ilgrosso commented on code in PR #1413:
URL: https://github.com/apache/syncope/pull/1413#discussion_r3373419963


##########
fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java:
##########
@@ -387,6 +388,38 @@ public void checkUserSuspension() {
         assertEquals(0, 
goodPwdClient.self().user().getFailedLogins().intValue());
     }
 
+    @Test
+    public void authenticationThrottle() {
+        UserCR userCR = 
UserITCase.getUniqueSample("[email protected]");
+        userCR.getRoles().add("User manager");
+
+        UserTO userTO = createUser(userCR).getEntity();
+        assertNotNull(userTO);
+
+        for (int i = 0; i < AUTHENTICATION_THROTTLE_MAX_ATTEMPTS - 1; i++) {
+            try {
+                CLIENT_FACTORY.create(userTO.getUsername(), "wrongpwd").self();
+                fail("This should not happen");
+            } catch (NotAuthorizedException e) {
+                assertNotNull(e);
+            }
+        }
+
+        try {
+            CLIENT_FACTORY.create(userTO.getUsername(), "wrongpwd").self();
+            fail("This should not happen");
+        } catch (WebApplicationException e) {
+            assertEquals(Response.Status.TOO_MANY_REQUESTS.getStatusCode(), 
e.getResponse().getStatus());
+        }
+
+        try {
+            CLIENT_FACTORY.create(userTO.getUsername(), "password123").self();

Review Comment:
   old tests have this try / catch layout
   
   recently added tests are instead using assertThrows / assertDoesNotThrow



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