slbotbm commented on code in PR #4614:
URL: https://github.com/apache/iggy/pull/4614#discussion_r4334539723


##########
foreign/cpp/tests/e2e/client.cpp:
##########
@@ -3025,3 +3025,46 @@ TEST_F(LowLevelE2E_Client, 
SendBinaryRequestUnknownCommandCodeThrows) {
     EXPECT_FALSE(error_info.has_operation_id);
     EXPECT_EQ(error_info.operation_id, 0u);
 }
+
+TEST_F(E2E_Client, CreatePersonalAccessTokenBeforeLoginThrows) {
+    RecordProperty("description", "Rejects personal access token creation 
without an active authenticated session.");
+    auto client                  = GetLoggedOutHighLevelClient();
+    const std::string token_name = GetRandomName(30);
+
+    ASSERT_THROW(client.CreatePersonalAccessToken(token_name, 
iggy::Expiry::ServerDefault()), std::exception);
+    ASSERT_NO_THROW(client.Connect());
+    ASSERT_THROW(client.CreatePersonalAccessToken(token_name, 
iggy::Expiry::ServerDefault()), std::exception);
+}

Review Comment:
   Let's add Login here and see that the token is created successfully. 



##########
foreign/cpp/tests/e2e/client.cpp:
##########


Review Comment:
   Add the following test cases:
   - 0 bytes name and >255 byte name. 
   - also initialize an http client using FromConnectionString function and 
test that it errors on name being < 3 bytes and > 30 bytes. 
   - In the happy path case of simply creating a token, create tokens using 
names in languages with different byte counts for characters.
   - There is a limit of 100 tokens for a single user. Create 101 tokens and 
test that the last calls fails. After that, create another user and see that 1 
token creation succeeds for that user.
   - An authenticated ordinary user with no permissions can create their own 
PATs.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to