Source:
private void testWebAuthn(boolean passwordless) { WebAuthnAssume.assumeChrome(driver); SigningInPage.CredentialType credentialType; final String expectedHelpText; if (passwordless) { credentialType = webAuthnPwdlessCredentialType; expectedHelpText = "Use your security key for passwordless log in."; } else { credentialType = webAuthnCredentialType; expectedHelpText = "Use your security key to log in."; } assertFalse(credentialType.isSetUp()); assertEquals("Security Key", credentialType.getTitle()); assertEquals(expectedHelpText, credentialType.getHelpText()); final String label1 = "WebAuthn is convenient"; final String label2 = "but not yet widely adopted"; SigningInPage.UserCredential webAuthn1 = addWebAuthnCredential(label1, passwordless); assertTrue(credentialType.isSetUp()); assertEquals(1, credentialType.getUserCredentialsCount()); assertUserCredential(label1, true, webAuthn1); SigningInPage.UserCredential webAuthn2 = addWebAuthnCredential(label2, passwordless); assertEquals(2, credentialType.getUserCredentialsCount()); assertUserCredential(label2, true, webAuthn2); assertFalse("Not set up link is visible", credentialType.isNotSetUpLinkVisible()); assertTrue("Title is visible", credentialType.isTitleVisible()); testRemoveCredential(webAuthn1); }

Target:
private void testWebAuthn(boolean passwordless) { testContext.setTestRealmReps(emptyList()); WebAuthnAssume.assumeChrome(driver); SigningInPage.CredentialType credentialType; final String expectedHelpText; final String providerId; if (passwordless) { credentialType = webAuthnPwdlessCredentialType; expectedHelpText = "Use your security key for passwordless log in."; providerId = WebAuthnPasswordlessRegisterFactory.PROVIDER_ID; } else { credentialType = webAuthnCredentialType; expectedHelpText = "Use your security key to log in."; providerId = WebAuthnRegisterFactory.PROVIDER_ID; } assertFalse(credentialType.isSetUp()); assertTrue("Set up link for \"" + credentialType.getType() + "\" is not visible", credentialType.isSetUpLinkVisible()); assertEquals("Security Key", credentialType.getTitle()); assertEquals(expectedHelpText, credentialType.getHelpText()); final String label1 = "WebAuthn is convenient"; final String label2 = "but not yet widely adopted"; SigningInPage.UserCredential webAuthn1 = addWebAuthnCredential(label1, passwordless); assertTrue(credentialType.isSetUp()); assertEquals(1, credentialType.getUserCredentialsCount()); assertUserCredential(label1, true, webAuthn1); SigningInPage.UserCredential webAuthn2 = addWebAuthnCredential(label2, passwordless); assertEquals(2, credentialType.getUserCredentialsCount()); assertUserCredential(label2, true, webAuthn2); RequiredActionProviderRepresentation requiredAction = new RequiredActionProviderRepresentation(); requiredAction.setEnabled(false); testRealmResource().flows().updateRequiredAction(providerId, requiredAction); refreshPageAndWaitForLoad(); assertFalse("Set up link for \"" + credentialType.getType() + "\" is visible", credentialType.isSetUpLinkVisible()); assertFalse("Not set up link for \"" + credentialType.getType() + "\" is visible", credentialType.isNotSetUpLabelVisible()); assertTrue("Title for \"" + credentialType.getType() + "\" is not visible", credentialType.isTitleVisible()); assertEquals(2, credentialType.getUserCredentialsCount()); testRemoveCredential(webAuthn1); }