[java-oidc-common] branch dev/JCOMOIDC-41 updated: Fix tests

Phil Smart philip.smart at jisc.ac.uk
Mon Sep 12 10:21:38 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=86e0682149aad144ffc8baca387a99181d06112f

The following commit(s) were added to refs/heads/dev/JCOMOIDC-41 by this push:
     new 86e0682  Fix tests
86e0682 is described below

commit 86e0682149aad144ffc8baca387a99181d06112f
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