[java-opensaml] branch main updated: Fix test bug by adding non-null variant of function composer.
Scott Cantor
cantor.2 at osu.edu
Tue Mar 21 20:19:25 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=d59daf43c0ff498018f20a3c70c2b013112c0158
The following commit(s) were added to refs/heads/main by this push:
new d59daf43c Fix test bug by adding non-null variant of function composer.
d59daf43c is described below
commit d59daf43c0ff498018f20a3c70c2b013112c0158
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Mar 21 16:19:22 2023 -0400
Fix test bug by adding non-null variant of function composer.
---
.../AbstractHandlerDelegatingProfileAction.java | 24 +++++++++++++++++++++-
.../PopulateSignatureValidationParameters.java | 4 ++--
.../PopulateSignatureSigningParametersTest.java | 3 ++-
3 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractHandlerDelegatingProfileAction.java b/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractHandlerDelegatingProfileAction.java
index 6a14e2c6c..70e0d47f4 100644
--- a/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractHandlerDelegatingProfileAction.java
+++ b/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractHandlerDelegatingProfileAction.java
@@ -142,8 +142,30 @@ public abstract class AbstractHandlerDelegatingProfileAction<DelegateType extend
*
* @param <T> the output type of the functions
*/
- @Nonnull protected <T> Function<MessageContext, T> adapt(
+ @Nullable protected <T> Function<MessageContext, T> adapt(
+ @Nullable final Function<ProfileRequestContext, T> function) {
+
+ if (function != null) {
+ return function.compose(PRC_LOOKUP);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Adapt a {@link ProfileRequestContext} function to a {@link MessageContext} function via composing
+ * with a lookup function, disallowing nulls.
+ *
+ * @param function the profile request context function
+ * @return the message context function
+ *
+ * @param <T> the output type of the functions
+ *
+ * @since 5.0.0
+ */
+ @Nonnull protected <T> Function<MessageContext, T> adaptRequired(
@Nonnull final Function<ProfileRequestContext, T> function) {
+
return function.compose(PRC_LOOKUP);
}
diff --git a/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/PopulateSignatureValidationParameters.java b/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/PopulateSignatureValidationParameters.java
index 26b4547b4..6d1e58da2 100644
--- a/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/PopulateSignatureValidationParameters.java
+++ b/opensaml-profile-impl/src/main/java/org/opensaml/profile/action/impl/PopulateSignatureValidationParameters.java
@@ -130,8 +130,8 @@ public class PopulateSignatureValidationParameters
assert resolver != null;
delegate.setSignatureValidationParametersResolver(resolver);
assert configurationLookupStrategy != null;
- delegate.setConfigurationLookupStrategy(adapt(configurationLookupStrategy));
- delegate.setSecurityParametersContextLookupStrategy(adapt(securityParametersContextLookupStrategy));
+ delegate.setConfigurationLookupStrategy(adaptRequired(configurationLookupStrategy));
+ delegate.setSecurityParametersContextLookupStrategy(adaptRequired(securityParametersContextLookupStrategy));
delegate.initialize();
}
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/profile/impl/PopulateSignatureSigningParametersTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/profile/impl/PopulateSignatureSigningParametersTest.java
index f1f6dd246..bfb41b128 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/profile/impl/PopulateSignatureSigningParametersTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/profile/impl/PopulateSignatureSigningParametersTest.java
@@ -40,6 +40,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/** Unit test for {@link PopulateSignatureSigningParameters}. */
+ at SuppressWarnings("javadoc")
public class PopulateSignatureSigningParametersTest extends OpenSAMLInitBaseTestCase {
private ProfileRequestContext prc;
@@ -93,7 +94,7 @@ public class PopulateSignatureSigningParametersTest extends OpenSAMLInitBaseTest
new OutboundMessageContextLookup()));
action.initialize();
- prc.getSubcontext(SecurityParametersContext.class, true).setSignatureSigningParameters(new SignatureSigningParameters());
+ prc.ensureSubcontext(SecurityParametersContext.class).setSignatureSigningParameters(new SignatureSigningParameters());
action.execute(prc);
ActionTestingSupport.assertProceedEvent(prc);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list