[java-identity-provider] branch main updated: IDP-2025 Transitory errors on Windows V5 nightly builds
Daniel Fisher
dfisher at vt.edu
Fri Oct 28 23:49:06 UTC 2022
This is an automated email from the git hooks/post-receive script.
dfisher pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=d33fc652c81f96710be994815cac70ce39f85a5e
The following commit(s) were added to refs/heads/main by this push:
new d33fc652c IDP-2025 Transitory errors on Windows V5 nightly builds
d33fc652c is described below
commit d33fc652c81f96710be994815cac70ce39f85a5e
Author: Daniel Fisher <dfisher at vt.edu>
AuthorDate: Fri Oct 28 19:44:56 2022 -0400
IDP-2025 Transitory errors on Windows V5 nightly builds
https://shibboleth.atlassian.net/browse/IDP-2025
Add destroy lifecycle method to LDAPCredentialValidator.
Update InMemoryDirectory to *not* close existing connections on shutdown.
Update AbstractFlowTest to use a static instance of InMemoryDirectory for all tests.
---
.../idp/authn/impl/LDAPCredentialValidator.java | 12 +++++++++---
.../java/net/shibboleth/idp/test/InMemoryDirectory.java | 12 ++++++++++--
.../net/shibboleth/idp/test/flows/AbstractFlowTest.java | 17 ++++++++---------
3 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/LDAPCredentialValidator.java b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/LDAPCredentialValidator.java
index f55aee18b..4ef96c946 100644
--- a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/LDAPCredentialValidator.java
+++ b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/LDAPCredentialValidator.java
@@ -33,7 +33,6 @@ import org.ldaptive.auth.AuthenticationResponse;
import org.ldaptive.auth.AuthenticationResultCode;
import org.ldaptive.auth.Authenticator;
import org.ldaptive.auth.User;
-import org.ldaptive.handler.LdapEntryHandler;
import org.ldaptive.jaas.LdapPrincipal;
import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
@@ -127,7 +126,15 @@ public class LDAPCredentialValidator extends AbstractUsernamePasswordCredentialV
}
}
-// Checkstyle: CyclomaticComplexity OFF
+ /** {@inheritDoc} */
+ @Override
+ protected void doDestroy() {
+ if (authenticator != null) {
+ authenticator.close();
+ }
+ super.doDestroy();
+ }
+
/** {@inheritDoc} */
@Override
@Nullable protected Subject doValidate(@Nonnull final ProfileRequestContext profileRequestContext,
@@ -204,7 +211,6 @@ public class LDAPCredentialValidator extends AbstractUsernamePasswordCredentialV
}
throw authException;
}
-// Checkstyle: CyclomaticComplexity ON
/**
* Builds a new {@link Subject} populated with the necessary data.
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java b/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java
index 04d2a613f..80f2b0e55 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/InMemoryDirectory.java
@@ -27,6 +27,8 @@ import javax.annotation.Nonnull;
import com.unboundid.util.ssl.SSLUtil;
import org.ldaptive.ssl.CredentialConfigFactory;
import org.ldaptive.ssl.SSLContextInitializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;
import com.unboundid.ldap.listener.InMemoryDirectoryServer;
@@ -44,6 +46,9 @@ import net.shibboleth.shared.logic.Constraint;
*/
public class InMemoryDirectory {
+ /** Class logger. */
+ @Nonnull private final Logger log = LoggerFactory.getLogger(InMemoryDirectory.class);
+
/** Directory server. */
@Nonnull private final InMemoryDirectoryServer directoryServer;
@@ -89,12 +94,15 @@ public class InMemoryDirectory {
*/
public void start() throws LDAPException {
directoryServer.startListening();
+ log.info("In-memory directory server started");
}
/**
- * Stops the directory server.
+ * Stops the directory server without closing existing connections. Resources should be configured so that LDAP
+ * connections are closed when the spring application context shuts down.
*/
public void stop() {
- directoryServer.shutDown(true);
+ directoryServer.shutDown(false);
+ log.info("In-memory directory server stopped");
}
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java
index 218584f46..f47985caa 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java
@@ -62,8 +62,10 @@ import org.springframework.webflow.expression.spel.WebFlowSpringELExpressionPars
import org.springframework.webflow.test.MockExternalContext;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
import com.google.common.net.HttpHeaders;
import com.unboundid.ldap.sdk.LDAPException;
@@ -144,8 +146,8 @@ public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests
/** The name of the bean defining the SAML 2 Direct c14n descriptor. */
@Nonnull public final static String SAML2_TRANSFORM_C14N_BEAN_NAME = "c14n/SAML2Transform";
- /** In-memory directory server. */
- @NonnullAfterInit protected InMemoryDirectory directoryServer;
+ /** In-memory directory server. A single instance is used for all child tests. */
+ @NonnullAfterInit private static InMemoryDirectory directoryServer;
/** Mock external context. */
@Nonnull protected MockExternalContext externalContext;
@@ -220,10 +222,8 @@ public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests
/**
* Initialize XMLObject support classes.
- * @throws IOException
- * @throws LDAPException
*/
- @BeforeClass public void initializeXMLObjectSupport() throws LDAPException, IOException {
+ @BeforeClass public void initializeXMLObjectSupport() {
parserPool = XMLObjectProviderRegistrySupport.getParserPool();
builderFactory = XMLObjectProviderRegistrySupport.getBuilderFactory();
marshallerFactory = XMLObjectProviderRegistrySupport.getMarshallerFactory();
@@ -237,10 +237,9 @@ public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests
* @throws LDAPException if the in-memory directory server cannot be created
* @throws IOException if the LDIF resource cannot be imported
*/
- @BeforeMethod
- public void setupDirectoryServer() throws LDAPException, IOException {
+ @BeforeSuite public static void setupDirectoryServer() throws LDAPException, IOException {
directoryServer =
- new InMemoryDirectory(new ClassPathResource(LDIF_FILE), 10389, new ClassPathResource(KEYSTORE_FILE));
+ new InMemoryDirectory(new ClassPathResource(LDIF_FILE), 10389, new ClassPathResource(KEYSTORE_FILE));
directoryServer.start();
}
@@ -249,7 +248,7 @@ public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests
*
* Always run this method to avoid starting the server multiple times when tests fail.
*/
- @AfterMethod(alwaysRun = true) public void teardownDirectoryServer() {
+ @AfterSuite(alwaysRun = true) public static void teardownDirectoryServer() {
if (directoryServer != null) {
directoryServer.stop();
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list