Tenancy tests - unifications
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/3e239568 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/3e239568 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/3e239568 Branch: refs/heads/master Commit: 3e2395683eddb1c2f29675c5455d9e7f009bf2d9 Parents: 0bd397a Author: nir-sopher <n...@qwilt.com> Authored: Sun Jun 25 18:38:06 2017 +0300 Committer: Jeremy Mitchell <mitchell...@gmail.com> Committed: Wed Jul 19 15:55:31 2017 -0600 ---------------------------------------------------------------------- traffic_ops/app/t/api/1.2/tenant_access.t | 66 +++++++++++++------------- 1 file changed, 34 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3e239568/traffic_ops/app/t/api/1.2/tenant_access.t ---------------------------------------------------------------------- diff --git a/traffic_ops/app/t/api/1.2/tenant_access.t b/traffic_ops/app/t/api/1.2/tenant_access.t index 8cb5605..b764502 100644 --- a/traffic_ops/app/t/api/1.2/tenant_access.t +++ b/traffic_ops/app/t/api/1.2/tenant_access.t @@ -134,32 +134,23 @@ ok $t->put_ok('/api/1.2/user/current' => {Accept => 'application/json'} => logout_from_tenant_admin(); #access to himself -test_user_resource_read_allow_access ("A1", "A1", $tenants_data); -test_user_resource_write_allow_access("A1", "A1", $tenants_data); +test_tenants_allow_access ("A1", "A1", $tenants_data); #access to child -test_user_resource_read_allow_access ("A1", "A1a", $tenants_data); -test_user_resource_write_allow_access("A1", "A1a", $tenants_data); +test_tenants_allow_access ("A1", "A1a", $tenants_data); #access to even if child is inactive -test_user_resource_read_allow_access ("A1", "A1a", $tenants_data); -test_user_resource_write_allow_access("A1", "A1a", $tenants_data); +test_tenants_allow_access ("A1", "A1a", $tenants_data); #No access to parent -test_user_resource_read_block_access ("A1", "A", $tenants_data); -test_user_resource_write_block_access("A1", "A", $tenants_data); +test_tenants_block_access ("A1", "A", $tenants_data); #No access to brother -test_user_resource_read_block_access ("A1", "A2", $tenants_data); -test_user_resource_write_block_access("A1", "A2", $tenants_data); +test_tenants_block_access ("A1", "A2", $tenants_data); #No access to nephew -test_user_resource_read_block_access ("A1", "A2a", $tenants_data); -test_user_resource_write_block_access("A1", "A2a", $tenants_data); +test_tenants_block_access ("A1", "A2a", $tenants_data); #No access to uncle -test_user_resource_read_block_access ("A1", "B", $tenants_data); -test_user_resource_write_block_access("A1", "B", $tenants_data); +test_tenants_block_access ("A1", "B", $tenants_data); #No access to grandfather -test_user_resource_read_block_access ("A1", "root", $tenants_data); -test_user_resource_write_block_access("A1", "root", $tenants_data); +test_tenants_block_access ("A1", "root", $tenants_data); #access to "no-tenant" -test_user_resource_read_allow_access ("A1", "none", $tenants_data); -test_user_resource_write_allow_access("A1", "none", $tenants_data); +test_tenants_allow_access ("A1", "none", $tenants_data); #####Working as user from inactive tenant "A3" login_to_tenant_admin ("A3", $tenants_data); @@ -175,20 +166,15 @@ ok $t->put_ok('/api/1.2/user/current' => {Accept => 'application/json'} => , 'Cannot change my tenancy: tenant: A1?'; logout_from_tenant_admin(); #no access to anywhere -test_user_resource_read_block_access ("A3", "A3", $tenants_data); -test_user_resource_write_block_access("A3", "A3", $tenants_data); +test_tenants_block_access ("A3", "A3", $tenants_data); #child -test_user_resource_read_block_access ("A3", "A1a", $tenants_data); -test_user_resource_write_block_access("A3", "A1a", $tenants_data); +test_tenants_block_access ("A3", "A1a", $tenants_data); #to parent -test_user_resource_read_block_access ("A3", "A", $tenants_data); -test_user_resource_write_block_access("A3", "A", $tenants_data); +test_tenants_block_access ("A3", "A", $tenants_data); #No access to brother -test_user_resource_read_block_access ("A3", "A2", $tenants_data); -test_user_resource_write_block_access("A3", "A2", $tenants_data); +test_tenants_block_access ("A3", "A2", $tenants_data); #no access to "no-tenant" -test_user_resource_read_block_access ("A3", "none", $tenants_data); -test_user_resource_write_block_access("A3", "none", $tenants_data); +test_tenants_block_access ("A3", "none", $tenants_data); @@ -205,11 +191,9 @@ ok $t->put_ok('/api/1.2/user/current' => {Accept => 'application/json'} => , 'Cannot change my tenancy: tenant: A1?'; logout_from_tenant_admin(); #access to himself -test_user_resource_read_allow_access ("none", "none", $tenants_data); -test_user_resource_write_allow_access("none", "none", $tenants_data); +test_tenants_allow_access ("none", "none", $tenants_data); #No access to tenant -test_user_resource_read_block_access ("none", "A", $tenants_data); -test_user_resource_write_block_access("none", "A", $tenants_data); +test_tenants_block_access ("none", "A", $tenants_data); ######################################################################################## # All is done - lets cleanup @@ -325,6 +309,24 @@ sub deactivate_tenant { , 'Success deactivate tenant '.$name.'?'; } +sub test_tenants_allow_access { + my $login_tenant = shift; + my $resource_tenant = shift; + my $tenants_data = shift; + + test_user_resource_read_allow_access ($login_tenant, $resource_tenant, $tenants_data); + test_user_resource_write_allow_access ($login_tenant, $resource_tenant, $tenants_data); +} + +sub test_tenants_block_access { + my $login_tenant = shift; + my $resource_tenant = shift; + my $tenants_data = shift; + + test_user_resource_read_block_access ($login_tenant, $resource_tenant, $tenants_data); + test_user_resource_write_block_access ($login_tenant, $resource_tenant, $tenants_data); +} + sub login_to_tenant_admin { my $login_tenant_name = shift; my $tenants_data = shift;