[java-identity-provider] branch main updated: Properly close service in tests.

Scott Cantor cantor.2 at osu.edu
Wed Mar 1 19:45:17 UTC 2023


This is an automated email from the git hooks/post-receive script.

scantor 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=2b565b6a6d9f811e081fed3a2f07094146f25ebe

The following commit(s) were added to refs/heads/main by this push:
     new 2b565b6a6 Properly close service in tests.
2b565b6a6 is described below

commit 2b565b6a6d9f811e081fed3a2f07094146f25ebe
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Mar 1 14:45:14 2023 -0500

    Properly close service in tests.
---
 .../idp/test/flows/cas/LoginFlowTest.java          | 25 ++++++++++++----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/LoginFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/LoginFlowTest.java
index f5ebb1891..79ac4eaf0 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/LoginFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/LoginFlowTest.java
@@ -63,6 +63,7 @@ import net.shibboleth.profile.relyingparty.VerifiedProfileCriterion;
 import net.shibboleth.shared.net.URISupport;
 import net.shibboleth.shared.resolver.CriteriaSet;
 import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceableComponent;
 
 /**
  * Tests the flow behind the <code>/login</code> endpoint.
@@ -280,19 +281,21 @@ public class LoginFlowTest extends AbstractFlowTest {
     private void setPostAuthenticationFlows(final List<String> flowIdentifiers) throws Exception {
         final ProfileRequestContext prc = new ProfileRequestContext();
         prc.setProfileId(LoginConfiguration.PROFILE_ID);
-        final RelyingPartyConfiguration rpConfig =
-                relyingPartyConfigurationResolver.getServiceableComponent().getComponent().resolveSingle(
-                        new CriteriaSet(new ProfileRequestContextCriterion(prc),
+        try (final ServiceableComponent<RelyingPartyConfigurationResolver> service =
+                relyingPartyConfigurationResolver.getServiceableComponent()) {
+            final RelyingPartyConfiguration rpConfig = service.getComponent().resolveSingle(
+                    new CriteriaSet(new ProfileRequestContextCriterion(prc),
                                 new VerifiedProfileCriterion(true)));
-        if (rpConfig == null) {
-            throw new IllegalStateException("Relying party configuration not found");
+            if (rpConfig == null) {
+                throw new IllegalStateException("Relying party configuration not found");
+            }
+            final LoginConfiguration loginConfiguration =
+                    (LoginConfiguration) rpConfig.getProfileConfiguration(prc, LoginConfiguration.PROFILE_ID);
+            if (loginConfiguration == null) {
+                throw new IllegalStateException("CAS login profile configuration not found");
+            }
+            loginConfiguration.setPostAuthenticationFlows(flowIdentifiers);
         }
-        final LoginConfiguration loginConfiguration =
-                (LoginConfiguration) rpConfig.getProfileConfiguration(prc, LoginConfiguration.PROFILE_ID);
-        if (loginConfiguration == null) {
-            throw new IllegalStateException("CAS login profile configuration not found");
-        }
-        loginConfiguration.setPostAuthenticationFlows(flowIdentifiers);
     }
 
     private void assertPopulatedAttributeContext(final ProfileRequestContext prc) {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list