You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2017/07/10 20:49:55 UTC
[03/14] incubator-trafficcontrol git commit: Org tenancy - nerge
users & ds tenancy
Org tenancy - nerge users & ds tenancy
adding deliveryservice.t back
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/c9d117cb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/c9d117cb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/c9d117cb
Branch: refs/heads/master
Commit: c9d117cb1f77e521a2695604bb45d3c5f030015d
Parents: 6fbab5d
Author: nir-sopher <ni...@gmail.com>
Authored: Tue Apr 4 20:55:32 2017 +0300
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600
----------------------------------------------------------------------
.../20170315000003_delivery_service_tenancy.sql | 30 --------------------
.../20170404000000_delivery_service_tenancy.sql | 30 ++++++++++++++++++++
traffic_ops/app/lib/API/Tenant.pm | 3 +-
traffic_ops/app/lib/Fixtures/Deliveryservice.pm | 2 +-
traffic_ops/app/lib/Schema/Result/Tenant.pm | 4 +--
traffic_ops/app/t/api/1.2/deliveryservice.t | 3 +-
.../app/t/api/1.2/deliveryservice_crud.t | 3 +-
traffic_ops/app/t/api/1.2/tenant.t | 1 +
8 files changed, 40 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c9d117cb/traffic_ops/app/db/migrations/20170315000003_delivery_service_tenancy.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170315000003_delivery_service_tenancy.sql b/traffic_ops/app/db/migrations/20170315000003_delivery_service_tenancy.sql
deleted file mode 100644
index a737d0c..0000000
--- a/traffic_ops/app/db/migrations/20170315000003_delivery_service_tenancy.sql
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
--- +goose Up
--- SQL in section 'Up' is executed when this migration is applied
-
-ALTER TABLE deliveryservice
- ADD tenant_id BIGINT,
- ADD CONSTRAINT fk_tenantid FOREIGN KEY (tenant_id) REFERENCES tenant (id) MATCH FULL,
- ALTER COLUMN tenant_id SET DEFAULT NULL;
-CREATE INDEX idx_k_deliveryservice_tenant_idx ON deliveryservice USING btree (tenant_id);
-
--- +goose Down
--- SQL section 'Down' is executed when this migration is rolled back
-
-ALTER TABLE deliveryservice
-DROP COLUMN tenant_id;
-
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c9d117cb/traffic_ops/app/db/migrations/20170404000000_delivery_service_tenancy.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170404000000_delivery_service_tenancy.sql b/traffic_ops/app/db/migrations/20170404000000_delivery_service_tenancy.sql
new file mode 100644
index 0000000..a737d0c
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20170404000000_delivery_service_tenancy.sql
@@ -0,0 +1,30 @@
+/*
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+
+ALTER TABLE deliveryservice
+ ADD tenant_id BIGINT,
+ ADD CONSTRAINT fk_tenantid FOREIGN KEY (tenant_id) REFERENCES tenant (id) MATCH FULL,
+ ALTER COLUMN tenant_id SET DEFAULT NULL;
+CREATE INDEX idx_k_deliveryservice_tenant_idx ON deliveryservice USING btree (tenant_id);
+
+-- +goose Down
+-- SQL section 'Down' is executed when this migration is rolled back
+
+ALTER TABLE deliveryservice
+DROP COLUMN tenant_id;
+
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c9d117cb/traffic_ops/app/lib/API/Tenant.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Tenant.pm b/traffic_ops/app/lib/API/Tenant.pm
index 784cb67..c21528b 100644
--- a/traffic_ops/app/lib/API/Tenant.pm
+++ b/traffic_ops/app/lib/API/Tenant.pm
@@ -255,10 +255,11 @@ sub delete {
return $self->alert("Tenant '$name' has children tenant(s): e.g '$existing_child'. Please update these tenants and retry.");
}
- #The order of the below tests is intentional - allowing UT to cover all cases - TODO(nirs) remove this comment when a full "tenancy" UT is added, including permissions and such (no use in putting effort into it yet)
+ #The order of the below tests is intentional
my $existing_ds = $self->db->resultset('Deliveryservice')->search( { tenant_id => $id })->get_column('xml_id')->first();
if ($existing_ds) {
return $self->alert("Tenant '$name' is assign with delivery-services(s): e.g. '$existing_ds'. Please update/delete these delivery-services and retry.");
+ }
my $existing_user = $self->db->resultset('TmUser')->search( { tenant_id => $id }, {order_by => 'me.username' })->get_column('username')->first();
if ($existing_user) {
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c9d117cb/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Deliveryservice.pm b/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
index a340540..7829c2d 100644
--- a/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
@@ -542,7 +542,7 @@ my %definition_for = (
check_path => '/crossdomain.xml',
type => 21,
profile => 100,
- cdn_id => 100,#TODO(nirs) on merge - change to 300
+ cdn_id => 100,
ipv6_routing_enabled => 1,
protocol => 1,
display_name => 'test-ds1-root-displayname',
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c9d117cb/traffic_ops/app/lib/Schema/Result/Tenant.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Tenant.pm b/traffic_ops/app/lib/Schema/Result/Tenant.pm
index da89550..3dadffe 100644
--- a/traffic_ops/app/lib/Schema/Result/Tenant.pm
+++ b/traffic_ops/app/lib/Schema/Result/Tenant.pm
@@ -179,8 +179,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-03-20 09:11:40
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:W4nbCNSj6N1gMar0mRvQ5Q
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-04-04 20:51:35
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7I7o08tTBHjshtXVypmOUw
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c9d117cb/traffic_ops/app/t/api/1.2/deliveryservice.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/deliveryservice.t b/traffic_ops/app/t/api/1.2/deliveryservice.t
index 7aee053..609718e 100644
--- a/traffic_ops/app/t/api/1.2/deliveryservice.t
+++ b/traffic_ops/app/t/api/1.2/deliveryservice.t
@@ -41,7 +41,7 @@ my $login_password = shift;
Test::TestHelper->unload_core_data($schema);
Test::TestHelper->load_core_data($schema);
-my $tenant_id = undef;#user does not have tenancy currently
+my $tenant_id = $schema->resultset('TmUser')->find( { username => $login_user } )->get_column('tenant_id');
my $tenant_name = defined ($tenant_id) ? $schema->resultset('Tenant')->find( { id => $tenant_id } )->get_column('name') : "null";
ok $t->post_ok( '/login', => form => { u => $login_user, p => $login_password } )->status_is(302)
@@ -451,6 +451,7 @@ my $dbh = Schema->database_handle;
my $t = Test::Mojo->new('TrafficOps');
run_ut($t, $schema, Test::TestHelper::ADMIN_USER, Test::TestHelper::ADMIN_USER_PASSWORD);
+run_ut($t, $schema, Test::TestHelper::ADMIN_ROOT_USER, Test::TestHelper::ADMIN_ROOT_USER_PASSWORD);
$dbh->disconnect();
done_testing();
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c9d117cb/traffic_ops/app/t/api/1.2/deliveryservice_crud.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/deliveryservice_crud.t b/traffic_ops/app/t/api/1.2/deliveryservice_crud.t
index 145177c..dac05e9 100644
--- a/traffic_ops/app/t/api/1.2/deliveryservice_crud.t
+++ b/traffic_ops/app/t/api/1.2/deliveryservice_crud.t
@@ -41,7 +41,7 @@ sub run_ut {
Test::TestHelper->unload_core_data($schema);
Test::TestHelper->load_core_data($schema);
- my $tenant_id = undef;#TODO(nirs) change when users tenancy is merged
+ my $tenant_id = $schema->resultset('TmUser')->find( { username => $login_user } )->get_column('tenant_id');
my $tenant_name = defined ($tenant_id) ? $schema->resultset('Tenant')->find( { id => $tenant_id } )->get_column('name') : "null";
ok $t->post_ok( '/login', => form => { u => $login_user, p => $login_password } )->status_is(302)
@@ -280,6 +280,7 @@ my $dbh = Schema->database_handle;
my $t = Test::Mojo->new('TrafficOps');
run_ut($t, $schema, Test::TestHelper::ADMIN_USER, Test::TestHelper::ADMIN_USER_PASSWORD);
+run_ut($t, $schema, Test::TestHelper::ADMIN_ROOT_USER, Test::TestHelper::ADMIN_ROOT_USER_PASSWORD);
$dbh->disconnect();
done_testing();
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c9d117cb/traffic_ops/app/t/api/1.2/tenant.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/tenant.t b/traffic_ops/app/t/api/1.2/tenant.t
index 384c407..986f919 100644
--- a/traffic_ops/app/t/api/1.2/tenant.t
+++ b/traffic_ops/app/t/api/1.2/tenant.t
@@ -158,6 +158,7 @@ ok $t->delete_ok('/api/1.2/tenants/' . 10**9)->status_is(400)
->or( sub { diag $t->tx->res->content->asset->{content}; } );
ok $t->delete_ok('/api/1.2/deliveryservices/' . 2100)->status_is(200)
+ ->or( sub { diag $t->tx->res->content->asset->{content}; } );
#cannot delete a tenant that have a user
ok $t->delete_ok('/api/1.2/tenants/' . 10**9)->status_is(400)