You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/05/24 09:58:39 UTC

[GitHub] [trafficcontrol] dmohan001c opened a new pull request #5879: Add TO Client API for CDN Automation

dmohan001c opened a new pull request #5879:
URL: https://github.com/apache/trafficcontrol/pull/5879


   ## What does this PR (Pull Request) do?
   
   - [x] This PR is not related to any Issue
   
   ## Which Traffic Control components are affected by this PR?
   
   - CDN in a Box
   - Traffic Control Client <!-- Please specify which; e.g. 'Python', 'Go', 'Java' -->
   - Traffic Ops
   - CI tests
   
   ## What is the best way to verify this PR?
   Execute all the Integration tests and make sure the tests passed.
   
   ## The following criteria are ALL met by this PR
   <!-- Check the boxes to signify that the associated statement is true. To
   "check a box", replace the space inside of the square brackets with an 'x'.
   e.g.
   
   - [ x] <- Wrong
   - [x ] <- Wrong
   - [] <- Wrong
   - [*] <- Wrong
   - [x] <- Correct!
   
   -->
   
   - [ ] This PR includes tests OR I have explained why tests are unnecessary
   - [ ] This PR includes documentation OR I have explained why documentation is unnecessary
   - [ ] This PR includes an update to CHANGELOG.md OR such an update is not necessary
   - [ ] This PR includes any and all required license headers
   - [ ] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://www.apache.org/security/) for details)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5879: Add TO Client API for CDN Automation

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5879:
URL: https://github.com/apache/trafficcontrol/pull/5879#discussion_r640826496



##########
File path: traffic_ops/testing/api/v4/cdns_test.go
##########
@@ -348,6 +373,46 @@ func GetTestCDNs(t *testing.T) {
 	}
 }
 
+func GetTestCDNsbyDomainName(t *testing.T) {
+	if len(testData.CDNs) < 1 {

Review comment:
       line 382 dereferences `testData.CDNs[1]`, so this needs to check that the length is at least 2 to prevent segfaulting (or it could instead use the `0` element on line 382)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5879: Add TO Client API for CDN Automation

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5879:
URL: https://github.com/apache/trafficcontrol/pull/5879#discussion_r645082763



##########
File path: traffic_ops/testing/api/v4/cdns_test.go
##########
@@ -376,3 +441,166 @@ func DeleteTestCDNs(t *testing.T) {
 		}
 	}
 }
+
+func DeleteTestCDNsInvalidId(t *testing.T) {
+
+	delResp, reqInf, err := TOSession.DeleteCDN(100000, client.RequestOptions{})
+	if err == nil {
+		t.Errorf("Expected, no cdn with that key found  but got - alerts: %+v", delResp.Alerts)
+	}
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Errorf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+}
+
+func CreateTestCDNEmptyName(t *testing.T) {
+	if len(testData.CDNs) < 1 {
+		t.Fatalf("need at least one CDN to test creating CDNs")
+	}
+
+	firstData := testData.CDNs[0]
+	firstData.Name = ""
+	resp, reqInf, err := TOSession.CreateCDN(firstData, client.RequestOptions{})
+	if err == nil {
+		t.Errorf("Expected 'name' cannot be blank  but got - alerts: %+v", resp.Alerts)
+	}
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Errorf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+}
+
+func CreateTestCDNEmptyDomainName(t *testing.T) {
+	if len(testData.CDNs) < 1 {
+		t.Fatalf("need at least one CDN to test creating CDNs")
+	}
+
+	firstData := testData.CDNs[0]
+	firstData.DomainName = ""
+	resp, reqInf, err := TOSession.CreateCDN(firstData, client.RequestOptions{})
+	if err == nil {
+		t.Errorf("Expected 'domainName' cannot be blank  but got - alerts: %+v", resp.Alerts)
+	}
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Errorf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+}

Review comment:
       I don't think these tests are comprehensive enough to test what they claim to test; CDN names and domain names must be unique, so if there was a bug in the API that let you create a CDN with a blank name or a blank domain name, it would still give you back a non-nil error and a 400 status code. Because the CDN defined by `testData.CDNs[0]` was already created prior to this test - as long as creation is working properly - a CDN with the same domain name and name will exist when you attempt to create it in the first test and the second test, respectively.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 merged pull request #5879: Add TO Client API for CDN Automation

Posted by GitBox <gi...@apache.org>.
ocket8888 merged pull request #5879:
URL: https://github.com/apache/trafficcontrol/pull/5879


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5879: Add TO Client API for CDN Automation

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5879:
URL: https://github.com/apache/trafficcontrol/pull/5879#discussion_r645082763



##########
File path: traffic_ops/testing/api/v4/cdns_test.go
##########
@@ -376,3 +441,166 @@ func DeleteTestCDNs(t *testing.T) {
 		}
 	}
 }
+
+func DeleteTestCDNsInvalidId(t *testing.T) {
+
+	delResp, reqInf, err := TOSession.DeleteCDN(100000, client.RequestOptions{})
+	if err == nil {
+		t.Errorf("Expected, no cdn with that key found  but got - alerts: %+v", delResp.Alerts)
+	}
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Errorf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+}
+
+func CreateTestCDNEmptyName(t *testing.T) {
+	if len(testData.CDNs) < 1 {
+		t.Fatalf("need at least one CDN to test creating CDNs")
+	}
+
+	firstData := testData.CDNs[0]
+	firstData.Name = ""
+	resp, reqInf, err := TOSession.CreateCDN(firstData, client.RequestOptions{})
+	if err == nil {
+		t.Errorf("Expected 'name' cannot be blank  but got - alerts: %+v", resp.Alerts)
+	}
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Errorf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+}
+
+func CreateTestCDNEmptyDomainName(t *testing.T) {
+	if len(testData.CDNs) < 1 {
+		t.Fatalf("need at least one CDN to test creating CDNs")
+	}
+
+	firstData := testData.CDNs[0]
+	firstData.DomainName = ""
+	resp, reqInf, err := TOSession.CreateCDN(firstData, client.RequestOptions{})
+	if err == nil {
+		t.Errorf("Expected 'domainName' cannot be blank  but got - alerts: %+v", resp.Alerts)
+	}
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Errorf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+}

Review comment:
       I don't think these tests are comprehensive enough to test what they claim to test; CDN names and domain names must be unique, so if there was a bug in the API that let you create a CDN with a blank name or a blank domain name, it would still give you back a non-nil error and a 400 status code. Because the CDN defined by `testData.CDNs[0]` was already created prior to this test - as long as creation is working properly - a CDN with the same domain name and name will exist when you attempt to create it in the first test and the second test, respectively.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] dmohan001c commented on a change in pull request #5879: Add TO Client API for CDN Automation

Posted by GitBox <gi...@apache.org>.
dmohan001c commented on a change in pull request #5879:
URL: https://github.com/apache/trafficcontrol/pull/5879#discussion_r641239805



##########
File path: traffic_ops/testing/api/v4/cdns_test.go
##########
@@ -348,6 +373,46 @@ func GetTestCDNs(t *testing.T) {
 	}
 }
 
+func GetTestCDNsbyDomainName(t *testing.T) {
+	if len(testData.CDNs) < 1 {

Review comment:
       updated the code to get the first value of CDN.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org