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:53 UTC
[01/14] incubator-trafficcontrol git commit: Org tenancy - rename
migration file
Repository: incubator-trafficcontrol
Updated Branches:
refs/heads/master 4e4eac88d -> 7d0883914
Org tenancy - rename migration file
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/b34693ee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/b34693ee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/b34693ee
Branch: refs/heads/master
Commit: b34693ee9f9fd15104b8e461513b54bce78cbb21
Parents: e5f054b
Author: nir-sopher <ni...@qwilt.com>
Authored: Mon Jun 26 11:32:28 2017 +0300
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600
----------------------------------------------------------------------
.../20170621000000_delivery_service_tenancy.sql | 30 --------------------
.../20170628000000_delivery_service_tenancy.sql | 30 ++++++++++++++++++++
2 files changed, 30 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/b34693ee/traffic_ops/app/db/migrations/20170621000000_delivery_service_tenancy.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170621000000_delivery_service_tenancy.sql b/traffic_ops/app/db/migrations/20170621000000_delivery_service_tenancy.sql
deleted file mode 100644
index a737d0c..0000000
--- a/traffic_ops/app/db/migrations/20170621000000_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/b34693ee/traffic_ops/app/db/migrations/20170628000000_delivery_service_tenancy.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170628000000_delivery_service_tenancy.sql b/traffic_ops/app/db/migrations/20170628000000_delivery_service_tenancy.sql
new file mode 100644
index 0000000..a737d0c
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20170628000000_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;
+
[09/14] incubator-trafficcontrol git commit: DS API added tenant - Doc
Posted by mi...@apache.org.
DS API added tenant - Doc
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/80d586fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/80d586fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/80d586fd
Branch: refs/heads/master
Commit: 80d586fde606805b624e5bdc96a5e4c71970d8a4
Parents: 7d4ea45
Author: nir-sopher <ni...@gmail.com>
Authored: Wed Mar 22 23:02:09 2017 +0200
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600
----------------------------------------------------------------------
.../traffic_ops_api/v12/deliveryservice.rst | 14 ++++++++++++++
.../source/development/traffic_ops_api/v12/server.rst | 3 +++
2 files changed, 17 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/80d586fd/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
----------------------------------------------------------------------
diff --git a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
index 694436a..2d04604 100644
--- a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
+++ b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
@@ -174,6 +174,8 @@ Delivery Service
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
| ``sslKeyVersion`` | int | |
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
+ | ``tenantId`` | int | Owning tenant ID |
+ +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
| ``trRequestHeaders`` | string | |
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
| ``trResponseHeaders`` | string | |
@@ -238,6 +240,7 @@ Delivery Service
"remapText": null,
"signed": false,
"sslKeyVersion": "0",
+ "tenantId": 1,
"trRequestHeaders": null,
"trResponseHeaders": "Access-Control-Allow-Origin: *",
"type": "HTTP",
@@ -403,6 +406,8 @@ Delivery Service
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
| ``sslKeyVersion`` | int | |
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
+ | ``tenantId`` | int | Owning tenant ID |
+ +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
| ``trRequestHeaders`` | string | |
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
| ``trResponseHeaders`` | string | |
@@ -474,6 +479,7 @@ Delivery Service
"remapText": null,
"signed": false,
"sslKeyVersion": "0",
+ "tenantId": 1,
"trRequestHeaders": null,
"trResponseHeaders": "Access-Control-Allow-Origin: *",
"type": "HTTP",
@@ -1877,6 +1883,8 @@ SSL Keys
+========================+==========+=========================================================================================================+
| active | yes | true if active, false if inactive. |
+------------------------+----------+---------------------------------------------------------------------------------------------------------+
+ | tenantId | No | Owning tenant ID |
+ +------------------------+----------+---------------------------------------------------------------------------------------------------------+
| cacheurl | no | Cache URL rule to apply to this delivery service. |
+------------------------+----------+---------------------------------------------------------------------------------------------------------+
| ccrDnsTtl | no | The TTL of the DNS response for A or AAAA queries requesting the IP address of the tr.host. |
@@ -2004,6 +2012,7 @@ SSL Keys
{
"xmlId": "my_ds_1",
"displayName": "my_ds_displayname_1",
+ "tenantId": 1,
"protocol": 1,
"orgServerFqdn": "http://10.75.168.91",
"cdnId": 2,
@@ -2231,6 +2240,7 @@ SSL Keys
"remapText": null,
"signed": false,
"sslKeyVersion": "0",
+ "tenantId": 1,
"trRequestHeaders": null,
"trResponseHeaders": "Access-Control-Allow-Origin: *",
"type": "HTTP",
@@ -2265,6 +2275,8 @@ SSL Keys
+========================+==========+=========================================================================================================+
| active | yes | true if active, false if inactive. |
+------------------------+----------+---------------------------------------------------------------------------------------------------------+
+ | tenantId | no | Owning tenant ID |
+ +------------------------+----------+---------------------------------------------------------------------------------------------------------+
| cacheurl | no | Cache URL rule to apply to this delivery service. |
+------------------------+----------+---------------------------------------------------------------------------------------------------------+
| ccrDnsTtl | no | The TTL of the DNS response for A or AAAA queries requesting the IP address of the tr.host. |
@@ -2391,6 +2403,7 @@ SSL Keys
{
"xmlId": "my_ds_1",
"displayName": "my_ds_displayname_1",
+ "tenantId": 1,
"protocol": 1,
"orgServerFqdn": "http://10.75.168.91",
"cdnId": 2,
@@ -2618,6 +2631,7 @@ SSL Keys
"remapText": null,
"signed": false,
"sslKeyVersion": "0",
+ "tenantId": 1,
"trRequestHeaders": null,
"trResponseHeaders": "Access-Control-Allow-Origin: *",
"type": "HTTP",
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/80d586fd/docs/source/development/traffic_ops_api/v12/server.rst
----------------------------------------------------------------------
diff --git a/docs/source/development/traffic_ops_api/v12/server.rst b/docs/source/development/traffic_ops_api/v12/server.rst
index 27ccbf3..3e47dcc 100644
--- a/docs/source/development/traffic_ops_api/v12/server.rst
+++ b/docs/source/development/traffic_ops_api/v12/server.rst
@@ -488,6 +488,8 @@ Server
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
| ``sslKeyVersion`` | string | |
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
+ | ``tenantId`` | int | Owning tenant ID. |
+ +--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
| ``trRequestHeaders`` | string | |
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
| ``trResponseHeaders`` | string | |
@@ -562,6 +564,7 @@ Server
"remapText": null,
"signed": false,
"sslKeyVersion": "0",
+ "tenantId": 1,
"trRequestHeaders": null,
"trResponseHeaders": "Access-Control-Allow-Origin: *",
"type": "HTTP",
[08/14] incubator-trafficcontrol git commit: A tenant cannot be
deleted if a ds is assigned to it
Posted by mi...@apache.org.
A tenant cannot be deleted if a ds is assigned to it
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/7d4ea45e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/7d4ea45e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/7d4ea45e
Branch: refs/heads/master
Commit: 7d4ea45e53dd67926d80f43640dc8c2343cac091
Parents: dc000f8
Author: nir-sopher <ni...@gmail.com>
Authored: Wed Mar 22 23:00:54 2017 +0200
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600
----------------------------------------------------------------------
traffic_ops/app/lib/API/Tenant.pm | 5 +++++
traffic_ops/app/t/api/1.2/tenant.t | 8 ++++++++
2 files changed, 13 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/7d4ea45e/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 c09df37..784cb67 100644
--- a/traffic_ops/app/lib/API/Tenant.pm
+++ b/traffic_ops/app/lib/API/Tenant.pm
@@ -255,6 +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)
+ 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) {
return $self->alert("Tenant '$name' is assign with user(s): e.g. '$existing_user'. Please update these users and retry.");
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/7d4ea45e/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 a66a8a3..ece6d3e 100644
--- a/traffic_ops/app/t/api/1.2/tenant.t
+++ b/traffic_ops/app/t/api/1.2/tenant.t
@@ -152,6 +152,14 @@ ok $t->delete_ok('/api/1.2/tenants/' . $tenantE_id)->status_is(200)->or( sub { d
ok $t->delete_ok('/api/1.2/tenants/' . $tenantD_id)->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
ok $t->delete_ok('/api/1.2/tenants/' . $tenantA_id)->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
+#TODO(nirs): move to a "tenancy" UT when written
+#cannot delete a tenant that have a delivery-service
+ok $t->delete_ok('/api/1.2/tenants/' . 10**9)->status_is(400)
+ ->json_is( "/alerts/0/text" => "Tenant 'root' is assign with delivery-services(s): e.g. 'test-ds1-root'. Please update/delete these delivery-services and retry." )
+ ->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+ok $t->delete_ok('/api/1.2/deliveryservices/' . 2100)->status_is(200)
+
#cannot delete a tenant that have a user
ok $t->delete_ok('/api/1.2/tenants/' . 10**9)->status_is(400)
->json_is( "/alerts/0/text" => "Tenant 'root' is assign with user(s): e.g. 'admin-root'. Please update these users and retry." )
[11/14] incubator-trafficcontrol git commit: Rename the
delivery_service_tenancy migration file, waiting for the pull
Posted by mi...@apache.org.
Rename the delivery_service_tenancy migration file, waiting for the pull
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/1e361b73
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/1e361b73
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/1e361b73
Branch: refs/heads/master
Commit: 1e361b736678b182ed153483d65e133444277b90
Parents: 6d67f5f
Author: nir-sopher <ni...@qwilt.com>
Authored: Wed Jun 21 00:15:33 2017 +0300
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600
----------------------------------------------------------------------
.../20170602000000_delivery_service_tenancy.sql | 30 --------------------
.../20170621000000_delivery_service_tenancy.sql | 30 ++++++++++++++++++++
2 files changed, 30 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/1e361b73/traffic_ops/app/db/migrations/20170602000000_delivery_service_tenancy.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170602000000_delivery_service_tenancy.sql b/traffic_ops/app/db/migrations/20170602000000_delivery_service_tenancy.sql
deleted file mode 100644
index a737d0c..0000000
--- a/traffic_ops/app/db/migrations/20170602000000_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/1e361b73/traffic_ops/app/db/migrations/20170621000000_delivery_service_tenancy.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170621000000_delivery_service_tenancy.sql b/traffic_ops/app/db/migrations/20170621000000_delivery_service_tenancy.sql
new file mode 100644
index 0000000..a737d0c
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20170621000000_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;
+
[07/14] incubator-trafficcontrol git commit: UI: Added elivery
service has the creating user tenancy
Posted by mi...@apache.org.
UI: Added elivery service has the creating user tenancy
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/dc000f8f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/dc000f8f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/dc000f8f
Branch: refs/heads/master
Commit: dc000f8f9117d30fe75051588c3a7b6d68400240
Parents: 23806ce
Author: nir-sopher <ni...@gmail.com>
Authored: Wed Mar 22 22:59:57 2017 +0200
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600
----------------------------------------------------------------------
traffic_ops/app/lib/UI/DeliveryService.pm | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/dc000f8f/traffic_ops/app/lib/UI/DeliveryService.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/DeliveryService.pm b/traffic_ops/app/lib/UI/DeliveryService.pm
index 51d7840..b9e33e5 100644
--- a/traffic_ops/app/lib/UI/DeliveryService.pm
+++ b/traffic_ops/app/lib/UI/DeliveryService.pm
@@ -1054,6 +1054,7 @@ sub create {
remap_text => $self->paramAsScalar( 'ds.remap_text', undef ),
initial_dispersion => $self->paramAsScalar( 'ds.initial_dispersion', 1 ),
logs_enabled => $self->paramAsScalar('ds.logs_enabled'),
+ tenant_id => current_user_tenant($self),#Tenancy is not dealt by the UI for now. getting the tenancy from the user
}
);
$insert->insert();
[10/14] incubator-trafficcontrol git commit: tenancy ds test - verify
stability
Posted by mi...@apache.org.
tenancy ds test - verify stability
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/0b0d9e54
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/0b0d9e54
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/0b0d9e54
Branch: refs/heads/master
Commit: 0b0d9e5411f863059e5667ae49f29c7ca2b2dcfe
Parents: c9d117c
Author: nir-sopher <ni...@gmail.com>
Authored: Thu Apr 6 19:36:47 2017 +0300
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600
----------------------------------------------------------------------
traffic_ops/app/lib/API/Tenant.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/0b0d9e54/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 c21528b..3bcdd0f 100644
--- a/traffic_ops/app/lib/API/Tenant.pm
+++ b/traffic_ops/app/lib/API/Tenant.pm
@@ -256,7 +256,7 @@ sub delete {
}
#The order of the below tests is intentional
- my $existing_ds = $self->db->resultset('Deliveryservice')->search( { tenant_id => $id })->get_column('xml_id')->first();
+ my $existing_ds = $self->db->resultset('Deliveryservice')->search( { tenant_id => $id }, {order_by => 'me.xml_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.");
}
[03/14] incubator-trafficcontrol git commit: Org tenancy - nerge
users & ds tenancy
Posted by mi...@apache.org.
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)
[05/14] incubator-trafficcontrol git commit: Delivery service tenancy
- API
Posted by mi...@apache.org.
Delivery service tenancy - API
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/17ff770e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/17ff770e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/17ff770e
Branch: refs/heads/master
Commit: 17ff770ec09e3f66be2710c67e17feac4d675324
Parents: c041291
Author: nir-sopher <ni...@gmail.com>
Authored: Mon Mar 20 19:36:31 2017 +0200
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600
----------------------------------------------------------------------
traffic_ops/app/lib/API/Deliveryservice.pm | 17 +-
traffic_ops/app/lib/API/Deliveryservice2.pm | 13 +
traffic_ops/app/lib/Fixtures/Deliveryservice.pm | 40 +++
traffic_ops/app/t/api/1.2/deliveryservice.t | 116 +++++++-
.../app/t/api/1.2/deliveryservice_crud.t | 296 +++++++++++++++++++
5 files changed, 475 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/17ff770e/traffic_ops/app/lib/API/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Deliveryservice.pm b/traffic_ops/app/lib/API/Deliveryservice.pm
index ee68788..0b5fa5e 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -133,6 +133,7 @@ sub index {
"remapText" => $row->remap_text,
"signed" => \$row->signed,
"sslKeyVersion" => $row->ssl_key_version,
+ "tenantId" => $row->tenant_id,
"trRequestHeaders" => $row->tr_request_headers,
"trResponseHeaders" => $row->tr_response_headers,
"type" => $row->type->name,
@@ -248,6 +249,7 @@ sub show {
"remapText" => $row->remap_text,
"signed" => \$row->signed,
"sslKeyVersion" => $row->ssl_key_version,
+ "tenantId" => $row->tenant_id,
"trRequestHeaders" => $row->tr_request_headers,
"trResponseHeaders" => $row->tr_response_headers,
"type" => $row->type->name,
@@ -285,6 +287,9 @@ sub update {
return $self->alert( "A deliveryservice with xmlId " . $xml_id . " already exists." );
}
}
+
+ #setting tenant_id to undef if tenant is not set. TODO(nirs): remove when tenancy is no longer optional in the API
+ my $tenant_id = exists($params->{tenantId}) ? $params->{tenantId} : undef;
my $values = {
active => $params->{active},
@@ -329,6 +334,7 @@ sub update {
remap_text => $params->{remapText},
signed => $params->{signed},
ssl_key_version => $params->{sslKeyVersion},
+ tenant_id => $tenant_id,
tr_request_headers => $params->{trRequestHeaders},
tr_response_headers => $params->{trResponseHeaders},
type => $params->{typeId},
@@ -415,6 +421,7 @@ sub update {
"remapText" => $rs->remap_text,
"signed" => $rs->signed,
"sslKeyVersion" => $rs->ssl_key_version,
+ "tenantId" => $rs->tenant_id,
"trRequestHeaders" => $rs->tr_request_headers,
"trResponseHeaders" => $rs->tr_response_headers,
"type" => $rs->type->name,
@@ -446,11 +453,15 @@ sub create {
return $self->alert($result);
}
+
my $xml_id = $params->{xmlId};
my $existing = $self->db->resultset('Deliveryservice')->find( { xml_id => $xml_id } );
if ($existing) {
return $self->alert( "A deliveryservice with xmlId " . $xml_id . " already exists." );
}
+
+ #setting tenant_id to the user id if tenant is not set. TODO(nirs): remove when tenancy is no longer optional in the API
+ my $tenant_id = exists($params->{tenantId}) ? $params->{tenantId} : $self->current_user_tenant();
my $values = {
active => $params->{active},
@@ -495,6 +506,7 @@ sub create {
remap_text => $params->{remapText},
signed => $params->{signed},
ssl_key_version => $params->{sslKeyVersion},
+ tenant_id => $tenant_id,
tr_request_headers => $params->{trRequestHeaders},
tr_response_headers => $params->{trResponseHeaders},
type => $params->{typeId},
@@ -594,6 +606,7 @@ sub create {
"remapText" => $insert->remap_text,
"signed" => $insert->signed,
"sslKeyVersion" => $insert->ssl_key_version,
+ "tenantId" => $insert->tenant_id,
"trRequestHeaders" => $insert->tr_request_headers,
"trResponseHeaders" => $insert->tr_response_headers,
"type" => $insert->type->name,
@@ -703,6 +716,7 @@ sub get_deliveryservices_by_serverId {
"remapText" => $row->remap_text,
"signed" => \$row->signed,
"sslKeyVersion" => $row->ssl_key_version,
+ "tenantId" => $row->tenant_id,
"trRequestHeaders" => $row->tr_request_headers,
"trResponseHeaders" => $row->tr_response_headers,
"type" => $row->type->name,
@@ -777,6 +791,7 @@ sub get_deliveryservices_by_userId {
"remapText" => $row->remap_text,
"signed" => \$row->signed,
"sslKeyVersion" => $row->ssl_key_version,
+ "tenantId" => $row->tenant_id,
"trRequestHeaders" => $row->tr_request_headers,
"trResponseHeaders" => $row->tr_response_headers,
"type" => $row->type->name,
@@ -1073,7 +1088,7 @@ sub is_deliveryservice_valid {
my $rules = {
fields => [
- qw/active cacheurl ccrDnsTtl cdnId checkPath displayName dnsBypassCname dnsBypassIp dnsBypassIp6 dnsBypassTtl dscp edgeHeaderRewrite geoLimitRedirectURL geoLimit geoLimitCountries geoProvider globalMaxMbps globalMaxTps httpBypassFqdn infoUrl initialDispersion ipv6RoutingEnabled logsEnabled longDesc longDesc1 longDesc2 maxDnsAnswers midHeaderRewrite missLat missLong multiSiteOrigin multiSiteOriginAlgorithm orgServerFqdn originShield profileId protocol qstringIgnore rangeRequestHandling regexRemap regionalGeoBlocking remapText signed sslKeyVersion trRequestHeaders trResponseHeaders typeId xmlId/
+ qw/active cacheurl ccrDnsTtl cdnId checkPath displayName dnsBypassCname dnsBypassIp dnsBypassIp6 dnsBypassTtl dscp edgeHeaderRewrite geoLimitRedirectURL geoLimit geoLimitCountries geoProvider globalMaxMbps globalMaxTps httpBypassFqdn infoUrl initialDispersion ipv6RoutingEnabled logsEnabled longDesc longDesc1 longDesc2 maxDnsAnswers midHeaderRewrite missLat missLong multiSiteOrigin multiSiteOriginAlgorithm orgServerFqdn originShield profileId protocol qstringIgnore rangeRequestHandling regexRemap regionalGeoBlocking remapText signed sslKeyVersion tenantId trRequestHeaders trResponseHeaders typeId xmlId/
],
# Validation checks to perform
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/17ff770e/traffic_ops/app/lib/API/Deliveryservice2.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Deliveryservice2.pm b/traffic_ops/app/lib/API/Deliveryservice2.pm
index de443f7..8b3846e 100644
--- a/traffic_ops/app/lib/API/Deliveryservice2.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice2.pm
@@ -130,6 +130,7 @@ sub delivery_services {
"remapText" => $row->remap_text,
"signed" => \$row->signed,
"sslKeyVersion" => $row->ssl_key_version,
+ "tenantId" => $row->tenant_id,
"trRequestHeaders" => $row->tr_request_headers,
"trResponseHeaders" => $row->tr_response_headers,
"type" => $row->type->name,
@@ -448,6 +449,16 @@ sub _check_params {
$transformed_params->{logsEnabled} = 0;
}
+ if (defined($ds_id)) {
+ #update
+ #setting tenant_id to undef if tenant is not set. TODO(nirs): remove when tenancy is no longer optional in the API
+ $transformed_params->{tenantId} = exists($params->{tenantId}) ? $params->{tenantId} : undef;
+ } else {
+ #create
+ #setting tenant_id to the runing user if tenant is not set. TODO(nirs): remove when tenancy is no longer optional in the API
+ $transformed_params->{tenantId} = exists($params->{tenantId}) ? $params->{tenantId} : $self->current_user_tenant();
+ }
+
return ($transformed_params, undef);
}
@@ -503,6 +514,7 @@ sub new_value {
tr_request_headers => $params->{trRequestHeaders},
tr_response_headers => $params->{trResponseHeaders},
logs_enabled => $transformed_params->{logsEnabled},
+ tenant_id => $transformed_params->{tenantId},
};
return $value;
@@ -562,6 +574,7 @@ sub get_response {
$response->{initialDispersion} = $rs->initial_dispersion;
$response->{dnsBypassCname} = $rs->dns_bypass_cname;
$response->{regionalGeoBlocking} = $rs->regional_geo_blocking;
+ $response->{tenantId} = $rs->tenant_id;
$response->{trRequestHeaders} = $rs->tr_request_headers;
$response->{logsEnabled} = $rs->logs_enabled==1 ? "true" : "false";
}
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/17ff770e/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 0f91ede..a340540 100644
--- a/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
@@ -512,6 +512,46 @@ my %definition_for = (
regional_geo_blocking => 1,
},
},
+ ds_cdn1_root => {
+ new => 'Deliveryservice',
+ using => {
+ id => 2100,
+ xml_id => 'test-ds1-root',
+ active => 1,
+ tenant_id => 10**9,
+ dscp => 40,
+ signed => 0,
+ qstring_ignore => 0,
+ geo_limit => 0,
+ http_bypass_fqdn => '',
+ dns_bypass_ip => '',
+ dns_bypass_ip6 => '',
+ dns_bypass_ttl => -1,
+ ccr_dns_ttl => 3600,
+ global_max_mbps => 0,
+ global_max_tps => 0,
+ long_desc => 'test-ds1-root long_desc',
+ long_desc_1 => 'test-ds1-root long_desc_1',
+ long_desc_2 => 'test-ds1-root long_desc_2',
+ max_dns_answers => 0,
+ protocol => 0,
+ org_server_fqdn => 'http://test-ds1-root.edge',
+ info_url => 'http://test-ds1-root.edge/info_url.html',
+ miss_lat => '41.881944',
+ miss_long => '-87.627778',
+ check_path => '/crossdomain.xml',
+ type => 21,
+ profile => 100,
+ cdn_id => 100,#TODO(nirs) on merge - change to 300
+ ipv6_routing_enabled => 1,
+ protocol => 1,
+ display_name => 'test-ds1-root-displayname',
+ initial_dispersion => 1,
+ regional_geo_blocking => 1,
+ logs_enabled => 1,
+ },
+ },
+
);
sub get_definition {
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/17ff770e/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 58134af..7aee053 100644
--- a/traffic_ops/app/t/api/1.2/deliveryservice.t
+++ b/traffic_ops/app/t/api/1.2/deliveryservice.t
@@ -30,14 +30,21 @@ use Test::TestHelper;
BEGIN { $ENV{MOJO_MODE} = "test" }
-my $schema = Schema->connect_to_database;
-my $dbh = Schema->database_handle;
-my $t = Test::Mojo->new('TrafficOps');
+
+sub run_ut {
+
+my $t = shift;
+my $schema = shift;
+my $login_user = shift;
+my $login_password = shift;
Test::TestHelper->unload_core_data($schema);
Test::TestHelper->load_core_data($schema);
-ok $t->post_ok( '/login', => form => { u => Test::TestHelper::ADMIN_USER, p => Test::TestHelper::ADMIN_USER_PASSWORD } )->status_is(302)
+my $tenant_id = undef;#user does not have tenancy currently
+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)
->or( sub { diag $t->tx->res->content->asset->{content}; } ), 'Should login?';
# Count the 'response number'
@@ -81,7 +88,9 @@ ok $t->get_ok("/api/1.2/deliveryservices/list?logsEnabled=true")->status_is(200)
->json_is( "/response/0/xmlId", "test-ds1" )
->json_is( "/response/0/logsEnabled", 1 )
->json_is( "/response/0/ipv6RoutingEnabled", 1 )
- ->json_is( "/response/1/xmlId", "test-ds4" );
+ ->json_is( "/response/1/xmlId", "test-ds1-root" )
+ ->json_is( "/response/1/tenantId", 10**9 )
+ ->json_is( "/response/2/xmlId", "test-ds4" );
# It creates new delivery services
ok $t->post_ok('/api/1.2/deliveryservices/create' => {Accept => 'application/json'} => json => {
@@ -90,6 +99,7 @@ ok $t->post_ok('/api/1.2/deliveryservices/create' => {Accept => 'application/jso
"protocol" => "1",
"orgServerFqdn" => "http://10.75.168.91",
"cdnName" => "cdn1",
+ "tenantId" => $tenant_id,
"profileName" => "CCR1",
"type" => "HTTP",
"multiSiteOrigin" => "0",
@@ -112,6 +122,7 @@ ok $t->post_ok('/api/1.2/deliveryservices/create' => {Accept => 'application/jso
->json_is( "/response/displayName" => "ds_displayname_1")
->json_is( "/response/orgServerFqdn" => "http://10.75.168.91")
->json_is( "/response/cdnName" => "cdn1")
+ ->json_is( "/response/tenantId" => $tenant_id)
->json_is( "/response/profileName" => "CCR1")
->json_is( "/response/protocol" => "1")
->json_is( "/response/type" => "HTTP")
@@ -154,6 +165,7 @@ ok $t->post_ok('/api/1.2/deliveryservices/create' => {Accept => 'application/jso
->json_is( "/response/displayName" => "ds_displayname_2")
->json_is( "/response/orgServerFqdn" => "http://10.75.168.91")
->json_is( "/response/cdnName" => "cdn1")
+ ->json_is( "/response/tenantId" => $tenant_id)#tenant id is derived from the current tenant
->json_is( "/response/profileName" => "CCR1")
->json_is( "/response/protocol" => "1")
->json_is( "/response/type" => "HTTP")
@@ -176,6 +188,7 @@ ok $t->post_ok('/api/1.2/deliveryservices/create' => {Accept => 'application/jso
"orgServerFqdn" => "http://10.75.168.91",
"cdnName" => "cdn2",
"profileName" => "CCR2",
+ "tenantId" => $tenant_id,
"type" => "HTTP",
"multiSiteOrigin" => "0",
"regionalGeoBlocking" => "1",
@@ -198,6 +211,7 @@ ok $t->post_ok('/api/1.2/deliveryservices/create' => {Accept => 'application/jso
->json_is( "/response/orgServerFqdn" => "http://10.75.168.91")
->json_is( "/response/cdnName" => "cdn2")
->json_is( "/response/profileName" => "CCR2")
+ ->json_is( "/response/tenantId" => $tenant_id)
->json_is( "/response/protocol" => "1")
->json_is( "/response/type" => "HTTP")
->json_is( "/response/multiSiteOrigin" => "0")
@@ -219,6 +233,7 @@ ok $t->put_ok('/api/1.2/deliveryservices/' . $ds_id . '/update' => {Accept => '
"protocol" => "2",
"orgServerFqdn" => "http://10.75.168.91",
"cdnName" => "cdn1",
+ "tenantId" => $tenant_id,
"profileName" => "CCR1",
"type" => "HTTP",
"multiSiteOrigin" => "0",
@@ -236,6 +251,83 @@ ok $t->put_ok('/api/1.2/deliveryservices/' . $ds_id . '/update' => {Accept => '
->json_is( "/response/displayName" => "ds_displayname_11")
->json_is( "/response/orgServerFqdn" => "http://10.75.168.91")
->json_is( "/response/cdnName" => "cdn1")
+ ->json_is( "/response/tenantId" => $tenant_id)
+ ->json_is( "/response/profileName" => "CCR1")
+ ->json_is( "/response/protocol" => "2")
+ ->json_is( "/response/type" => "HTTP")
+ ->json_is( "/response/multiSiteOrigin" => "0")
+ ->json_is( "/response/regionalGeoBlocking" => "0")
+ ->json_is( "/response/active" => "true")
+ ->json_is( "/response/matchList/0/type" => "HOST_REGEXP")
+ ->json_is( "/response/matchList/0/setNumber" => "0")
+ ->json_is( "/response/matchList/0/pattern" => ".*\\.my_vod1\\..*")
+ , 'Does the deliveryservice details return?';
+
+
+
+#removing tenancy when no set
+ok $t->put_ok('/api/1.2/deliveryservices/' . $ds_id . '/update' => {Accept => 'application/json'} => json => {
+ "xmlId" => "ds_1",
+ "displayName" => "ds_displayname_11",
+ "protocol" => "2",
+ "orgServerFqdn" => "http://10.75.168.91",
+ "cdnName" => "cdn1",
+ "profileName" => "CCR1",
+ "type" => "HTTP",
+ "multiSiteOrigin" => "0",
+ "regionalGeoBlocking" => "0",
+ "active" => "true",
+ "matchList" => [
+ {
+ "type" => "HOST_REGEXP",
+ "setNumber" => "0",
+ "pattern" => ".*\\.my_vod1\\..*"
+ }
+ ]})
+ ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/xmlId" => "ds_1")
+ ->json_is( "/response/displayName" => "ds_displayname_11")
+ ->json_is( "/response/orgServerFqdn" => "http://10.75.168.91")
+ ->json_is( "/response/cdnName" => "cdn1")
+ ->json_is( "/response/tenantId" => undef)
+ ->json_is( "/response/profileName" => "CCR1")
+ ->json_is( "/response/protocol" => "2")
+ ->json_is( "/response/type" => "HTTP")
+ ->json_is( "/response/multiSiteOrigin" => "0")
+ ->json_is( "/response/regionalGeoBlocking" => "0")
+ ->json_is( "/response/active" => "true")
+ ->json_is( "/response/matchList/0/type" => "HOST_REGEXP")
+ ->json_is( "/response/matchList/0/setNumber" => "0")
+ ->json_is( "/response/matchList/0/pattern" => ".*\\.my_vod1\\..*")
+ , 'Does the deliveryservice details return?';
+
+
+#putting tenancy back
+ok $t->put_ok('/api/1.2/deliveryservices/' . $ds_id . '/update' => {Accept => 'application/json'} => json => {
+ "xmlId" => "ds_1",
+ "displayName" => "ds_displayname_11",
+ "protocol" => "2",
+ "orgServerFqdn" => "http://10.75.168.91",
+ "cdnName" => "cdn1",
+ "tenantId" => $tenant_id,
+ "profileName" => "CCR1",
+ "type" => "HTTP",
+ "multiSiteOrigin" => "0",
+ "regionalGeoBlocking" => "0",
+ "active" => "true",
+ "matchList" => [
+ {
+ "type" => "HOST_REGEXP",
+ "setNumber" => "0",
+ "pattern" => ".*\\.my_vod1\\..*"
+ }
+ ]})
+ ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/xmlId" => "ds_1")
+ ->json_is( "/response/displayName" => "ds_displayname_11")
+ ->json_is( "/response/orgServerFqdn" => "http://10.75.168.91")
+ ->json_is( "/response/cdnName" => "cdn1")
+ ->json_is( "/response/tenantId" => $tenant_id)
->json_is( "/response/profileName" => "CCR1")
->json_is( "/response/protocol" => "2")
->json_is( "/response/type" => "HTTP")
@@ -258,6 +350,7 @@ ok $t->put_ok('/api/1.2/deliveryservices/' . $ds_id . '/update' => {Accept => 'a
"protocol" => "1",
"orgServerFqdn" => "http://10.75.168.91",
"cdnName" => "cdn2",
+ "tenantId" => $tenant_id,
"profileName" => "CCR2",
"type" => "HTTP",
"multiSiteOrigin" => "0",
@@ -281,6 +374,7 @@ ok $t->put_ok('/api/1.2/deliveryservices/' . $ds_id . '/update' => {Accept => 'a
->json_is( "/response/displayName" => "ds_displayname_1")
->json_is( "/response/orgServerFqdn" => "http://10.75.168.91")
->json_is( "/response/cdnName" => "cdn2")
+ ->json_is( "/response/tenantId" => $tenant_id)
->json_is( "/response/profileName" => "CCR2")
->json_is( "/response/protocol" => "1")
->json_is( "/response/type" => "HTTP")
@@ -303,6 +397,7 @@ ok $t->put_ok('/api/1.2/deliveryservices/' . $ds_id . '/update' => {Accept => '
"protocol" => "1",
"orgServerFqdn" => "http://10.75.168.91",
"cdnName" => "cdn1",
+ "tenantId" => $tenant_id,
"profileName" => "CCR1",
"type" => "HTTP",
"multiSiteOrigin" => "0",
@@ -342,12 +437,21 @@ ok $t->get_ok("/api/1.2/deliveryservices.json")->status_is(200)->or( sub { diag
->json_is( "/response/0/xmlId", "ds_2" )->json_is( "/response/0/logsEnabled", 0 )->json_is( "/response/0/ipv6RoutingEnabled", 0 )
->json_is( "/response/1/xmlId", "ds_3" );
-$t->get_ok('/api/1.2/deliveryservices/list?logsEnabled=true')->status_is(200)->$count_response(2)
+$t->get_ok('/api/1.2/deliveryservices/list?logsEnabled=true')->status_is(200)->$count_response(3)
->or( sub { diag $t->tx->res->content->asset->{content}; } );
ok $t->put_ok('/api/1.2/snapshot/cdn1')->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
ok $t->get_ok('/logout')->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+}
+
+my $schema = Schema->connect_to_database;
+my $dbh = Schema->database_handle;
+my $t = Test::Mojo->new('TrafficOps');
+
+run_ut($t, $schema, Test::TestHelper::ADMIN_USER, Test::TestHelper::ADMIN_USER_PASSWORD);
+
$dbh->disconnect();
done_testing();
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/17ff770e/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
new file mode 100644
index 0000000..145177c
--- /dev/null
+++ b/traffic_ops/app/t/api/1.2/deliveryservice_crud.t
@@ -0,0 +1,296 @@
+package main;
+#
+#
+# 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.
+#
+use Mojo::Base -strict;
+use Test::More;
+use Test::Mojo;
+use Data::Dumper;
+use DBI;
+use JSON;
+use strict;
+use warnings;
+no warnings 'once';
+use warnings 'all';
+use Test::TestHelper;
+
+#no_transactions=>1 ==> keep fixtures after every execution, beware of duplicate data!
+#no_transactions=>0 ==> delete fixtures after every execution
+
+BEGIN { $ENV{MOJO_MODE} = "test" }
+
+
+sub run_ut {
+
+ my $t = shift;
+ my $schema = shift;
+ my $login_user = shift;
+ my $login_password = shift;
+
+ 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_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)
+ ->or( sub { diag $t->tx->res->content->asset->{content}; } ), 'Should login?';
+
+ # It gets existing delivery services
+ ok $t->get_ok("/api/1.2/deliveryservices")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } )
+ ->json_is( "/response/0/xmlId", "steering-ds1" )
+ ->json_is( "/response/0/logsEnabled", 0 )
+ ->json_is( "/response/0/ipv6RoutingEnabled", 1 )
+ ->json_is( "/response/1/xmlId", "steering-ds2" );
+
+ # It creates new delivery services
+ ok $t->post_ok('/api/1.2/deliveryservices' => {Accept => 'application/json'} => json => {
+ "xmlId" => "ds_1",
+ "displayName" => "ds_displayname_1",
+ "protocol" => "1",
+ "orgServerFqdn" => "http://10.75.168.91",
+ "cdnName" => "cdn1",
+ "tenantId" => $tenant_id,
+ "profileId" => 300,
+ "typeId" => "36",
+ "multiSiteOrigin" => "0",
+ "regionalGeoBlocking" => "1",
+ "active" => "false",
+ "dscp" => 0,
+ "ipv6RoutingEnabled" => "true",
+ "logsEnabled" => "true",
+ "initialDispersion" => 0,
+ "cdnId" => 100,
+ "signed" => "false",
+ "rangeRequestHandling" => 0,
+ "geoLimit" => 0,
+ "geoProvider" => 0,
+ "qstringIgnore" => 0,
+ })
+ ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/0/xmlId" => "ds_1")->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/0/displayName" => "ds_displayname_1")
+ ->json_is( "/response/0/orgServerFqdn" => "http://10.75.168.91")
+ ->json_is( "/response/0/cdnId" => 100)
+ ->json_is( "/response/0/tenantId" => $tenant_id)
+ ->json_is( "/response/0/profileId" => 300)
+ ->json_is( "/response/0/protocol" => "1")
+ ->json_is( "/response/0/typeId" => 36)
+ ->json_is( "/response/0/multiSiteOrigin" => "0")
+ ->json_is( "/response/0/regionalGeoBlocking" => "1")
+ ->json_is( "/response/0/active" => "false")
+ , 'Was the DS properly added and reported?';
+
+
+ my $ds_id = &get_ds_id('ds_1');
+
+ ok $t->get_ok("/api/1.2/deliveryservices/$ds_id")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } )
+ ->json_is( "/response/0/xmlId" => "ds_1")->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/0/displayName" => "ds_displayname_1")
+ ->json_is( "/response/0/orgServerFqdn" => "http://10.75.168.91")
+ ->json_is( "/response/0/cdnId" => 100)
+ ->json_is( "/response/0/tenantId" => $tenant_id)
+ ->json_is( "/response/0/profileId" => 300)
+ ->json_is( "/response/0/protocol" => "1")
+ ->json_is( "/response/0/typeId" => 36)
+ ->json_is( "/response/0/multiSiteOrigin" => "0")
+ ->json_is( "/response/0/regionalGeoBlocking" => "1")
+ ->json_is( "/response/0/active" => "0")
+ , 'Does the deliveryservice details return?';
+
+ # A minor change
+ ok $t->put_ok('/api/1.2/deliveryservices/'.$ds_id => {Accept => 'application/json'} => json => {
+ "xmlId" => "ds_1",
+ "displayName" => "ds_displayname_1",
+ "protocol" => "1",
+ "orgServerFqdn" => "http://10.75.168.92",
+ "cdnName" => "cdn1",
+ "tenantId" => $tenant_id,
+ "profileId" => 300,
+ "typeId" => "36",
+ "multiSiteOrigin" => "0",
+ "regionalGeoBlocking" => "1",
+ "active" => "false",
+ "dscp" => 0,
+ "ipv6RoutingEnabled" => "true",
+ "logsEnabled" => "true",
+ "initialDispersion" => 0,
+ "cdnId" => 100,
+ "signed" => "false",
+ "rangeRequestHandling" => 0,
+ "geoLimit" => 0,
+ "geoProvider" => 0,
+ "qstringIgnore" => 0,
+ })
+ ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/0/xmlId" => "ds_1")->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/0/displayName" => "ds_displayname_1")
+ ->json_is( "/response/0/orgServerFqdn" => "http://10.75.168.92")
+ ->json_is( "/response/0/cdnId" => 100)
+ ->json_is( "/response/0/tenantId" => $tenant_id)
+ ->json_is( "/response/0/profileId" => 300)
+ ->json_is( "/response/0/protocol" => "1")
+ ->json_is( "/response/0/typeId" => 36)
+ ->json_is( "/response/0/multiSiteOrigin" => "0")
+ ->json_is( "/response/0/regionalGeoBlocking" => "1")
+ ->json_is( "/response/0/active" => "false")
+ , 'A minor change';
+
+
+ # Removing tenancy by not putting it in the put
+ ok $t->put_ok('/api/1.2/deliveryservices/'.$ds_id => {Accept => 'application/json'} => json => {
+ "xmlId" => "ds_1",
+ "displayName" => "ds_displayname_1",
+ "protocol" => "1",
+ "orgServerFqdn" => "http://10.75.168.92",
+ "cdnName" => "cdn1",
+ "profileId" => 300,
+ "typeId" => "36",
+ "multiSiteOrigin" => "0",
+ "regionalGeoBlocking" => "1",
+ "active" => "false",
+ "dscp" => 0,
+ "ipv6RoutingEnabled" => "true",
+ "logsEnabled" => "true",
+ "initialDispersion" => 0,
+ "cdnId" => 100,
+ "signed" => "false",
+ "rangeRequestHandling" => 0,
+ "geoLimit" => 0,
+ "geoProvider" => 0,
+ "qstringIgnore" => 0,
+ })
+ ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/0/xmlId" => "ds_1")->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/0/displayName" => "ds_displayname_1")
+ ->json_is( "/response/0/tenantId" => undef)
+ , 'Was tenant id removed?';
+
+ # Putting tenant id back
+ ok $t->put_ok('/api/1.2/deliveryservices/'.$ds_id => {Accept => 'application/json'} => json => {
+ "xmlId" => "ds_1",
+ "displayName" => "ds_displayname_1",
+ "protocol" => "1",
+ "orgServerFqdn" => "http://10.75.168.92",
+ "cdnName" => "cdn1",
+ "tenantId" => $tenant_id,
+ "profileId" => 300,
+ "typeId" => "36",
+ "multiSiteOrigin" => "0",
+ "regionalGeoBlocking" => "1",
+ "active" => "false",
+ "dscp" => 0,
+ "ipv6RoutingEnabled" => "true",
+ "logsEnabled" => "true",
+ "initialDispersion" => 0,
+ "cdnId" => 100,
+ "signed" => "false",
+ "rangeRequestHandling" => 0,
+ "geoLimit" => 0,
+ "geoProvider" => 0,
+ "qstringIgnore" => 0,
+ })
+ ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/0/xmlId" => "ds_1")->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/0/displayName" => "ds_displayname_1")
+ ->json_is( "/response/0/tenantId" => $tenant_id)
+ , 'Was the tenant ID set again?';
+
+
+ # removing tenant id
+ ok $t->put_ok('/api/1.2/deliveryservices/'.$ds_id => {Accept => 'application/json'} => json => {
+ "xmlId" => "ds_1",
+ "displayName" => "ds_displayname_1",
+ "protocol" => "1",
+ "orgServerFqdn" => "http://10.75.168.92",
+ "cdnName" => "cdn1",
+ "tenantId" => undef,
+ "profileId" => 300,
+ "typeId" => "36",
+ "multiSiteOrigin" => "0",
+ "regionalGeoBlocking" => "1",
+ "active" => "false",
+ "dscp" => 0,
+ "ipv6RoutingEnabled" => "true",
+ "logsEnabled" => "true",
+ "initialDispersion" => 0,
+ "cdnId" => 100,
+ "signed" => "false",
+ "rangeRequestHandling" => 0,
+ "geoLimit" => 0,
+ "geoProvider" => 0,
+ "qstringIgnore" => 0,
+ })
+ ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/0/xmlId" => "ds_1")->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/0/displayName" => "ds_displayname_1")
+ ->json_is( "/response/0/tenantId" => undef)
+ , 'Was the tenant ID set again?';
+
+ ok $t->delete_ok('/api/1.2/deliveryservices/' . $ds_id)->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+ # It creates new delivery services, tenant id derived from user
+ ok $t->post_ok('/api/1.2/deliveryservices' => {Accept => 'application/json'} => json => {
+ "xmlId" => "ds_1",
+ "displayName" => "ds_displayname_1",
+ "protocol" => "1",
+ "orgServerFqdn" => "http://10.75.168.91",
+ "cdnName" => "cdn1",
+ "profileId" => 300,
+ "typeId" => "36",
+ "multiSiteOrigin" => "0",
+ "regionalGeoBlocking" => "1",
+ "active" => "false",
+ "dscp" => 0,
+ "ipv6RoutingEnabled" => "true",
+ "logsEnabled" => "true",
+ "initialDispersion" => 0,
+ "cdnId" => 100,
+ "signed" => "false",
+ "rangeRequestHandling" => 0,
+ "geoLimit" => 0,
+ "geoProvider" => 0,
+ "qstringIgnore" => 0,
+ })
+ ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/0/xmlId" => "ds_1")->or( sub { diag $t->tx->res->content->asset->{content}; } )
+ ->json_is( "/response/0/tenantId" => $tenant_id)
+ , 'Was the tenant id dervied from the creating user?';
+
+ my $ds_id = &get_ds_id('ds_1');
+ ok $t->delete_ok('/api/1.2/deliveryservices/' . $ds_id)->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+ ok $t->get_ok('/logout')->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+}
+
+my $schema = Schema->connect_to_database;
+my $dbh = Schema->database_handle;
+my $t = Test::Mojo->new('TrafficOps');
+
+run_ut($t, $schema, Test::TestHelper::ADMIN_USER, Test::TestHelper::ADMIN_USER_PASSWORD);
+
+$dbh->disconnect();
+done_testing();
+
+sub get_ds_id {
+ my $xml_id = shift;
+ my $q = "select id from deliveryservice where xml_id = \'$xml_id\'";
+ my $get_svr = $dbh->prepare($q);
+ $get_svr->execute();
+ my $p = $get_svr->fetchall_arrayref( {} );
+ $get_svr->finish();
+ my $id = $p->[0]->{id};
+ return $id;
+}
[12/14] incubator-trafficcontrol git commit: org-tenancy - comments
removal
Posted by mi...@apache.org.
org-tenancy - comments removal
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/6fbab5d4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/6fbab5d4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/6fbab5d4
Branch: refs/heads/master
Commit: 6fbab5d40dce6a3fbbb80aa2b3fb65b433bb73e3
Parents: 80d586f
Author: nir-sopher <ni...@gmail.com>
Authored: Sun Apr 2 15:10:18 2017 +0300
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600
----------------------------------------------------------------------
traffic_ops/app/lib/API/Deliveryservice.pm | 4 ++--
traffic_ops/app/lib/API/Deliveryservice2.pm | 4 ++--
traffic_ops/app/t/api/1.2/tenant.t | 1 -
3 files changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/6fbab5d4/traffic_ops/app/lib/API/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Deliveryservice.pm b/traffic_ops/app/lib/API/Deliveryservice.pm
index 0b5fa5e..8d7f1cd 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -288,7 +288,7 @@ sub update {
}
}
- #setting tenant_id to undef if tenant is not set. TODO(nirs): remove when tenancy is no longer optional in the API
+ #setting tenant_id to undef if tenant is not set.
my $tenant_id = exists($params->{tenantId}) ? $params->{tenantId} : undef;
my $values = {
@@ -460,7 +460,7 @@ sub create {
return $self->alert( "A deliveryservice with xmlId " . $xml_id . " already exists." );
}
- #setting tenant_id to the user id if tenant is not set. TODO(nirs): remove when tenancy is no longer optional in the API
+ #setting tenant_id to the user id if tenant is not set.
my $tenant_id = exists($params->{tenantId}) ? $params->{tenantId} : $self->current_user_tenant();
my $values = {
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/6fbab5d4/traffic_ops/app/lib/API/Deliveryservice2.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Deliveryservice2.pm b/traffic_ops/app/lib/API/Deliveryservice2.pm
index 8b3846e..bce272a 100644
--- a/traffic_ops/app/lib/API/Deliveryservice2.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice2.pm
@@ -451,11 +451,11 @@ sub _check_params {
if (defined($ds_id)) {
#update
- #setting tenant_id to undef if tenant is not set. TODO(nirs): remove when tenancy is no longer optional in the API
+ #setting tenant_id to undef if tenant is not set.
$transformed_params->{tenantId} = exists($params->{tenantId}) ? $params->{tenantId} : undef;
} else {
#create
- #setting tenant_id to the runing user if tenant is not set. TODO(nirs): remove when tenancy is no longer optional in the API
+ #setting tenant_id to the runing user if tenant is not set.
$transformed_params->{tenantId} = exists($params->{tenantId}) ? $params->{tenantId} : $self->current_user_tenant();
}
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/6fbab5d4/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 ece6d3e..384c407 100644
--- a/traffic_ops/app/t/api/1.2/tenant.t
+++ b/traffic_ops/app/t/api/1.2/tenant.t
@@ -152,7 +152,6 @@ ok $t->delete_ok('/api/1.2/tenants/' . $tenantE_id)->status_is(200)->or( sub { d
ok $t->delete_ok('/api/1.2/tenants/' . $tenantD_id)->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
ok $t->delete_ok('/api/1.2/tenants/' . $tenantA_id)->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
-#TODO(nirs): move to a "tenancy" UT when written
#cannot delete a tenant that have a delivery-service
ok $t->delete_ok('/api/1.2/tenants/' . 10**9)->status_is(400)
->json_is( "/alerts/0/text" => "Tenant 'root' is assign with delivery-services(s): e.g. 'test-ds1-root'. Please update/delete these delivery-services and retry." )
[04/14] incubator-trafficcontrol git commit: Add tenancy to delivery
service table
Posted by mi...@apache.org.
Add tenancy to delivery service table
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/c0412919
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/c0412919
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/c0412919
Branch: refs/heads/master
Commit: c04129197aaac163113f08f58be0e0b44ae018c3
Parents: 4e4eac8
Author: nir-sopher <ni...@gmail.com>
Authored: Mon Mar 20 19:33:28 2017 +0200
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600
----------------------------------------------------------------------
.../20170315000003_delivery_service_tenancy.sql | 30 +++++++++++++
traffic_ops/app/lib/Fixtures/Deliveryservice.pm | 13 ++++++
.../lib/Fixtures/Integration/Deliveryservice.pm | 8 ++++
.../app/lib/Schema/Result/Deliveryservice.pm | 47 +++++++++++++++++---
traffic_ops/app/lib/Schema/Result/Tenant.pm | 16 ++++++-
5 files changed, 107 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c0412919/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
new file mode 100644
index 0000000..a737d0c
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20170315000003_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/c0412919/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 28953d0..0f91ede 100644
--- a/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
@@ -25,6 +25,7 @@ my %definition_for = (
id => 100,
xml_id => 'test-ds1',
active => 1,
+ tenant_id => undef,
dscp => 40,
signed => 0,
qstring_ignore => 0,
@@ -63,6 +64,7 @@ my %definition_for = (
id => 200,
xml_id => 'test-ds2',
active => 1,
+ tenant_id => undef,
dscp => 40,
signed => 0,
qstring_ignore => 0,
@@ -101,6 +103,7 @@ my %definition_for = (
id => 300,
xml_id => 'test-ds3',
active => 1,
+ tenant_id => undef,
dscp => 40,
signed => 0,
qstring_ignore => 0,
@@ -139,6 +142,7 @@ my %definition_for = (
id => 400,
xml_id => 'test-ds4',
active => 1,
+ tenant_id => undef,
dscp => 40,
signed => 0,
qstring_ignore => 0,
@@ -177,6 +181,7 @@ my %definition_for = (
id => 500,
xml_id => 'test-ds5',
active => 1,
+ tenant_id => undef,
dscp => 40,
signed => 0,
qstring_ignore => 0,
@@ -215,6 +220,7 @@ my %definition_for = (
id => 600,
xml_id => 'test-ds6',
active => 1,
+ tenant_id => undef,
dscp => 40,
signed => 0,
qstring_ignore => 0,
@@ -253,6 +259,7 @@ my %definition_for = (
id => 700,
xml_id => 'steering-ds1',
active => 1,
+ tenant_id => undef,
dscp => 40,
signed => 0,
qstring_ignore => 0,
@@ -289,6 +296,7 @@ my %definition_for = (
id => 800,
xml_id => 'steering-ds2',
active => 1,
+ tenant_id => undef,
dscp => 40,
signed => 0,
qstring_ignore => 0,
@@ -325,6 +333,7 @@ my %definition_for = (
id => 900,
xml_id => 'steering-ds3',
active => 1,
+ tenant_id => undef,
dscp => 40,
signed => 0,
qstring_ignore => 0,
@@ -361,6 +370,7 @@ my %definition_for = (
id => 1000,
xml_id => 'steering-target-ds1',
active => 1,
+ tenant_id => undef,
dscp => 40,
signed => 0,
qstring_ignore => 0,
@@ -397,6 +407,7 @@ my %definition_for = (
id => 1100,
xml_id => 'steering-target-ds2',
active => 1,
+ tenant_id => undef,
dscp => 40,
signed => 0,
qstring_ignore => 0,
@@ -433,6 +444,7 @@ my %definition_for = (
id => 1200,
xml_id => 'steering-target-ds3',
active => 1,
+ tenant_id => undef,
dscp => 40,
signed => 0,
qstring_ignore => 0,
@@ -469,6 +481,7 @@ my %definition_for = (
id => 1300,
xml_id => 'steering-target-ds4',
active => 1,
+ tenant_id => undef,
dscp => 40,
signed => 0,
qstring_ignore => 0,
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c0412919/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
index 80f475d..c41f7c5 100644
--- a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
@@ -63,6 +63,7 @@ my %definition_for = (
global_max_tps => '0',
max_dns_answers => '0',
tr_response_headers => undef,
+ tenant_id => undef,
cdn_id => '2',
dns_bypass_ttl => undef,
initial_dispersion => '1',
@@ -99,6 +100,7 @@ my %definition_for = (
type => '10',
ipv6_routing_enabled => undef,
tr_response_headers => undef,
+ tenant_id => undef,
cdn_id => '1',
global_max_mbps => '0',
global_max_tps => '0',
@@ -167,6 +169,7 @@ my %definition_for = (
remap_text => undef,
ssl_key_version => '0',
tr_request_headers => undef,
+ tenant_id => undef,
cdn_id => '1',
global_max_tps => '0',
http_bypass_fqdn => '',
@@ -192,6 +195,7 @@ my %definition_for = (
last_updated => '2015-12-10 15:44:37',
signed => '0',
ccr_dns_ttl => '3600',
+ tenant_id => undef,
cdn_id => '1',
display_name => 'movies-c1',
protocol => '0',
@@ -268,6 +272,7 @@ my %definition_for = (
global_max_tps => '0',
http_bypass_fqdn => '',
origin_shield => undef,
+ tenant_id => undef,
cdn_id => '1',
dns_bypass_ttl => undef,
},
@@ -286,6 +291,7 @@ my %definition_for = (
mid_header_rewrite => undef,
signed => '0',
ssl_key_version => '0',
+ tenant_id => undef,
cdn_id => '2',
long_desc => 'test-ds3 long_desc',
max_dns_answers => '0',
@@ -333,6 +339,7 @@ my %definition_for = (
origin_shield => undef,
range_request_handling => '0',
remap_text => undef,
+ tenant_id => undef,
cdn_id => '2',
long_desc_2 => 'test long_desc_2',
tr_request_headers => undef,
@@ -393,6 +400,7 @@ my %definition_for = (
active => '1',
cacheurl => undef,
ccr_dns_ttl => '3600',
+ tenant_id => undef,
cdn_id => '2',
dns_bypass_ip => '',
dns_bypass_ttl => undef,
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c0412919/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
index a179d7f..9889a7e 100644
--- a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
@@ -278,11 +278,22 @@ __PACKAGE__->table("deliveryservice");
default_value: false
is_nullable: 1
+=head2 multi_site_origin_algorithm
+
+ data_type: 'smallint'
+ is_nullable: 1
+
=head2 geolimit_redirect_url
data_type: 'text'
is_nullable: 1
+=head2 tenant_id
+
+ data_type: 'bigint'
+ is_foreign_key: 1
+ is_nullable: 1
+
=cut
__PACKAGE__->add_columns(
@@ -390,8 +401,12 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 1 },
"logs_enabled",
{ data_type => "boolean", default_value => \"false", is_nullable => 1 },
+ "multi_site_origin_algorithm",
+ { data_type => "smallint", is_nullable => 1 },
"geolimit_redirect_url",
{ data_type => "text", is_nullable => 1 },
+ "tenant_id",
+ { data_type => "bigint", is_foreign_key => 1, is_nullable => 1 },
);
=head1 PRIMARY KEY
@@ -410,7 +425,7 @@ __PACKAGE__->set_primary_key("id", "type");
=head1 UNIQUE CONSTRAINTS
-=head2 C<idx_101208_ds_id_unique>
+=head2 C<idx_89502_ds_id_unique>
=over 4
@@ -420,9 +435,9 @@ __PACKAGE__->set_primary_key("id", "type");
=cut
-__PACKAGE__->add_unique_constraint("idx_101208_ds_id_unique", ["id"]);
+__PACKAGE__->add_unique_constraint("idx_89502_ds_id_unique", ["id"]);
-=head2 C<idx_101208_ds_name_unique>
+=head2 C<idx_89502_ds_name_unique>
=over 4
@@ -432,7 +447,7 @@ __PACKAGE__->add_unique_constraint("idx_101208_ds_id_unique", ["id"]);
=cut
-__PACKAGE__->add_unique_constraint("idx_101208_ds_name_unique", ["xml_id"]);
+__PACKAGE__->add_unique_constraint("idx_89502_ds_name_unique", ["xml_id"]);
=head1 RELATIONS
@@ -591,6 +606,26 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
+=head2 tenant
+
+Type: belongs_to
+
+Related object: L<Schema::Result::Tenant>
+
+=cut
+
+__PACKAGE__->belongs_to(
+ "tenant",
+ "Schema::Result::Tenant",
+ { id => "tenant_id" },
+ {
+ is_deferrable => 0,
+ join_type => "LEFT",
+ on_delete => "NO ACTION",
+ on_update => "NO ACTION",
+ },
+);
+
=head2 type
Type: belongs_to
@@ -607,8 +642,8 @@ __PACKAGE__->belongs_to(
);
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-01-02 16:07:07
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qCU9AxWN09+5k2ETT6tqSQ
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-03-20 18:24:11
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/w+omk3X6k2RKjoI6IDlFw
# You can replace this text with custom code or comments, and it will be preserved on regeneration
#
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c0412919/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 9f11084..da89550 100644
--- a/traffic_ops/app/lib/Schema/Result/Tenant.pm
+++ b/traffic_ops/app/lib/Schema/Result/Tenant.pm
@@ -113,6 +113,21 @@ __PACKAGE__->add_unique_constraint("tenant_name_key", ["name"]);
=head1 RELATIONS
+=head2 deliveryservices
+
+Type: has_many
+
+Related object: L<Schema::Result::Deliveryservice>
+
+=cut
+
+__PACKAGE__->has_many(
+ "deliveryservices",
+ "Schema::Result::Deliveryservice",
+ { "foreign.tenant_id" => "self.id" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+
=head2 parent
Type: belongs_to
@@ -167,6 +182,5 @@ __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
-
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
[14/14] incubator-trafficcontrol git commit: This closes #403
Posted by mi...@apache.org.
This closes #403
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/7d088391
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/7d088391
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/7d088391
Branch: refs/heads/master
Commit: 7d088391459a600b3b53a872135d10054c185daa
Parents: b34693e
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Mon Jul 10 14:49:38 2017 -0600
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:49:38 2017 -0600
----------------------------------------------------------------------
----------------------------------------------------------------------
[02/14] incubator-trafficcontrol git commit: Adjust
deliveryservice_user.t due to recently added DSs to the fixture
Posted by mi...@apache.org.
Adjust deliveryservice_user.t due to recently added DSs to the fixture
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/e5f054ba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/e5f054ba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/e5f054ba
Branch: refs/heads/master
Commit: e5f054ba4bb46e5ba45bf84aeb823e267184ecad
Parents: 1e361b7
Author: nir-sopher <ni...@qwilt.com>
Authored: Wed Jun 21 02:20:42 2017 +0300
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600
----------------------------------------------------------------------
traffic_ops/app/t/api/1.2/deliveryservice_user.t | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/e5f054ba/traffic_ops/app/t/api/1.2/deliveryservice_user.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/deliveryservice_user.t b/traffic_ops/app/t/api/1.2/deliveryservice_user.t
index 5419383..725cc39 100644
--- a/traffic_ops/app/t/api/1.2/deliveryservice_user.t
+++ b/traffic_ops/app/t/api/1.2/deliveryservice_user.t
@@ -54,8 +54,8 @@ my $count_response = sub {
$t->get_ok('/api/1.2/users/200/deliveryservices')->status_is(200)->$count_response(1)
->or( sub { diag $t->tx->res->content->asset->{content}; } );
-# there are currently 12 delivery services NOT assigned to user with id=200
-$t->get_ok('/api/1.2/user/200/deliveryservices/available')->status_is(200)->$count_response(12)
+# there are currently 13 delivery services NOT assigned to user with id=200
+$t->get_ok('/api/1.2/user/200/deliveryservices/available')->status_is(200)->$count_response(13)
->or( sub { diag $t->tx->res->content->asset->{content}; } );
# assign one ds to user with id=200
@@ -75,7 +75,7 @@ $t->get_ok('/api/1.2/users/200/deliveryservices')->status_is(200)->$count_respon
->or( sub { diag $t->tx->res->content->asset->{content}; } );
# there are now 11 delivery services NOT assigned to user with id=200
-$t->get_ok('/api/1.2/user/200/deliveryservices/available')->status_is(200)->$count_response(11)
+$t->get_ok('/api/1.2/user/200/deliveryservices/available')->status_is(200)->$count_response(12)
->or( sub { diag $t->tx->res->content->asset->{content}; } );
# now remove ds=300 from user=200
@@ -88,8 +88,8 @@ ok $t->delete_ok('/api/1.2/deliveryservice_user/200/200')->status_is(404)->or( s
$t->get_ok('/api/1.2/users/200/deliveryservices')->status_is(200)->$count_response(1)
->or( sub { diag $t->tx->res->content->asset->{content}; } );
-# there are now 12 delivery services NOT assigned to user with id=200
-$t->get_ok('/api/1.2/user/200/deliveryservices/available')->status_is(200)->$count_response(12)
+# there are now 13 delivery services NOT assigned to user with id=200
+$t->get_ok('/api/1.2/user/200/deliveryservices/available')->status_is(200)->$count_response(13)
->or( sub { diag $t->tx->res->content->asset->{content}; } );
ok $t->get_ok('/logout')->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );
[06/14] incubator-trafficcontrol git commit: Test fix following DS
addition
Posted by mi...@apache.org.
Test fix following DS addition
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/23806cef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/23806cef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/23806cef
Branch: refs/heads/master
Commit: 23806cefb99247c4329af83f1bb344a2fb2dc6f2
Parents: 17ff770
Author: nir-sopher <ni...@gmail.com>
Authored: Mon Mar 20 19:46:52 2017 +0200
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600
----------------------------------------------------------------------
traffic_ops/app/t/api/1.2/config_files_apache_traffic_server.t | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/23806cef/traffic_ops/app/t/api/1.2/config_files_apache_traffic_server.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/config_files_apache_traffic_server.t b/traffic_ops/app/t/api/1.2/config_files_apache_traffic_server.t
index d5cb58f..9ec9ecf 100644
--- a/traffic_ops/app/t/api/1.2/config_files_apache_traffic_server.t
+++ b/traffic_ops/app/t/api/1.2/config_files_apache_traffic_server.t
@@ -71,7 +71,7 @@ my $count_response = sub {
return $t->success( is( scalar(@$r), $count ) );
};
-$t->get_ok('/api/1.2/deliveryservices/list?logsEnabled=true')->status_is(200)->$count_response(2)
+$t->get_ok('/api/1.2/deliveryservices/list?logsEnabled=true')->status_is(200)->$count_response(3)
->or( sub { diag $t->tx->res->content->asset->{content}; } );
ok $t->put_ok('/api/1.2/snapshot/cdn1')->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
[13/14] incubator-trafficcontrol git commit: Migration file rename
Posted by mi...@apache.org.
Migration file rename
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/6d67f5f7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/6d67f5f7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/6d67f5f7
Branch: refs/heads/master
Commit: 6d67f5f771e4678f4e1d54d981d810ab550e3552
Parents: 0b0d9e5
Author: nir-sopher <ni...@gmail.com>
Authored: Thu Apr 20 13:38:08 2017 +0300
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jul 10 14:41:42 2017 -0600
----------------------------------------------------------------------
.../20170404000000_delivery_service_tenancy.sql | 30 --------------------
.../20170602000000_delivery_service_tenancy.sql | 30 ++++++++++++++++++++
2 files changed, 30 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/6d67f5f7/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
deleted file mode 100644
index a737d0c..0000000
--- a/traffic_ops/app/db/migrations/20170404000000_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/6d67f5f7/traffic_ops/app/db/migrations/20170602000000_delivery_service_tenancy.sql
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/migrations/20170602000000_delivery_service_tenancy.sql b/traffic_ops/app/db/migrations/20170602000000_delivery_service_tenancy.sql
new file mode 100644
index 0000000..a737d0c
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20170602000000_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;
+