@Test
    void verifyUsernamePasswordCredentialsBadPasswordAndCancelled() throws Throwable {
        val context = MockRequestContext.create(applicationContext);
        var credential = new UsernamePasswordCredential();
        credential.setUsername("cassurrogate+casuser");
        credential.assignPassword("badpassword");
        WebUtils.putCredential(context, credential);
        assertNull(initialAuthenticationAction.execute(context));
        val credential1 = WebUtils.getCredential(context);
        assertEquals("casuser", credential1.getId());
        assertEquals("cassurrogate", credential.getCredentialMetadata()
            .getTrait(SurrogateCredentialTrait.class).get().getSurrogateUsername());

        val sc = WebUtils.getCredential(context, UsernamePasswordCredential.class);
        sc.setUsername("casuser");
        sc.assignPassword("Mellon");
        WebUtils.putCredential(context, sc);
        assertNull(initialAuthenticationAction.execute(context));
        val credential2 = WebUtils.getCredential(context);
        assertEquals("casuser", credential2.getId());
        assertTrue(credential.getCredentialMetadata().getTrait(SurrogateCredentialTrait.class).isEmpty());
    }
This is {@link SurrogateInitialAuthenticationActionTests}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-surrogate-webflow/src/test/java/org/apereo/cas/web/flow/action/SurrogateInitialAuthenticationActionTests.java