@Test
public void resolveShouldReturnConfigurationAndStoreItInCache() {

    wireMockRule.stubFor(get(urlPathEqualTo(OidcConfigurationResolver.OPENID_CONFIGURATION_PATH))
            .willReturn(aResponse()
                    .withStatus(HttpStatus.SC_OK)
                    .withHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType())
                    .withBody("" +
                            "{\n" +
                            "  \"issuer\": \"https://gitlab.com\",\n" +
                            "  \"authorization_endpoint\": \"https://gitlab.com/oauth/authorize\",\n" +
                            "  \"token_endpoint\": \"https://gitlab.com/oauth/token\",\n" +
                            "  \"userinfo_endpoint\": \"https://gitlab.com/oauth/userinfo\",\n" +
                            "  \"jwks_uri\": \"https://gitlab.com/oauth/discovery/keys\"\n" +
                            "}")));
    final OidcConfiguration oidcConfiguration = new OidcConfigurationResolver(true, wireMockRule.baseUrl()).resolve();
    assertThat(oidcConfiguration).isNotNull();
    assertThat(oidcConfiguration.getIssuer()).isEqualTo("https://gitlab.com");
    assertThat(oidcConfiguration.getAuthorizationEndpointUri()).isEqualTo("https://gitlab.com/oauth/authorize");
    assertThat(oidcConfiguration.getTokenEndpointUri()).isEqualTo("https://gitlab.com/oauth/token");
    assertThat(oidcConfiguration.getUserInfoEndpointUri()).isEqualTo("https://gitlab.com/oauth/userinfo");
    assertThat(oidcConfiguration.getJwksUri()).isEqualTo("https://gitlab.com/oauth/discovery/keys");
    // On the next invocation, the configuration should be loaded from cache
    assertThat(new OidcConfigurationResolver(true, wireMockRule.baseUrl()).resolve()).isEqualTo(oidcConfiguration);
    // Only one request should've been made
    verify(1, getRequestedFor(urlPathEqualTo(OidcConfigurationResolver.OPENID_CONFIGURATION_PATH)));
}