[java-shib-metadata] branch main updated: Re-enable tests. Fix previous issue using Spring ReflectionTestUtils.

Brent Putman putmanb at georgetown.edu
Fri Feb 9 21:13:38 UTC 2024


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

putmanb pushed a commit to branch main
in repository java-shib-metadata.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-metadata.git;a=commit;h=95e95dabf245ed789a2cb39cc1157e0b97d84351

The following commit(s) were added to refs/heads/main by this push:
     new 95e95dab Re-enable tests.  Fix previous issue using Spring ReflectionTestUtils.
95e95dab is described below

commit 95e95dabf245ed789a2cb39cc1157e0b97d84351
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Fri Feb 9 15:53:38 2024 -0500

    Re-enable tests.  Fix previous issue using Spring ReflectionTestUtils.
---
 .../DynamicHTTPMetadataProviderParserTest.java     |  6 +--
 .../FileBackedHTTPMetadataProviderParserTest.java  |  6 +--
 .../impl/MetadataResolverTestingSupport.java       | 55 ----------------------
 3 files changed, 6 insertions(+), 61 deletions(-)

diff --git a/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/DynamicHTTPMetadataProviderParserTest.java b/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/DynamicHTTPMetadataProviderParserTest.java
index 173a9562..fbe796c5 100644
--- a/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/DynamicHTTPMetadataProviderParserTest.java
+++ b/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/DynamicHTTPMetadataProviderParserTest.java
@@ -30,13 +30,13 @@ import org.opensaml.saml.criterion.ArtifactCriterion;
 import org.opensaml.saml.metadata.resolver.impl.AbstractDynamicMetadataResolver;
 import org.opensaml.saml.metadata.resolver.impl.FunctionDrivenDynamicHTTPMetadataResolver;
 import org.opensaml.saml.metadata.resolver.impl.HTTPEntityIDRequestURLBuilder;
-import org.opensaml.saml.metadata.resolver.impl.MetadataResolverTestingSupport;
 import org.opensaml.saml.saml2.binding.artifact.SAML2ArtifactType0004;
 import org.opensaml.saml.saml2.metadata.EntityDescriptor;
 import org.opensaml.security.crypto.JCAConstants;
 import org.opensaml.security.httpclient.HttpClientSecurityParameters;
 import org.springframework.context.ApplicationContext;
 import org.springframework.mock.env.MockPropertySource;
+import org.springframework.test.util.ReflectionTestUtils;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
@@ -441,7 +441,7 @@ public class DynamicHTTPMetadataProviderParserTest extends AbstractMetadataParse
         Assert.assertEquals(ed.getEntityID(), entityID);
     }
     
-    @Test(enabled = false)
+    @Test
     public void testHTTPSTrustEngineExplicitKeyViaParamsMerge() throws Exception {
         MockPropertySource propSource = singletonPropertySource(PROP_MDURL, 
                 RepositorySupport.buildHTTPSResourceURL(REPO_OPENSAML, TEMPLATE_URL));
@@ -451,7 +451,7 @@ public class DynamicHTTPMetadataProviderParserTest extends AbstractMetadataParse
         
         //Test the merged security params instance
         assert resolver != null;
-        final HttpClientSecurityParameters securityParams = MetadataResolverTestingSupport.getHttpClientSecurityParameters(resolver);
+        final HttpClientSecurityParameters securityParams = (HttpClientSecurityParameters) ReflectionTestUtils.getField(resolver, "httpClientSecurityParameters");
         assert securityParams != null;
         Assert.assertNotNull(securityParams);
         Assert.assertNotNull(securityParams.getTLSTrustEngine());
diff --git a/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/FileBackedHTTPMetadataProviderParserTest.java b/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/FileBackedHTTPMetadataProviderParserTest.java
index f470fd4e..3be3aaa5 100644
--- a/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/FileBackedHTTPMetadataProviderParserTest.java
+++ b/shib-metadata-spring/src/test/java/net/shibboleth/spring/metadata/FileBackedHTTPMetadataProviderParserTest.java
@@ -23,11 +23,11 @@ import java.util.List;
 import org.opensaml.saml.metadata.resolver.MetadataResolver;
 import org.opensaml.saml.metadata.resolver.impl.FileBackedHTTPMetadataResolver;
 import org.opensaml.saml.metadata.resolver.impl.HTTPMetadataResolver;
-import org.opensaml.saml.metadata.resolver.impl.MetadataResolverTestingSupport;
 import org.opensaml.saml.saml2.metadata.EntityDescriptor;
 import org.opensaml.security.httpclient.HttpClientSecurityParameters;
 import org.springframework.beans.factory.BeanCreationException;
 import org.springframework.mock.env.MockPropertySource;
+import org.springframework.test.util.ReflectionTestUtils;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
@@ -197,7 +197,7 @@ public class FileBackedHTTPMetadataProviderParserTest extends AbstractMetadataPa
         assertNotNull(resolver.resolveSingle(criteriaFor(IDP_ID)));
     }
     
-    @Test(enabled = false) public void httpsTrustEngineExplicitKeyParamsMerge() throws Exception {
+    @Test public void httpsTrustEngineExplicitKeyParamsMerge() throws Exception {
         MockPropertySource propSource = singletonPropertySource(PROP_MDURL, 
                 RepositorySupport.buildHTTPSResourceURL(REPO_IDP, ENTITY_XML));
 
@@ -205,7 +205,7 @@ public class FileBackedHTTPMetadataProviderParserTest extends AbstractMetadataPa
 
         //Test the merged security params instance
         assert resolver != null;
-        final HttpClientSecurityParameters securityParams = MetadataResolverTestingSupport.getHttpClientSecurityParameters(resolver);
+        final HttpClientSecurityParameters securityParams = (HttpClientSecurityParameters) ReflectionTestUtils.getField(resolver, "httpClientSecurityParameters");
         assert securityParams != null;
         Assert.assertNotNull(securityParams);
         Assert.assertNotNull(securityParams.getTLSTrustEngine());
diff --git a/shib-metadata-spring/src/test/java/org/opensaml/saml/metadata/resolver/impl/MetadataResolverTestingSupport.java b/shib-metadata-spring/src/test/java/org/opensaml/saml/metadata/resolver/impl/MetadataResolverTestingSupport.java
deleted file mode 100644
index 8de787a1..00000000
--- a/shib-metadata-spring/src/test/java/org/opensaml/saml/metadata/resolver/impl/MetadataResolverTestingSupport.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.opensaml.saml.metadata.resolver.impl;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.opensaml.saml.metadata.resolver.MetadataResolver;
-import org.opensaml.security.httpclient.HttpClientSecurityParameters;
-
-/**
- * Testing support for metadata resolvers.
- */
-public final class MetadataResolverTestingSupport {
-    
-    /**
-     * Get the configured {@link HttpClientSecurityParameters} instance of the resolver, if applicable and available.
-     * 
-     * <p>
-     * This is necessary because the getter for this property is declared 'protected' on the resolver. This class
-     * is located in the same package so as to facilitate access for external callers.
-     * </p>
-     * 
-     * @param resolver the resolver to process
-     * 
-     * @return the security parameters instance, or null
-     */
-    @Nullable
-    public static HttpClientSecurityParameters getHttpClientSecurityParameters(
-            @Nonnull final MetadataResolver resolver) {
-
-        if (resolver instanceof HTTPMetadataResolver httpResolver) {
-            return httpResolver.getHttpClientSecurityParameters();
-        }
-
-        if (resolver instanceof AbstractDynamicHTTPMetadataResolver httpResolver) {
-            return httpResolver.getHttpClientSecurityParameters();
-        }
-        
-        return null;
-    }
-
-}

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


More information about the commits mailing list