You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2017/01/05 18:44:42 UTC

[1/3] incubator-trafficcontrol git commit: adds some more missing api crud tests

Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master 4c95beebd -> 2792bf2b9


adds some more missing api crud tests


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

Branch: refs/heads/master
Commit: 2792bf2b912010aeea9e68ba896a77ab73e7c07d
Parents: 46ed097
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Wed Jan 4 19:22:44 2017 -0700
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Thu Jan 5 11:13:10 2017 -0700

----------------------------------------------------------------------
 traffic_ops/app/lib/Fixtures/Asn.pm      |  4 +--
 traffic_ops/app/lib/Fixtures/Profile.pm  |  8 +++++
 traffic_ops/app/t/api/1.1/profile.t      |  4 +--
 traffic_ops/app/t/api/1.2/asn.t          | 10 +++---
 traffic_ops/app/t/api/1.2/cdn.t          |  4 +--
 traffic_ops/app/t/api/1.2/division.t     | 31 ++++++++++++++++
 traffic_ops/app/t/api/1.2/physlocation.t | 51 +++++++++++++++++++++++++++
 traffic_ops/app/t/api/1.2/profile.t      |  5 +++
 traffic_ops/app/t/api/1.2/region.t       | 43 ++++++++++++++++++++++
 9 files changed, 148 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/2792bf2b/traffic_ops/app/lib/Fixtures/Asn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Asn.pm b/traffic_ops/app/lib/Fixtures/Asn.pm
index e896bcf..f53845a 100644
--- a/traffic_ops/app/lib/Fixtures/Asn.pm
+++ b/traffic_ops/app/lib/Fixtures/Asn.pm
@@ -23,7 +23,7 @@ my %definition_for = (
 		using => {
 			id         => 1,
 			asn        => 9939,
-			cachegroup => 2,
+			cachegroup => 1,
 		},
 	},
 	test_cran_2 => {
@@ -31,7 +31,7 @@ my %definition_for = (
 		using => {
 			id         => 2,
 			asn        => 9940,
-			cachegroup => 1,
+			cachegroup => 2,
 		},
 	},
 );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/2792bf2b/traffic_ops/app/lib/Fixtures/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Profile.pm b/traffic_ops/app/lib/Fixtures/Profile.pm
index 151537e..2245f20 100644
--- a/traffic_ops/app/lib/Fixtures/Profile.pm
+++ b/traffic_ops/app/lib/Fixtures/Profile.pm
@@ -66,6 +66,14 @@ my %definition_for = (
 			description => 'rascal2 description',
 		},
 	},
+	MISC => {
+		new   => 'Profile',
+		using => {
+			id          => 8,
+			name        => 'MISC',
+			description => 'misc profile description',
+		},
+	},
 );
 
 sub get_definition {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/2792bf2b/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 fd694c1..d68581d 100644
--- a/traffic_ops/app/t/api/1.1/profile.t
+++ b/traffic_ops/app/t/api/1.1/profile.t
@@ -41,9 +41,7 @@ ok $t->post_ok( '/login', => form => { u => Test::TestHelper::PORTAL_USER, p =>
 
 $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" )
-	->json_is( "/response/2/description", "mid description" )->json_is( "/response/3/name", "RASCAL1" )
-	->json_is( "/response/3/description", "rascal description" );
+	->json_is( "/response/1/description", "edge description" )->json_is( "/response/2/name", "MID1" );
 
 $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/2792bf2b/traffic_ops/app/t/api/1.2/asn.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/asn.t b/traffic_ops/app/t/api/1.2/asn.t
index f9508e1..8659d67 100644
--- a/traffic_ops/app/t/api/1.2/asn.t
+++ b/traffic_ops/app/t/api/1.2/asn.t
@@ -40,19 +40,19 @@ 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)
   ->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
-$t->get_ok("/api/1.2/asns")->status_is(200)->json_is( "/response/0/id", "1" )->json_is( "/response/0/cachegroup", "mid-northwest-group" )
+$t->get_ok("/api/1.2/asns")->status_is(200)->json_is( "/response/0/id", 1 )->json_is( "/response/0/cachegroup", "mid-northeast-group" )
   ->json_is( "/response/0/asn", "9939" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
 $t->get_ok("/api/1.2/asns?orderby=id")->status_is(200)->json_is( "/response/0/id", "1" )
-  ->json_is( "/response/0/cachegroup", "mid-northwest-group" )->json_is( "/response/0/asn", "9939" )
+  ->json_is( "/response/0/cachegroup", "mid-northeast-group" )->json_is( "/response/0/asn", "9939" )
   ->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
-$t->get_ok("/api/1.2/asns?orderby=cachegroup")->status_is(200)->json_is( "/response/0/id", "2" )
-  ->json_is( "/response/0/cachegroup", "mid-northeast-group" )->json_is( "/response/0/asn", "9940" )
+$t->get_ok("/api/1.2/asns?orderby=cachegroup")->status_is(200)->json_is( "/response/0/id", "1" )
+  ->json_is( "/response/0/cachegroup", "mid-northeast-group" )->json_is( "/response/0/asn", "9939" )
   ->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
 $t->get_ok("/api/1.2/asns/2")->status_is(200)->json_is( "/response/0/id", "2" )
-  ->json_is( "/response/0/cachegroup", "mid-northeast-group" )->json_is( "/response/0/asn", "9940" )
+  ->json_is( "/response/0/cachegroup", "mid-northwest-group" )->json_is( "/response/0/asn", "9940" )
   ->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
 ok $t->post_ok('/api/1.2/asns' => {Accept => 'application/json'} => json => {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/2792bf2b/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 b6045c6..cc6bab5 100644
--- a/traffic_ops/app/t/api/1.2/cdn.t
+++ b/traffic_ops/app/t/api/1.2/cdn.t
@@ -38,10 +38,10 @@ 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)
 	->or( sub { diag $t->tx->res->content->asset->{content}; } ), 'Should login?';
 
-$t->get_ok("/api/1.2/cdns")->status_is(200)->json_is( "/response/0/id", "1" )
+$t->get_ok("/api/1.2/cdns")->status_is(200)->json_is( "/response/0/id", 1 )
     ->json_is( "/response/0/name", "cdn1" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
-$t->get_ok("/api/1.2/cdns/1")->status_is(200)->json_is( "/response/0/id", "1" )
+$t->get_ok("/api/1.2/cdns/1")->status_is(200)->json_is( "/response/0/id", 1 )
     ->json_is( "/response/0/name", "cdn1" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
 ok $t->post_ok('/api/1.2/cdns' => {Accept => 'application/json'} => json => {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/2792bf2b/traffic_ops/app/t/api/1.2/division.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/division.t b/traffic_ops/app/t/api/1.2/division.t
index 0923e78..6139b32 100644
--- a/traffic_ops/app/t/api/1.2/division.t
+++ b/traffic_ops/app/t/api/1.2/division.t
@@ -38,13 +38,44 @@ 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)
 	->or( sub { diag $t->tx->res->content->asset->{content}; } ), 'Should login?';
 
+$t->get_ok("/api/1.2/divisions")->status_is(200)->json_is( "/response/0/id", 1 )
+	->json_is( "/response/0/name", "mountain" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+$t->get_ok("/api/1.2/divisions/1")->status_is(200)->json_is( "/response/0/id", 1 )
+	->json_is( "/response/0/name", "mountain" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
 ok $t->post_ok('/api/1.2/divisions' => {Accept => 'application/json'} => json => {
         "name" => "divion1" })->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
 	->json_is( "/response/name" => "divion1" )
             , 'Does the divion details return?';
+
 ok $t->post_ok('/api/1.2/divisions' => {Accept => 'application/json'} => json => {
         "name" => "divion1" })->status_is(400);
 
+my $division_id = &get_division_id('divion1');
+
+ok $t->put_ok('/api/1.2/divisions/' . $division_id  => {Accept => 'application/json'} => json => {
+			"name" => "division2"
+		})
+		->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+		->json_is( "/response/name" => "division2" )
+		->json_is( "/alerts/0/level" => "success" )
+	, 'Does the division2 details return?';
+
+ok $t->delete_ok('/api/1.2/divisions/' . $division_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}; } );
 $dbh->disconnect();
 done_testing();
+
+sub get_division_id {
+	my $name = shift;
+	my $q    = "select id from division where name = \'$name\'";
+	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;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/2792bf2b/traffic_ops/app/t/api/1.2/physlocation.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/physlocation.t b/traffic_ops/app/t/api/1.2/physlocation.t
index 50d4c43..02e300a 100644
--- a/traffic_ops/app/t/api/1.2/physlocation.t
+++ b/traffic_ops/app/t/api/1.2/physlocation.t
@@ -49,6 +49,57 @@ ok $t->post_ok('/api/1.2/regions/non_region/phys_locations' => {Accept => 'appli
         "name" => "physical location1",
         "shortName" => "mountain"})->status_is(400);
 
+$t->get_ok("/api/1.2/phys_locations")->status_is(200)->json_is( "/response/0/id", 2 )
+	->json_is( "/response/0/name", "Boulder" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+$t->get_ok("/api/1.2/phys_locations/1")->status_is(200)->json_is( "/response/0/id", 1 )
+	->json_is( "/response/0/name", "Denver" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+ok $t->post_ok('/api/1.2/phys_locations' => {Accept => 'application/json'} => json => {
+			"name" => "phys1",
+			"shortName" => "phys1",
+			"address" => "address",
+			"city" => "city",
+			"state" => "state",
+			"zip" => "zip",
+			"regionId" => 1,
+		})
+		->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+		->json_is( "/response/name" => "phys1" )
+		->json_is( "/alerts/0/level" => "success" )
+		->json_is( "/alerts/0/text" => "Phys location creation was successful." )
+	, 'Does the phys location details return?';
+
+my $phys_loc_id = &get_phys_location_id('phys1');
+
+ok $t->put_ok('/api/1.2/phys_locations/' . $phys_loc_id  => {Accept => 'application/json'} => json => {
+			"name" => "phys2",
+			"shortName" => "phys2",
+			"address" => "address",
+			"city" => "city",
+			"state" => "state",
+			"zip" => "zip",
+			"regionId" => 1,
+		})
+		->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+		->json_is( "/response/name" => "phys2" )
+		->json_is( "/alerts/0/level" => "success" )
+	, 'Does the phys location details return?';
+
+ok $t->delete_ok('/api/1.2/phys_locations/' . $phys_loc_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}; } );
 $dbh->disconnect();
 done_testing();
+
+sub get_phys_location_id {
+	my $name = shift;
+	my $q    = "select id from phys_location where name = \'$name\'";
+	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;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/2792bf2b/traffic_ops/app/t/api/1.2/profile.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/profile.t b/traffic_ops/app/t/api/1.2/profile.t
index ce962d8..68dffb8 100644
--- a/traffic_ops/app/t/api/1.2/profile.t
+++ b/traffic_ops/app/t/api/1.2/profile.t
@@ -113,6 +113,11 @@ ok $t->get_ok('/api/1.2/profiles?param=9' => {Accept => 'application/json'})->st
 	->json_is( "/response/1/description" => "mid description" )
 		, 'Does the profile details return?';
 
+$t->get_ok("/api/1.2/profiles/8")->status_is(200)->json_is( "/response/0/id", 8 )
+	->json_is( "/response/0/name", "MISC" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+ok $t->delete_ok('/api/1.2/profiles/8')->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
 ok $t->get_ok('/api/1.2/profiles/parameter/1' => {Accept => 'application/json'})->status_is(404);
 
 ok $t->get_ok('/logout')->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/2792bf2b/traffic_ops/app/t/api/1.2/region.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/region.t b/traffic_ops/app/t/api/1.2/region.t
index 213168e..f862197 100644
--- a/traffic_ops/app/t/api/1.2/region.t
+++ b/traffic_ops/app/t/api/1.2/region.t
@@ -46,6 +46,49 @@ ok $t->post_ok('/api/1.2/divisions/mountain/regions' => {Accept => 'application/
 ok $t->post_ok('/api/1.2/divisions/mountain/regions' => {Accept => 'application/json'} => json => {
         "name" => "region1"})->status_is(400);
 
+$t->get_ok("/api/1.2/regions")->status_is(200)->json_is( "/response/0/id", 2 )
+	->json_is( "/response/0/name", "Boulder Region" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+$t->get_ok("/api/1.2/regions/1")->status_is(200)->json_is( "/response/0/id", 1 )
+	->json_is( "/response/0/name", "Denver Region" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+ok $t->post_ok('/api/1.2/regions' => {Accept => 'application/json'} => json => {
+			"name" => "reg1",
+			"division" => 1
+		})
+		->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+		->json_is( "/response/name" => "reg1" )
+		->json_is( "/response/division" => 1 )
+		->json_is( "/alerts/0/level" => "success" )
+		->json_is( "/alerts/0/text" => "Region create was successful." )
+	, 'Do the region details return?';
+
+my $region_id = &get_reg_id('reg1');
+
+ok $t->put_ok('/api/1.2/regions/' . $region_id  => {Accept => 'application/json'} => json => {
+			"name" => "reg2",
+			"division" => 1
+		})
+		->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+		->json_is( "/response/name" => "reg2" )
+		->json_is( "/response/division" => 1 )
+		->json_is( "/alerts/0/level" => "success" )
+	, 'Do the regions details return?';
+
+ok $t->delete_ok('/api/1.2/regions/' . $region_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}; } );
 $dbh->disconnect();
 done_testing();
+
+sub get_reg_id {
+	my $name = shift;
+	my $q    = "select id from region where name = \'$name\'";
+	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;
+}
+


[2/3] incubator-trafficcontrol git commit: adds missing crud tests for cdn api

Posted by da...@apache.org.
adds missing crud tests for cdn 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/46ed0978
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/46ed0978
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/46ed0978

Branch: refs/heads/master
Commit: 46ed09784e8b597c0276b4c5e1953c8c96e0b6dc
Parents: da27b27
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Wed Jan 4 14:52:08 2017 -0700
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Thu Jan 5 11:13:10 2017 -0700

----------------------------------------------------------------------
 traffic_ops/app/t/api/1.2/cdn.t | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/46ed0978/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 a357f03..b6045c6 100644
--- a/traffic_ops/app/t/api/1.2/cdn.t
+++ b/traffic_ops/app/t/api/1.2/cdn.t
@@ -38,6 +38,12 @@ 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)
 	->or( sub { diag $t->tx->res->content->asset->{content}; } ), 'Should login?';
 
+$t->get_ok("/api/1.2/cdns")->status_is(200)->json_is( "/response/0/id", "1" )
+    ->json_is( "/response/0/name", "cdn1" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+$t->get_ok("/api/1.2/cdns/1")->status_is(200)->json_is( "/response/0/id", "1" )
+    ->json_is( "/response/0/name", "cdn1" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
 ok $t->post_ok('/api/1.2/cdns' => {Accept => 'application/json'} => json => {
         "name" => "cdn_test"
         })


[3/3] incubator-trafficcontrol git commit: adds crud tests for asn api

Posted by da...@apache.org.
adds crud tests for asn 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/da27b27c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/da27b27c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/da27b27c

Branch: refs/heads/master
Commit: da27b27c2f4989e1e2ff20dc538f52020b73866e
Parents: 4c95bee
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Wed Jan 4 14:34:59 2017 -0700
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Thu Jan 5 11:13:10 2017 -0700

----------------------------------------------------------------------
 traffic_ops/app/lib/Fixtures/Asn.pm |  8 +++++
 traffic_ops/app/t/api/1.2/asn.t     | 51 ++++++++++++++++++++++++++++----
 2 files changed, 54 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/da27b27c/traffic_ops/app/lib/Fixtures/Asn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Asn.pm b/traffic_ops/app/lib/Fixtures/Asn.pm
index d0d05f3..e896bcf 100644
--- a/traffic_ops/app/lib/Fixtures/Asn.pm
+++ b/traffic_ops/app/lib/Fixtures/Asn.pm
@@ -23,6 +23,14 @@ my %definition_for = (
 		using => {
 			id         => 1,
 			asn        => 9939,
+			cachegroup => 2,
+		},
+	},
+	test_cran_2 => {
+		new   => 'Asn',
+		using => {
+			id         => 2,
+			asn        => 9940,
 			cachegroup => 1,
 		},
 	},

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/da27b27c/traffic_ops/app/t/api/1.2/asn.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/asn.t b/traffic_ops/app/t/api/1.2/asn.t
index 2232a3a..f9508e1 100644
--- a/traffic_ops/app/t/api/1.2/asn.t
+++ b/traffic_ops/app/t/api/1.2/asn.t
@@ -40,18 +40,59 @@ 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)
   ->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
-$t->get_ok("/api/1.2/asns.json")->status_is(200)->json_is( "/response/0/id", "1" )->json_is( "/response/0/cachegroup", "mid-northeast-group" )
+$t->get_ok("/api/1.2/asns")->status_is(200)->json_is( "/response/0/id", "1" )->json_is( "/response/0/cachegroup", "mid-northwest-group" )
   ->json_is( "/response/0/asn", "9939" )->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
-$t->get_ok("/api/1.2/asns.json?orderby=id")->status_is(200)->json_is( "/response/0/id", "1" )
-  ->json_is( "/response/0/cachegroup", "mid-northeast-group" )->json_is( "/response/0/asn", "9939" )
+$t->get_ok("/api/1.2/asns?orderby=id")->status_is(200)->json_is( "/response/0/id", "1" )
+  ->json_is( "/response/0/cachegroup", "mid-northwest-group" )->json_is( "/response/0/asn", "9939" )
   ->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
-$t->get_ok("/api/1.2/asns.json?orderby=cachegroup")->status_is(200)->json_is( "/response/0/id", "1" )
-  ->json_is( "/response/0/cachegroup", "mid-northeast-group" )->json_is( "/response/0/asn", "9939" )
+$t->get_ok("/api/1.2/asns?orderby=cachegroup")->status_is(200)->json_is( "/response/0/id", "2" )
+  ->json_is( "/response/0/cachegroup", "mid-northeast-group" )->json_is( "/response/0/asn", "9940" )
   ->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
+$t->get_ok("/api/1.2/asns/2")->status_is(200)->json_is( "/response/0/id", "2" )
+  ->json_is( "/response/0/cachegroup", "mid-northeast-group" )->json_is( "/response/0/asn", "9940" )
+  ->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+ok $t->post_ok('/api/1.2/asns' => {Accept => 'application/json'} => json => {
+            "asn" => 852,
+            "cachegroupId" => 1
+        })
+        ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+        ->json_is( "/response/asn" => 852 )
+        ->json_is( "/response/cachegroupId" => 1 )
+        ->json_is( "/response/cachegroup" => "mid-northeast-group" )
+        ->json_is( "/alerts/0/level" => "success" )
+        ->json_is( "/alerts/0/text" => "ASN create was successful." )
+    , 'Does the asn details return?';
+
+my $asn_id = &get_asn_id(852);
+
+ok $t->put_ok('/api/1.2/asns/' . $asn_id  => {Accept => 'application/json'} => json => {
+            "asn" => 853,
+            "cachegroupId" => 1
+        })
+        ->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } )
+        ->json_is( "/response/asn" => 853 )
+        ->json_is( "/alerts/0/level" => "success" )
+    , 'Does the asn details return?';
+
+ok $t->delete_ok('/api/1.2/asns/' . $asn_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}; } );
 
 $dbh->disconnect();
 done_testing();
+
+sub get_asn_id {
+    my $asn = shift;
+    my $q    = "select id from asn where asn = \'$asn\'";
+    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;
+}
+