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/03/09 19:09:35 UTC

[27/44] incubator-trafficcontrol git commit: Merge 2 - profile test

Merge 2 - profile test


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/d095923e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/d095923e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/d095923e

Branch: refs/heads/master
Commit: d095923ee94a1e33e8dbb0cced14f6f267523bdd
Parents: 742d475
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Thu Dec 29 11:00:53 2016 -0700
Committer: Jan van Doorn <jv...@apache.org>
Committed: Fri Feb 17 17:49:10 2017 +0000

----------------------------------------------------------------------
 traffic_ops/app/lib/API/Cdn.pm                  | 21 +++++++++++++++++---
 .../app/lib/API/DeliveryService/SslKeys.pm      |  2 +-
 .../app/t/api/1.1/deliveryservice/ssl_keys.t    |  2 +-
 traffic_ops/app/t/api/1.1/profile.t             |  9 ++++++---
 traffic_ops/app/t/api/1.2/cdn.t                 |  2 +-
 5 files changed, 27 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d095923e/traffic_ops/app/lib/API/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Cdn.pm b/traffic_ops/app/lib/API/Cdn.pm
index 269dec9..cec6a24 100644
--- a/traffic_ops/app/lib/API/Cdn.pm
+++ b/traffic_ops/app/lib/API/Cdn.pm
@@ -39,7 +39,8 @@ sub index {
 				"id"            => $row->id,
 				"dnssecEnabled" => \$row->dnssec_enabled,
 				"lastUpdated" 	=> $row->last_updated,
-				"name"          => $row->name
+				"name"          => $row->name,
+				"domainName"    => $row->domain_name
 			}
 		);
 	}
@@ -58,7 +59,8 @@ sub show {
 				"id"            => $row->id,
 				"dnssecEnabled" => \$row->dnssec_enabled,
 				"lastUpdated" 	=> $row->last_updated,
-				"name"          => $row->name
+				"name"          => $row->name,
+				"domainName"    => $row->domain_name
 			}
 		);
 	}
@@ -77,7 +79,8 @@ sub name {
 				"id"            => $row->id,
 				"dnssecEnabled" => \$row->dnssec_enabled,
 				"lastUpdated"   => $row->last_updated,
-				"name"          => $row->name
+				"name"          => $row->name,
+				"domainName"    => $row->domain_name
 			}
 		);
 	}
@@ -104,15 +107,26 @@ sub create {
 		return $self->alert("dnssecEnabled is required.");
 	}
 
+	if ( !defined( $params->{domainName} ) ) {
+		return $self->alert("Domain Name is required.");
+	}
+
 	my $existing = $self->db->resultset('Cdn')->search( { name => $params->{name} } )->single();
 	if ($existing) {
 		$self->app->log->error( "a cdn with name '" . $params->{name} . "' already exists." );
 		return $self->alert( "a cdn with name " . $params->{name} . " already exists." );
 	}
 
+	my $existing = $self->db->resultset('Cdn')->search( { domain_name => $params->{domainName} } )->single();
+	if ($existing) {
+		$self->app->log->error( "a cdn with domain name '" . $params->{domainName} . "' already exists." );
+		return $self->alert( "a cdn with domain " . $params->{domainName} . " already exists." );
+	}
+
 	my $values = {
 		name => $params->{name},
 		dnssec_enabled => $params->{dnssecEnabled},
+		domain_name => $params->{domainName},
 	};
 
 	my $insert = $self->db->resultset('Cdn')->create($values);
@@ -123,6 +137,7 @@ sub create {
 		my $response;
 		$response->{id}            = $rs->id;
 		$response->{name}          = $rs->name;
+		$response->{domainName}    = $rs->domain_name;
 		$response->{dnssecEnabled} = \$rs->dnssec_enabled;
 		&log( $self, "Created CDN with id: " . $rs->id . " and name: " . $rs->name, "APICHANGE" );
 		return $self->success( $response, "cdn was created." );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d095923e/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm b/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
index 49d19fc..985b171 100644
--- a/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
+++ b/traffic_ops/app/lib/API/DeliveryService/SslKeys.pm
@@ -159,7 +159,7 @@ sub view_by_hostname {
 			->search( { 'regex.pattern' => "$host_regex" }, { join => { deliveryservice_regexes => { regex => undef } } } )->get_column('id')->all();
 
 		# TODO JvD - test this with online riak servers!
-		my $cdn_id = $self->db->resultset('Cdn')->search( { domain_name => $domain_name } )->get_column('id');
+		my $cdn_id = $self->db->resultset('Cdn')->search( { domain_name => $domain_name } )->get_column('id')->single();
 		my@domain_profiles = $self->db->resultset('Profile')->search( { cdn => $cdn_id } )->get_column('id')->all();
 
 		my $rs_ds = $self->db->resultset('Deliveryservice')->search( { 'profile' => { -in => \@domain_profiles } }, {} );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d095923e/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t b/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t
index 2108cd1..e76f7a0 100644
--- a/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t
+++ b/traffic_ops/app/t/api/1.1/deliveryservice/ssl_keys.t
@@ -146,7 +146,7 @@ ok $t->get_ok("/api/1.1/deliveryservices/xmlId/foo.bar/sslkeys.json")->json_has(
 	->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
 #get key by hostname
-my $gen_hostname = "edge.foo.top.kabletown.net";
+my $gen_hostname = "edge.foo.cdn1.kabletown.net";
 ok $t->get_ok("/api/1.1/deliveryservices/hostname/$gen_hostname/sslkeys.json")->json_has("/response")->json_has("/response/certificate/csr")
 	->json_has("/response/certificate/key")->json_has("/response/certificate/crt")->json_is( "/response/organization" => $org )
 	->json_is( "/response/state" => $state )->json_is( "/response/city" => $city )->json_is( "/response/businessUnit" => $unit )

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d095923e/traffic_ops/app/t/api/1.1/profile.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.1/profile.t b/traffic_ops/app/t/api/1.1/profile.t
index d68581d..192f011 100644
--- a/traffic_ops/app/t/api/1.1/profile.t
+++ b/traffic_ops/app/t/api/1.1/profile.t
@@ -39,9 +39,12 @@ Test::TestHelper->load_core_data($schema);
 ok $t->post_ok( '/login', => form => { u => Test::TestHelper::PORTAL_USER, p => Test::TestHelper::PORTAL_USER_PASSWORD } )->status_is(302)
 	->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
-$t->get_ok("/api/1.1/profiles.json")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )->json_is( "/response/0/name", "CCR1" )
-	->json_is( "/response/0/description", "ccr description" )->json_is( "/response/1/name", "EDGE1" )
-	->json_is( "/response/1/description", "edge description" )->json_is( "/response/2/name", "MID1" );
+$t->get_ok("/api/1.1/profiles.json")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+	->json_is( "/response/0/name", "CCR1" )->json_is( "/response/0/description", "ccr description" )
+	->json_is( "/response/1/name", "CCR2" )->json_is( "/response/1/description", "ccr description" )
+	->json_is( "/response/2/name", "EDGE1" )->json_is( "/response/2/description", "edge description" )
+	->json_is( "/response/3/name", "MID1" )->json_is( "/response/3/description", "mid description" )
+	->json_is( "/response/4/name", "RASCAL1" )->json_is( "/response/4/description", "rascal description" );
 
 $t->get_ok("/api/1.1/profiles/trimmed.json")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d095923e/traffic_ops/app/t/api/1.2/cdn.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/cdn.t b/traffic_ops/app/t/api/1.2/cdn.t
index f962719..b833312 100644
--- a/traffic_ops/app/t/api/1.2/cdn.t
+++ b/traffic_ops/app/t/api/1.2/cdn.t
@@ -69,7 +69,7 @@ $t->get_ok("/api/1.2/servers?cdnId=100")->status_is(200)
     ->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
 ok $t->post_ok('/api/1.2/cdns' => {Accept => 'application/json'} => json => {
-        "name" => "cdn_test", "dnssecEnabled" => "true" })
+        "name" => "cdn_test", "dnssecEnabled" => "true", "domainName" => "testcdn.kabletown.net" })
     ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
     ->json_is( "/response/name" => "cdn_test" )
     ->json_is( "/alerts/0/level" => "success" )