Enhance activation request validation and documentation
- Updated the `RequestActivationCommandValidator` to require a non-empty comment, ensuring that users provide necessary identification information. - Modified integration tests to validate the new requirement for a comment, including a test for handling empty comments. - Updated API documentation to reflect that the comment is now mandatory and clarified its purpose. - Enhanced frontend components to enforce comment requirements and provide user guidance on the comment's importance.
This commit is contained in:
@@ -56,7 +56,7 @@ public class ActivationFlowTests(PnvPanelWebApplicationFactory factory)
|
||||
|
||||
var requestResponse = await userClient.PostJsonAsync(
|
||||
"/api/activation/request",
|
||||
new { comment = (string?)null }
|
||||
new { comment = "Erin, a friend of the admin" }
|
||||
);
|
||||
var request = await requestResponse.ReadAsAsync<ActivationRequestResponse>();
|
||||
|
||||
@@ -85,14 +85,29 @@ public class ActivationFlowTests(PnvPanelWebApplicationFactory factory)
|
||||
|
||||
var first = await userClient.PostJsonAsync(
|
||||
"/api/activation/request",
|
||||
new { comment = (string?)null }
|
||||
new { comment = "Frank, a colleague of the admin" }
|
||||
);
|
||||
Assert.Equal(HttpStatusCode.OK, first.StatusCode);
|
||||
|
||||
var second = await userClient.PostJsonAsync(
|
||||
"/api/activation/request",
|
||||
new { comment = (string?)null }
|
||||
new { comment = "Frank, a colleague of the admin" }
|
||||
);
|
||||
Assert.Equal(HttpStatusCode.Conflict, second.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Request_WhenCommentEmpty_ReturnsBadRequest()
|
||||
{
|
||||
using var userClient = factory.CreateClient();
|
||||
var userName = $"gina_{Guid.NewGuid():N}"[..20];
|
||||
var (_, userToken) = await RegisterAndLoginAsync(userClient, userName, "P@ssw0rd123");
|
||||
userClient.UseBearerToken(userToken);
|
||||
|
||||
var response = await userClient.PostJsonAsync(
|
||||
"/api/activation/request",
|
||||
new { comment = (string?)null }
|
||||
);
|
||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user