User tenancy verification - index test
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/0bd397ac Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/0bd397ac Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/0bd397ac Branch: refs/heads/master Commit: 0bd397ac89cd65c3a480abcfb4a131ab1a2b1729 Parents: 93bcdfb Author: nir-sopher <n...@qwilt.com> Authored: Sun Jun 25 17:50:26 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 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/0bd397ac/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 22df77b..8cb5605 100644 --- a/traffic_ops/app/t/api/1.2/tenant_access.t +++ b/traffic_ops/app/t/api/1.2/tenant_access.t @@ -81,16 +81,6 @@ my $count_response_test = sub { return $t->success( is( $t->$responses_counter(), $count ) ); }; -#Get the null tenants counters -ok $t->post_ok( '/login', => form => { u => Test::TestHelper::ADMIN_USER, p => Test::TestHelper::ADMIN_USER_PASSWORD } )->status_is(302) - ->or( sub { diag $t->tx->res->content->asset->{content}; } ), 'Should login?'; - -my $fixture_num_of_tenants = $t->get_ok('/api/1.2/tenants')->status_is(200)->$responses_counter(); -my $fixture_num_of_users = $t->get_ok('/api/1.2/users')->status_is(200)->$responses_counter(); - -ok $t->get_ok('/logout')->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } ); - - #Building up the setup ok $t->post_ok( '/login', => form => { u => Test::TestHelper::ADMIN_ROOT_USER, p => Test::TestHelper::ADMIN_ROOT_USER_PASSWORD } )->status_is(302) ->or( sub { diag $t->tx->res->content->asset->{content}; } ), 'Should login?'; @@ -116,6 +106,14 @@ deactivate_tenant("A3", $tenants_data); ok $t->get_ok('/logout')->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } ); +#Get the null tenants counters +ok $t->post_ok( '/login', => form => { u => Test::TestHelper::ADMIN_USER, p => Test::TestHelper::ADMIN_USER_PASSWORD } )->status_is(302) + ->or( sub { diag $t->tx->res->content->asset->{content}; } ), 'Should login?'; + +my $fixture_num_of_tenants = $t->get_ok('/api/1.2/tenants')->status_is(200)->$responses_counter(); +my $fixture_num_of_users = $t->get_ok('/api/1.2/users')->status_is(200)->$responses_counter(); + +ok $t->get_ok('/logout')->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } ); ######################################################################################## @@ -126,6 +124,7 @@ login_to_tenant_admin ("A1", $tenants_data); my $num_of_tenants_can_be_accessed = 3; #A1, A1a, A1b #sanity check on tenants - testing of tenant as a resource is taken care of in tenants.t ok $t->get_ok('/api/1.2/tenants')->status_is(200)->$count_response_test($num_of_tenants_can_be_accessed+$fixture_num_of_tenants); +ok $t->get_ok('/api/1.2/users')->status_is(200)->$count_response_test($num_of_tenants_can_be_accessed+$fixture_num_of_users); #cannot change its tenancy ok $t->put_ok('/api/1.2/user/current' => {Accept => 'application/json'} => json => { user => { tenantId => $tenants_data->{"A1a"}->{'id'}} } ) @@ -166,7 +165,8 @@ test_user_resource_write_allow_access("A1", "none", $tenants_data); login_to_tenant_admin ("A3", $tenants_data); $num_of_tenants_can_be_accessed = 0; #sanity check on tenants - testing of tenant as a resource is taken care of in tenants.t -ok $t->get_ok('/api/1.2/tenants')->status_is(200)->$count_response_test($num_of_tenants_can_be_accessed+$fixture_num_of_tenants); +ok $t->get_ok('/api/1.2/tenants')->status_is(200)->$count_response_test(0); +ok $t->get_ok('/api/1.2/users')->status_is(200)->$count_response_test(0); #cannot change its tenancy ok $t->put_ok('/api/1.2/user/current' => {Accept => 'application/json'} => json => { user => { tenantId => $tenants_data->{"A1a"}->{'id'}} } )