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 2022/07/11 19:27:08 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a diff in pull request #6895: Fix user update to raise exception when the username contains spaces

ocket8888 commented on code in PR #6895:
URL: https://github.com/apache/trafficcontrol/pull/6895#discussion_r918278478


##########
traffic_ops/testing/api/v2/user_test.go:
##########
@@ -273,6 +273,30 @@ func UserSelfUpdateTest(t *testing.T) {
 	} else if *resp2[0].Email != currentEmail {
 		t.Errorf("Expected Email to still be '%s', but it was '%s'", currentEmail, *resp2[0].Email)
 	}
+
+	// Now test using an invalid username
+	currentUsername := *user.Username
+	user.Username = new("ops man")
+	updateResp, _, err = TOSession.UpdateCurrentUser(user)
+	if err == nil {
+		t.Fatal("error was expected updating user with username: 'ops man' - got none")
+	}
+
+	// Ensure it wasn't actually updated
+	resp2, _, err = TOSession.GetUserByID(*user.ID)
+	if err != nil {
+		t.Fatalf("error getting user #%d: %v", *user.ID, err)
+	}
+
+	if len(resp2) < 1 {
+		t.Fatalf("no user returned when requesting user #%d", *user.ID)
+	}
+
+	if resp2[0].Username == nil {
+		t.Errorf("Username missing or null after update")
+	} else if *resp2[0].Username != currentUsername {
+		t.Errorf("Expected Username to still be '%s', but it was '%s'", currentUsername, *resp2[0].Username)
+	}

Review Comment:
   I re-ran them and they passed.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

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