@Test
public void authenticateShouldProvisionAndReturnNewUserWhenUserDoesNotExistAndProvisioningIsEnabled() throws AlpineAuthenticationException {

    when(configMock.getPropertyAsBoolean(eq(Config.AlpineKey.OIDC_USER_PROVISIONING)))
            .thenReturn(true);
    wireMockRule.stubFor(get(urlPathEqualTo(OIDC_USERINFO_PATH))
            .willReturn(aResponse()
                    .withStatus(HttpStatus.SC_OK)
                    .withHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType())
                    .withBody("" +
                            "{" +
                            "    \"sub\": \"subject\", " +
                            "    \"email\": \"subject@mail.local\", " +
                            "    \"" + USERNAMCE_CLAIM + "\": \"username\"" +
                            "}")));
    final OidcAuthenticationService authService = new OidcAuthenticationService(configMock, oidcConfigurationMock, ACCESS_TOKEN);
    final OidcUser provisionedUser = (OidcUser) authService.authenticate();
    assertThat(provisionedUser).isNotNull();
    assertThat(provisionedUser.getUsername()).isEqualTo("username");
    assertThat(provisionedUser.getSubjectIdentifier()).isEqualTo("subject");
    assertThat(provisionedUser.getEmail()).isEqualTo("subject@mail.local");
    assertThat(provisionedUser.getTeams()).isNullOrEmpty();
    assertThat(provisionedUser.getPermissions()).isNullOrEmpty();
}