1616
1717package e2e ;
1818
19+ import com .webauthn4j .springframework .security .authenticator .WebAuthnAuthenticatorService ;
1920import com .webauthn4j .springframework .security .webauthn .sample .SampleSPA ;
2021import e2e .page .AuthenticatorLoginComponent ;
2122import e2e .page .PasswordLoginComponent ;
3435import org .openqa .selenium .support .ui .WebDriverWait ;
3536import org .openqa .selenium .virtualauthenticator .HasVirtualAuthenticator ;
3637import org .openqa .selenium .virtualauthenticator .VirtualAuthenticatorOptions ;
38+ import org .springframework .beans .factory .annotation .Autowired ;
3739import org .springframework .boot .test .context .SpringBootTest ;
3840import org .springframework .test .context .junit4 .SpringRunner ;
3941
4042import java .time .Duration ;
4143
44+ import static org .assertj .core .api .Assertions .assertThat ;
45+
4246@ RunWith (SpringRunner .class )
4347@ SpringBootTest (classes = SampleSPA .class , webEnvironment = SpringBootTest .WebEnvironment .DEFINED_PORT )
4448public class RegistrationAndAuthenticationE2ETest {
4549
4650 private WebDriver driver ;
4751 private WebDriverWait wait ;
4852
53+ @ Autowired
54+ private WebAuthnAuthenticatorService webAuthnAuthenticatorService ;
55+
4956 @ BeforeClass
5057 public static void setupClassTest () {
5158 WebDriverManager .chromedriver ().setup ();
@@ -86,8 +93,10 @@ public void test() {
8693 signupComponent .waitRegisterClickable ();
8794 signupComponent .clickRegister ();
8895
89- // Password authentication
9096 wait .until (ExpectedConditions .urlToBe ("http://localhost:8080/angular/login" ));
97+ long counterValueAtRegistrationPhase = webAuthnAuthenticatorService .loadAuthenticatorsByUserPrincipal ("john.doe@example.com" ).get (0 ).getCounter ();
98+
99+ // Password authentication
91100 PasswordLoginComponent passwordLoginComponent = new PasswordLoginComponent (driver );
92101 passwordLoginComponent .setUsername ("john.doe@example.com" );
93102 passwordLoginComponent .setPassword ("password" );
@@ -98,6 +107,10 @@ public void test() {
98107 // nop
99108
100109 wait .until (ExpectedConditions .urlToBe ("http://localhost:8080/angular/profile" ));
110+ long counterValueAtAuthenticationPhase = webAuthnAuthenticatorService .loadAuthenticatorsByUserPrincipal ("john.doe@example.com" ).get (0 ).getCounter ();
111+
112+ assertThat (counterValueAtAuthenticationPhase ).isGreaterThan (counterValueAtRegistrationPhase );
113+
101114 ProfileComponent profileComponent = new ProfileComponent (driver );
102115
103116 }
0 commit comments