[java-identity-provider] branch maint-4 updated: Fix tests resulting from error message fix.

Scott Cantor cantor.2 at osu.edu
Wed Dec 7 17:46:52 UTC 2022


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch maint-4
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=f25b87cf21f11742cb59c7d41405e3dcb9087703

The following commit(s) were added to refs/heads/maint-4 by this push:
     new f25b87cf2 Fix tests resulting from error message fix.
f25b87cf2 is described below

commit f25b87cf21f11742cb59c7d41405e3dcb9087703
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Dec 7 12:46:49 2022 -0500

    Fix tests resulting from error message fix.
---
 .../shibboleth/idp/authn/impl/ValidateFunctionResult.java |  4 ++--
 .../idp/authn/impl/LDAPCredentialValidatorTest.java       | 15 ++++++++++-----
 .../idp/authn/impl/ValidateCredentialsTest.java           |  3 ++-
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateFunctionResult.java b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateFunctionResult.java
index d774a09fc..ad9a0c2d5 100644
--- a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateFunctionResult.java
+++ b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateFunctionResult.java
@@ -131,8 +131,8 @@ public class ValidateFunctionResult extends AbstractAuditingValidationAction {
             buildAuthenticationResult(profileRequestContext, authenticationContext);
         } else {
             log.info("{} Authentication by function failed, result type was invalid", getLogPrefix());
-            handleError(profileRequestContext, authenticationContext, AuthnEventIds.NO_CREDENTIALS,
-                    AuthnEventIds.NO_CREDENTIALS);
+            handleError(profileRequestContext, authenticationContext, AuthnEventIds.INVALID_CREDENTIALS,
+                    AuthnEventIds.INVALID_CREDENTIALS);
             recordFailure(profileRequestContext);
         }
     }
diff --git a/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/LDAPCredentialValidatorTest.java b/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/LDAPCredentialValidatorTest.java
index 12cf009ca..34bfa4602 100644
--- a/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/LDAPCredentialValidatorTest.java
+++ b/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/LDAPCredentialValidatorTest.java
@@ -175,7 +175,9 @@ public class LDAPCredentialValidatorTest extends BaseAuthenticationContextTest {
 
         final Event event = action.execute(src);
         Assert.assertNull(ac.getAuthenticationResult());
-        Assert.assertNull(ac.getSubcontext(AuthenticationErrorContext.class));
+        ActionTestingSupport.assertEvent(event, AuthnEventIds.NO_CREDENTIALS);
+        final AuthenticationErrorContext aec = ac.getSubcontext(AuthenticationErrorContext.class);
+        Assert.assertNotNull(aec);
         ActionTestingSupport.assertEvent(event, AuthnEventIds.NO_CREDENTIALS);
     }
 
@@ -220,7 +222,7 @@ public class LDAPCredentialValidatorTest extends BaseAuthenticationContextTest {
         Assert.assertEquals(lrc.getAuthenticationResponse().getAuthenticationResultCode(),
                 AuthenticationResultCode.DN_RESOLUTION_FAILURE);
 
-        AuthenticationErrorContext aec = ac.getSubcontext(AuthenticationErrorContext.class);
+        final AuthenticationErrorContext aec = ac.getSubcontext(AuthenticationErrorContext.class);
         Assert.assertNotNull(aec);
         ActionTestingSupport.assertEvent(event, "UnknownUsername");
         Assert.assertEquals(aec.getClassifiedErrors().size(), 1);
@@ -255,7 +257,8 @@ public class LDAPCredentialValidatorTest extends BaseAuthenticationContextTest {
         ActionTestingSupport.assertEvent(event, AuthnEventIds.AUTHN_EXCEPTION);
         System.err.println("EXCEPTIONS:: " + aec.getExceptions());
         Assert.assertEquals(aec.getExceptions().size(), 1);
-        Assert.assertEquals(aec.getClassifiedErrors().size(), 0);
+        Assert.assertEquals(aec.getClassifiedErrors().size(), 1);
+        Assert.assertTrue(aec.isClassifiedError(AuthnEventIds.AUTHN_EXCEPTION));
     }
 
     @Test public void testBadUsername() throws ComponentInitializationException {
@@ -279,7 +282,7 @@ public class LDAPCredentialValidatorTest extends BaseAuthenticationContextTest {
         Assert.assertEquals(lrc.getAuthenticationResponse().getAuthenticationResultCode(),
                 AuthenticationResultCode.DN_RESOLUTION_FAILURE);
 
-        AuthenticationErrorContext aec = ac.getSubcontext(AuthenticationErrorContext.class);
+        final AuthenticationErrorContext aec = ac.getSubcontext(AuthenticationErrorContext.class);
         Assert.assertNotNull(aec);
         ActionTestingSupport.assertEvent(event, "UnknownUsername");
         Assert.assertEquals(aec.getClassifiedErrors().size(), 1);
@@ -302,8 +305,10 @@ public class LDAPCredentialValidatorTest extends BaseAuthenticationContextTest {
 
         final Event event = action.execute(src);
         Assert.assertNull(ac.getAuthenticationResult());
-        Assert.assertNull(ac.getSubcontext(AuthenticationErrorContext.class));
         ActionTestingSupport.assertEvent(event, AuthnEventIds.INVALID_CREDENTIALS);
+        final AuthenticationErrorContext aec = ac.getSubcontext(AuthenticationErrorContext.class);
+        Assert.assertNotNull(aec);
+        Assert.assertTrue(aec.isClassifiedError(AuthnEventIds.INVALID_CREDENTIALS));
     }
 
     @Test public void testBadPassword() throws ComponentInitializationException {
diff --git a/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateCredentialsTest.java b/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateCredentialsTest.java
index e387a85fd..140ce924f 100644
--- a/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateCredentialsTest.java
+++ b/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateCredentialsTest.java
@@ -204,8 +204,9 @@ public class ValidateCredentialsTest extends BaseAuthenticationContextTest {
         AuthenticationErrorContext aec = ac.getSubcontext(AuthenticationErrorContext.class);
         Assert.assertNotNull(aec);
         ActionTestingSupport.assertEvent(event, "InvalidPassword");
-        Assert.assertEquals(aec.getClassifiedErrors().size(), 1);
+        Assert.assertEquals(aec.getClassifiedErrors().size(), 2);
         Assert.assertTrue(aec.isClassifiedError("InvalidPassword"));
+        Assert.assertTrue(aec.isClassifiedError("InvalidCredentials"));
     }
 
     @Test public void testAuthorized() throws ComponentInitializationException {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list