Skip to content

Commit

Permalink
test-perl: Add tests for value max lengths from Limitations section
Browse files Browse the repository at this point in the history
  • Loading branch information
jajik committed Oct 8, 2024
1 parent 84d89c6 commit 128b1f5
Showing 1 changed file with 108 additions and 5 deletions.
113 changes: 108 additions & 5 deletions test-perl/t/mod_proxy_cluster/messages_config_nok.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use Apache::TestRequest 'GET';
# use Test::More;
use ModProxyCluster;

plan tests => 22;
plan tests => 70;

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

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

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

# Too long Alias and Context

# LIMITS
## Alias
my $long_alias = "a" x 256;
my $long_context = "c" x 81;

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

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

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

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

## TODO: Test other LIMITS
## Balancer
my $long_balancer = "b" x 41;
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', Balancer => $long_balancer );

ok $resp->is_error;
ok ($resp->content ne "");
ok ($resp->header("Type") eq "SYNTAX");
ok ($resp->header("Mess") eq "SYNTAX: Balancer field too big");

$resp = GET "$url/mod_cluster_manager";
ok $resp->is_success;
ok (index($resp->as_string, "Node spare") == -1);

## JVMRoute
my $long_route = "r" x ($is_httpd2_4 ? 65 : 97);
$resp = CMD 'CONFIG', $url, ( JVMRoute => $long_route );

ok $resp->is_error;
ok ($resp->content ne "");
ok ($resp->header("Type") eq "SYNTAX");
ok ($resp->header("Mess") eq "SYNTAX: JVMRoute field too big");

$resp = GET "$url/mod_cluster_manager";
ok $resp->is_success;
ok (index($resp->as_string, "Node $long_route") == -1);

## Domain
my $long_domain = "d" x 21;
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', Domain => $long_domain );

ok $resp->is_error;
ok ($resp->content ne "");
ok ($resp->header("Type") eq "SYNTAX");
ok ($resp->header("Mess") eq "SYNTAX: LBGroup field too big");

$resp = GET "$url/mod_cluster_manager";
ok $resp->is_success;
ok (index($resp->as_string, "Node spare") == -1);

## Host
my $long_host = "d" x 65;
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', Host => $long_host );

ok $resp->is_error;
ok ($resp->content ne "");
ok ($resp->header("Type") eq "SYNTAX");
ok ($resp->header("Mess") eq "SYNTAX: Host field too big");

$resp = GET "$url/mod_cluster_manager";
ok $resp->is_success;
ok (index($resp->as_string, "Node spare") == -1);

## Port
my $long_port = "p" x 8;
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', Port => $long_port );

ok $resp->is_error;
ok ($resp->content ne "");
ok ($resp->header("Type") eq "SYNTAX");
ok ($resp->header("Mess") eq "SYNTAX: Port field too big");

$resp = GET "$url/mod_cluster_manager";
ok $resp->is_success;
ok (index($resp->as_string, "Node spare") == -1);

## Type
my $long_type = "t" x 17;
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', Type => $long_type );

ok $resp->is_error;
ok ($resp->content ne "");
ok ($resp->header("Type") eq "SYNTAX");
ok ($resp->header("Mess") eq "SYNTAX: Type field too big");

$resp = GET "$url/mod_cluster_manager";
ok $resp->is_success;
ok (index($resp->as_string, "Node spare") == -1);

## StickySessionCookie
my $long_cookie = "d" x 31;
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', StickySessionCookie => $long_cookie );

ok $resp->is_error;
ok ($resp->content ne "");
ok ($resp->header("Type") eq "SYNTAX");
ok ($resp->header("Mess") eq "SYNTAX: A field is too big");

$resp = GET "$url/mod_cluster_manager";
ok $resp->is_success;
ok (index($resp->as_string, "Node spare") == -1);

## StickySessionPath
my $long_path = "p" x 31;
$resp = CMD 'CONFIG', $url, ( JVMRoute => 'spare', StickySessionPath => $long_path );

ok $resp->is_error;
ok ($resp->content ne "");
ok ($resp->header("Type") eq "SYNTAX");
ok ($resp->header("Mess") eq "SYNTAX: A field is too big");

$resp = GET "$url/mod_cluster_manager";
ok $resp->is_success;
ok (index($resp->as_string, "Node spare") == -1);

0 comments on commit 128b1f5

Please sign in to comment.