Skip to content

Commit 80ee647

Browse files
committed
test-perl: Add tests for value max lengths from Limitations section
1 parent 648d274 commit 80ee647

File tree

1 file changed

+108
-5
lines changed

1 file changed

+108
-5
lines changed

test-perl/t/mod_proxy_cluster/messages_config_nok.t

Lines changed: 108 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use Apache::TestRequest 'GET';
1313
# use Test::More;
1414
use ModProxyCluster;
1515

16-
plan tests => 22;
16+
plan tests => 70;
1717

1818
Apache::TestRequest::module("mpc_test_host");
1919
my $hostport = Apache::TestRequest::hostport();
@@ -24,6 +24,7 @@ my $resp = GET $url;
2424
ok $resp->is_success;
2525
ok (index($resp->as_string, "mod_cluster/2.0.0.Alpha1-SNAPSHOT") != -1);
2626

27+
my $is_httpd2_4 = $resp->header('Server') =~ m/Apache\/2\.4/;
2728

2829
##################
2930
##### CONFIG #####
@@ -46,10 +47,9 @@ ok ($resp->header("Type") eq "SYNTAX");
4647
# ok ($resp->header("Mess") eq "SYNTAX: Can't parse MCMP message. It might have contained illegal symbols or unknown elements.");
4748
ok ($resp->header("Mess") eq "SYNTAX: JVMRoute can't be empty");
4849

49-
# Too long Alias and Context
50-
50+
# LIMITS
51+
## Alias
5152
my $long_alias = "a" x 256;
52-
my $long_context = "c" x 81;
5353

5454
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', Alias => $long_alias );
5555

@@ -62,6 +62,8 @@ $resp = GET "$url/mod_cluster_manager";
6262
ok $resp->is_success;
6363
ok (index($resp->as_string, "Node spare") == -1);
6464

65+
## Context
66+
my $long_context = "c" x 81;
6567
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', Context => $long_context );
6668

6769
ok $resp->is_error;
@@ -73,5 +75,106 @@ $resp = GET "$url/mod_cluster_manager";
7375
ok $resp->is_success;
7476
ok (index($resp->as_string, "Node spare") == -1);
7577

76-
## TODO: Test other LIMITS
78+
## Balancer
79+
my $long_balancer = "b" x 41;
80+
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', Balancer => $long_balancer );
81+
82+
ok $resp->is_error;
83+
ok ($resp->content ne "");
84+
ok ($resp->header("Type") eq "SYNTAX");
85+
ok ($resp->header("Mess") eq "SYNTAX: Balancer field too big");
86+
87+
$resp = GET "$url/mod_cluster_manager";
88+
ok $resp->is_success;
89+
ok (index($resp->as_string, "Node spare") == -1);
90+
91+
## JVMRoute
92+
my $long_route = "r" x ($is_httpd2_4 ? 65 : 97);
93+
$resp = CMD 'CONFIG', $url, ( JVMRoute => $long_route );
94+
95+
ok $resp->is_error;
96+
ok ($resp->content ne "");
97+
ok ($resp->header("Type") eq "SYNTAX");
98+
ok ($resp->header("Mess") eq "SYNTAX: JVMRoute field too big");
99+
100+
$resp = GET "$url/mod_cluster_manager";
101+
ok $resp->is_success;
102+
ok (index($resp->as_string, "Node $long_route") == -1);
103+
104+
## Domain
105+
my $long_domain = "d" x 21;
106+
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', Domain => $long_domain );
107+
108+
ok $resp->is_error;
109+
ok ($resp->content ne "");
110+
ok ($resp->header("Type") eq "SYNTAX");
111+
ok ($resp->header("Mess") eq "SYNTAX: LBGroup field too big");
112+
113+
$resp = GET "$url/mod_cluster_manager";
114+
ok $resp->is_success;
115+
ok (index($resp->as_string, "Node spare") == -1);
116+
117+
## Host
118+
my $long_host = "d" x 65;
119+
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', Host => $long_host );
120+
121+
ok $resp->is_error;
122+
ok ($resp->content ne "");
123+
ok ($resp->header("Type") eq "SYNTAX");
124+
ok ($resp->header("Mess") eq "SYNTAX: Host field too big");
125+
126+
$resp = GET "$url/mod_cluster_manager";
127+
ok $resp->is_success;
128+
ok (index($resp->as_string, "Node spare") == -1);
129+
130+
## Port
131+
my $long_port = "p" x 8;
132+
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', Port => $long_port );
133+
134+
ok $resp->is_error;
135+
ok ($resp->content ne "");
136+
ok ($resp->header("Type") eq "SYNTAX");
137+
ok ($resp->header("Mess") eq "SYNTAX: Port field too big");
138+
139+
$resp = GET "$url/mod_cluster_manager";
140+
ok $resp->is_success;
141+
ok (index($resp->as_string, "Node spare") == -1);
142+
143+
## Type
144+
my $long_type = "t" x 17;
145+
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', Type => $long_type );
146+
147+
ok $resp->is_error;
148+
ok ($resp->content ne "");
149+
ok ($resp->header("Type") eq "SYNTAX");
150+
ok ($resp->header("Mess") eq "SYNTAX: Type field too big");
151+
152+
$resp = GET "$url/mod_cluster_manager";
153+
ok $resp->is_success;
154+
ok (index($resp->as_string, "Node spare") == -1);
155+
156+
## StickySessionCookie
157+
my $long_cookie = "d" x 31;
158+
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', StickySessionCookie => $long_cookie );
159+
160+
ok $resp->is_error;
161+
ok ($resp->content ne "");
162+
ok ($resp->header("Type") eq "SYNTAX");
163+
ok ($resp->header("Mess") eq "SYNTAX: A field is too big");
164+
165+
$resp = GET "$url/mod_cluster_manager";
166+
ok $resp->is_success;
167+
ok (index($resp->as_string, "Node spare") == -1);
168+
169+
## StickySessionPath
170+
my $long_path = "p" x 31;
171+
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', StickySessionPath => $long_path );
77172

173+
ok $resp->is_error;
174+
ok ($resp->content ne "");
175+
ok ($resp->header("Type") eq "SYNTAX");
176+
ok ($resp->header("Mess") eq "SYNTAX: A field is too big");
177+
178+
$resp = GET "$url/mod_cluster_manager";
179+
ok $resp->is_success;
180+
ok (index($resp->as_string, "Node spare") == -1);

0 commit comments

Comments
 (0)