[java-oidc-common] 32/35: Fix tests
Phil Smart
philip.smart at jisc.ac.uk
Tue Sep 20 14:19:32 UTC 2022
This is an automated email from the git hooks/post-receive script.
philsmart pushed a commit to branch dev/JCOMOIDC-41
in repository java-oidc-common.
View the commit online:
http://git.shibboleth.net/view/?p=java-oidc-common.git;a=commit;h=bdc89542b09ba6caa2064428065f3ab8d46684c2
commit bdc89542b09ba6caa2064428065f3ab8d46684c2
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Mon Sep 12 11:21:33 2022 +0100
Fix tests
---
...PProviderConfigurationFetchingStrategyTest.java | 31 ++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/oidc-common-metadata-impl/src/test/java/net/shibboleth/oidc/metadata/impl/HTTPProviderConfigurationFetchingStrategyTest.java b/oidc-common-metadata-impl/src/test/java/net/shibboleth/oidc/metadata/impl/HTTPProviderConfigurationFetchingStrategyTest.java
index 3851205..ea26629 100644
--- a/oidc-common-metadata-impl/src/test/java/net/shibboleth/oidc/metadata/impl/HTTPProviderConfigurationFetchingStrategyTest.java
+++ b/oidc-common-metadata-impl/src/test/java/net/shibboleth/oidc/metadata/impl/HTTPProviderConfigurationFetchingStrategyTest.java
@@ -34,6 +34,7 @@ import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HttpContext;
import org.mockito.Mockito;
+import org.slf4j.MDC;
import org.springframework.core.io.ClassPathResource;
import org.testng.annotations.Test;
@@ -101,6 +102,9 @@ public class HTTPProviderConfigurationFetchingStrategyTest {
final var StringEntity = new StringEntity(metadataAsString);
StringEntity.setContentType(new BasicHeader("Content-Type", "application/json"));
Mockito.when(httpResponse.getEntity()).thenReturn(StringEntity);
+
+ MDC.put(AbstractDynamicHTTPFetchingStrategy.MDC_ATTRIB_CURRENT_REQUEST_URI,
+ "https://op.example.com/.well-known/openid-configuration");
final var handledMetadata = responseHandler.handleResponse(httpResponse);
@@ -108,6 +112,33 @@ public class HTTPProviderConfigurationFetchingStrategyTest {
assertEquals(handledMetadata.getIssuer().getValue(), "https://op.example.com");
}
+ @Test
+ public void testResponseHandler_Failure_WrongIssuer() throws Exception {
+
+ final OIDCProviderMetadataResponseHandler responseHandler = new OIDCProviderMetadataResponseHandler();
+
+ final HttpResponse httpResponse = Mockito.mock(HttpResponse.class);
+ final StatusLine statusLine = Mockito.mock(StatusLine.class);
+ Mockito.when(httpResponse.getStatusLine()).thenReturn(statusLine);
+ Mockito.when(statusLine.getStatusCode()).thenReturn(200);
+
+ final var metadata =
+ new ClassPathResource("/net/shibboleth/oidc/metadata/impl/openid-configuration.json");
+ final var metadataAsString = CharStreams.toString(new InputStreamReader(
+ metadata.getInputStream(), StandardCharsets.UTF_8));
+
+ final var StringEntity = new StringEntity(metadataAsString);
+ StringEntity.setContentType(new BasicHeader("Content-Type", "application/json"));
+ Mockito.when(httpResponse.getEntity()).thenReturn(StringEntity);
+
+ MDC.put(AbstractDynamicHTTPFetchingStrategy.MDC_ATTRIB_CURRENT_REQUEST_URI,
+ "https://wrongissuer.example.com/.well-known/openid-configuration");
+
+ final var handledMetadata = responseHandler.handleResponse(httpResponse);
+
+ assertNull(handledMetadata);
+ }
+
@Test
public void testResponseHandler_304Response_NoMetadata() throws Exception {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list