[java-idp-plugin-duo] branch dev/JDUO-71 updated: Fix tests
Phil Smart
philip.smart at jisc.ac.uk
Mon Jul 3 14:51:55 UTC 2023
This is an automated email from the git hooks/post-receive script.
philsmart pushed a commit to branch dev/JDUO-71
in repository java-idp-plugin-duo.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-duo.git;a=commit;h=ec9f9bd3a8718b208e31e21ec753b57632c10333
The following commit(s) were added to refs/heads/dev/JDUO-71 by this push:
new ec9f9bd Fix tests
ec9f9bd is described below
commit ec9f9bd3a8718b208e31e21ec753b57632c10333
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Mon Jul 3 15:51:52 2023 +0100
Fix tests
---
idp-duo-impl/pom.xml | 4 ++--
.../META-INF/net.shibboleth.idp/postconfig.xml | 8 --------
.../flows/authn/DuoOIDC/duo-oidc-authn-beans.xml | 6 +++---
.../plugin/authn/duo/impl/DuoAuthnFlowTest.java | 6 +++---
.../authn/duo/impl/DuoOIDCAuthnControllerTest.java | 10 +++++-----
.../duo-oidc-authn-config-principal-mapping.xml | 2 +-
idp-duo-nimbus-client-impl/pom.xml | 17 +++++------------
.../authn/duo/nimbus/impl/NimbusClientTest.java | 22 ++++++++++++----------
8 files changed, 31 insertions(+), 44 deletions(-)
diff --git a/idp-duo-impl/pom.xml b/idp-duo-impl/pom.xml
index b330bad..210dc5f 100644
--- a/idp-duo-impl/pom.xml
+++ b/idp-duo-impl/pom.xml
@@ -130,12 +130,12 @@
<groupId>net.shibboleth.idp</groupId>
<artifactId>idp-conf</artifactId>
<scope>test</scope>
- </dependency>
+ </dependency>-->
<dependency>
<groupId>net.shibboleth.idp</groupId>
<artifactId>idp-conf-impl</artifactId>
<scope>test</scope>
- </dependency>-->
+ </dependency>
<dependency>
<groupId>${shib-shared.groupId}</groupId>
<artifactId>shib-testing</artifactId>
diff --git a/idp-duo-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml b/idp-duo-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
index f3280dd..cbcf8cd 100644
--- a/idp-duo-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
+++ b/idp-duo-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
@@ -31,14 +31,6 @@
</property>
</bean>
- <!--
- Internal versions of the Http Request/Response proxies to ease the transition to IdP 5.0.
- Will be removed in IdP 5.0.
- -->
- <bean id="shibboleth.authn.DuoOIDC.internal.HttpServletRequest"
- class="net.shibboleth.utilities.java.support.net.ThreadLocalHttpServletRequestProxy" lazy-init="true" />
- <bean id="shibboleth.authn.DuoOIDC.internal.HttpServletResponse"
- class="net.shibboleth.utilities.java.support.net.ThreadLocalHttpServletResponseProxy" lazy-init="true" />
<!-- Controller implementation -->
<bean id="shibboleth.DuoOIDCAuthnController"
diff --git a/idp-duo-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/DuoOIDC/duo-oidc-authn-beans.xml b/idp-duo-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/DuoOIDC/duo-oidc-authn-beans.xml
index ee39e60..3d2f72d 100644
--- a/idp-duo-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/DuoOIDC/duo-oidc-authn-beans.xml
+++ b/idp-duo-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/DuoOIDC/duo-oidc-authn-beans.xml
@@ -12,7 +12,7 @@
<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer" p:placeholderPrefix="%{"
p:placeholderSuffix="}" />
- <bean class="net.shibboleth.ext.spring.config.IdentifiableBeanPostProcessor" />
+ <bean class="net.shibboleth.shared.spring.config.IdentifiableBeanPostProcessor" />
<bean class="net.shibboleth.idp.profile.impl.ProfileActionBeanPostProcessor" />
<!-- location of the Duo OIDC IdP servlet -->
@@ -75,7 +75,7 @@
-->
<bean id="ExtractDuoAuthenticationFromHeaders" scope="prototype"
class="net.shibboleth.idp.authn.duo.impl.ExtractDuoAuthenticationFromHeaders"
- p:httpServletRequest-ref="shibboleth.authn.DuoOIDC.internal.HttpServletRequest"
+ p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier"
p:autoAuthenticationSupported="%{idp.duo.oidc.nonbrowser.auto:true}"
p:clientAdddressTrusted="%{idp.duo.oidc.nonbrowser.clientAddressTrusted:true}"
p:factorHeader="%{idp.duo.oidc.nonbrowser.header.factor:X-Shibboleth-Duo-Factor}"
@@ -108,7 +108,7 @@
<!-- Duo OIDC AuthAPI beans -->
<bean id="PopulateDuoAuthenticationContext" scope="prototype"
class="net.shibboleth.idp.plugin.authn.duo.impl.PopulateDuoAuthenticationContext"
- p:httpServletRequest-ref="shibboleth.authn.DuoOIDC.internal.HttpServletRequest"
+ p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier"
p:duoIntegrationLookupStrategy-ref="shibboleth.authn.DuoOIDC.DuoIntegrationStrategy"
p:redirectURICreationStrategy-ref="shibboleth.authn.DuoOIDC.RedirectURICreationStrategy"
p:usernameLookupStrategy-ref="shibboleth.authn.DuoOIDC.UsernameLookupStrategy"
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoAuthnFlowTest.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoAuthnFlowTest.java
index 2a9cd2d..da07fb5 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoAuthnFlowTest.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoAuthnFlowTest.java
@@ -99,8 +99,8 @@ public class DuoAuthnFlowTest extends AbstractAuthnXmlFlowExecutionTests {
*/
@Nonnull @NonnullElements @Unmodifiable private final Map<String,String> flowResources =
Map.of(
- "classpath:/net/shibboleth/idp/flows/authn/authn-abstract-flow.xml","authn.abstract",
- "classpath:/conf/authn/authn-events-flow.xml","authn.events");
+ "classpath:/net/shibboleth/idp/flows/authn/authn-abstract-flow.xml","authn.abstract",
+ "classpath:/net/shibboleth/idp/module/conf/authn/authn-events-flow.xml","authn.events");
/** Constructor.*/
@@ -547,7 +547,7 @@ public class DuoAuthnFlowTest extends AbstractAuthnXmlFlowExecutionTests {
/**
* Test the Duo flow from the external authorization request. This should fail, as forced authn is
- * requested by the auth_time is from a previous authentication (to far in the past).
+ * requested but the auth_time is from a previous authentication (to far in the past).
*
* @throws DuoClientException if the client can not be created.*/
@Test
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoOIDCAuthnControllerTest.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoOIDCAuthnControllerTest.java
index d24b68a..6b85d0d 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoOIDCAuthnControllerTest.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoOIDCAuthnControllerTest.java
@@ -42,7 +42,6 @@ import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.ServletContextAttributeExporter;
-import org.springframework.web.util.NestedServletException;
import org.springframework.webflow.core.collection.LocalAttributeMap;
import org.springframework.webflow.core.collection.MutableAttributeMap;
import org.springframework.webflow.execution.FlowExecution;
@@ -53,6 +52,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import jakarta.servlet.ServletContext;
+import jakarta.servlet.ServletException;
import net.shibboleth.idp.authn.AuthenticationFlowDescriptor;
import net.shibboleth.idp.authn.ExternalAuthentication;
import net.shibboleth.idp.authn.ExternalAuthenticationException;
@@ -158,7 +158,7 @@ public class DuoOIDCAuthnControllerTest extends AbstractTestNGSpringContextTests
.param("code", CODE)
.param("state",invalidState))
.andDo(print());
- } catch (final NestedServletException e) {
+ } catch (final ServletException e) {
assertTrue(e.getCause() instanceof ExternalAuthenticationException);
log.error("{}",e.getRootCause().getMessage());
}
@@ -177,7 +177,7 @@ public class DuoOIDCAuthnControllerTest extends AbstractTestNGSpringContextTests
.param("code", CODE)
.param("state",invalidState))
.andDo(print());
- } catch (final NestedServletException e) {
+ } catch (final ServletException e) {
assertTrue(e.getCause() instanceof ExternalAuthenticationException);
log.error("{}",e.getRootCause().getMessage());
}
@@ -246,7 +246,7 @@ public class DuoOIDCAuthnControllerTest extends AbstractTestNGSpringContextTests
try {
mockMvc.perform(get("/Authn/Duo/2FA/duo-callback").param("state",
state)).andDo(print());
- } catch (final NestedServletException e) {
+ } catch (final ServletException e) {
assertTrue(e.getCause() instanceof ExternalAuthenticationException);
log.error("{}",e.getMessage());
}
@@ -265,7 +265,7 @@ public class DuoOIDCAuthnControllerTest extends AbstractTestNGSpringContextTests
param("code", CODE)).
andDo(print());
- } catch (final NestedServletException e) {
+ } catch (final ServletException e) {
assertTrue(e.getCause() instanceof ExternalAuthenticationException);
log.error("{}",e.getMessage());
}
diff --git a/idp-duo-impl/src/test/resources/conf/authn/duo-oidc-authn-config-principal-mapping.xml b/idp-duo-impl/src/test/resources/conf/authn/duo-oidc-authn-config-principal-mapping.xml
index e904ae2..a532dd7 100644
--- a/idp-duo-impl/src/test/resources/conf/authn/duo-oidc-authn-config-principal-mapping.xml
+++ b/idp-duo-impl/src/test/resources/conf/authn/duo-oidc-authn-config-principal-mapping.xml
@@ -10,7 +10,7 @@
<!-- need this bean to define the scripted function -->
<bean id="shibboleth.ContextFunctions.Scripted"
- class="net.shibboleth.idp.profile.context.navigate.ScriptedContextLookupFunction" abstract="true" />
+ class="net.shibboleth.profile.context.navigate.ScriptedContextLookupFunction" abstract="true" />
<bean id="shibboleth.authn.DuoOIDC.ContextToPrincipalMappingStrategy" parent="shibboleth.ContextFunctions.Scripted"
factory-method="inlineScript"
diff --git a/idp-duo-nimbus-client-impl/pom.xml b/idp-duo-nimbus-client-impl/pom.xml
index 6e76e75..57af438 100644
--- a/idp-duo-nimbus-client-impl/pom.xml
+++ b/idp-duo-nimbus-client-impl/pom.xml
@@ -30,16 +30,6 @@
<artifactId>jsr305</artifactId>
<scope>provided</scope>
</dependency>
- <!-- <dependency>
- <groupId>net.shibboleth.utilities</groupId>
- <artifactId>java-support</artifactId>
- <scope>provided</scope>
- </dependency>-->
- <!-- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- <scope>provided</scope>
- </dependency>-->
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
@@ -78,8 +68,11 @@
<artifactId>spring-core</artifactId>
<scope>test</scope>
</dependency>
-
-
+ <dependency>
+ <groupId>${shib-shared.groupId}</groupId>
+ <artifactId>shib-profile-api</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/idp-duo-nimbus-client-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/nimbus/impl/NimbusClientTest.java b/idp-duo-nimbus-client-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/nimbus/impl/NimbusClientTest.java
index a24707e..2abf22e 100644
--- a/idp-duo-nimbus-client-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/nimbus/impl/NimbusClientTest.java
+++ b/idp-duo-nimbus-client-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/nimbus/impl/NimbusClientTest.java
@@ -49,7 +49,9 @@ import javax.annotation.Nonnull;
import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.hc.client5.http.classic.methods.HttpUriRequest;
+import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.mockito.Mockito;
@@ -174,8 +176,8 @@ public class NimbusClientTest {
Mockito.when(httpResponse.getCode()).thenReturn(200);
Mockito.when(httpResponse.getEntity()).thenReturn(new StringEntity(ID_TOKEN_RESPONSE));
- Mockito.when(httpClient.executeOpen(null, (HttpUriRequest) Mockito.any(), (HttpContext) Mockito.any()))
- .thenReturn(httpResponse);
+ Mockito.when(httpClient.executeOpen((HttpHost) Mockito.any(), (ClassicHttpRequest) Mockito.any(),
+ (HttpContext) Mockito.any())).thenReturn(httpResponse);
// create new client with mock response
client = new NimbusClient(integ, httpClient, null, new ObjectMapper());
@@ -200,8 +202,8 @@ public class NimbusClientTest {
Mockito.when(httpResponse.getCode()).thenReturn(500);
Mockito.when(httpResponse.getEntity()).thenReturn(new StringEntity(ID_TOKEN_REPONSE_NULL));
- Mockito.when(httpClient.executeOpen(null, (HttpUriRequest) Mockito.any(), (HttpContext) Mockito.any()))
- .thenReturn(httpResponse);
+ Mockito.when(httpClient.executeOpen((HttpHost) Mockito.any(), (ClassicHttpRequest) Mockito.any(),
+ (HttpContext) Mockito.any())).thenReturn(httpResponse);
// create new client with mock response
client = new NimbusClient(integ, httpClient, null, new ObjectMapper());
@@ -222,8 +224,8 @@ public class NimbusClientTest {
Mockito.when(httpResponse.getCode()).thenReturn(500);
Mockito.when(httpResponse.getEntity()).thenReturn(new StringEntity(HEALTH_CHECK_REPONSE));
- Mockito.when(httpClient.executeOpen(null, (HttpUriRequest) Mockito.any(), (HttpContext) Mockito.any()))
- .thenReturn(httpResponse);
+ Mockito.when(httpClient.executeOpen((HttpHost) Mockito.any(), (ClassicHttpRequest) Mockito.any(),
+ (HttpContext) Mockito.any())).thenReturn(httpResponse);
// create new client with mock response
client = new NimbusClient(integ, httpClient, null, new ObjectMapper());
@@ -246,8 +248,8 @@ public class NimbusClientTest {
Mockito.when(httpResponse.getCode()).thenReturn(500);
Mockito.when(httpResponse.getEntity()).thenReturn(new StringEntity(HEALTH_CHECK_REPONSE_MORE_FIELDS));
- Mockito.when(httpClient.executeOpen(null, (HttpUriRequest) Mockito.any(), (HttpContext) Mockito.any()))
- .thenReturn(httpResponse);
+ Mockito.when(httpClient.executeOpen((HttpHost) Mockito.any(), (ClassicHttpRequest) Mockito.any(),
+ (HttpContext) Mockito.any())).thenReturn(httpResponse);
// create new client with mock response
client = new NimbusClient(integ, httpClient, null, new ObjectMapper());
@@ -270,8 +272,8 @@ public class NimbusClientTest {
Mockito.when(httpResponse.getCode()).thenReturn(500);
Mockito.when(httpResponse.getEntity()).thenReturn(new StringEntity(HEALTH_CHECK_REPONSE_ERROR));
- Mockito.when(httpClient.executeOpen(null, (HttpUriRequest) Mockito.any(), (HttpContext) Mockito.any()))
- .thenReturn(httpResponse);
+ Mockito.when(httpClient.executeOpen((HttpHost) Mockito.any(), (ClassicHttpRequest) Mockito.any(),
+ (HttpContext) Mockito.any())).thenReturn(httpResponse);
// create new client with mock response
client = new NimbusClient(integ, httpClient, null, new ObjectMapper());
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list