@Test
public void authenticateShouldReturnOidcUserWhenIdentityProviderIsOpenIdConnect() throws AuthenticationException {

    try (final AlpineQueryManager qm = new AlpineQueryManager()) {
        qm.createManagedUser("username", "passwordHash");
        qm.createLdapUser("username");
        final OidcUser oidcUser = new OidcUser();
        oidcUser.setUsername("username");
        oidcUser.setSubjectIdentifier("subjectIdentifier");
        qm.persist(oidcUser);
    }
    final Principal principalMock = mock(Principal.class);
    when(principalMock.getName())
            .thenReturn("username");
    final String token = new JsonWebToken().createToken(principalMock, null, IdentityProvider.OPENID_CONNECT);
    final ContainerRequest containerRequestMock = mock(ContainerRequest.class);
    when(containerRequestMock.getRequestHeader(eq(HttpHeaders.AUTHORIZATION)))
            .thenReturn(Collections.singletonList("Bearer " + token));
    final JwtAuthenticationService authService = new JwtAuthenticationService(containerRequestMock);
    final UserPrincipal authenticatedUser = (UserPrincipal) authService.authenticate();
    assertThat(authenticatedUser).isNotNull();
    assertThat(authenticatedUser).isInstanceOf(OidcUser.class);
}