[java-idp-plugin-duo] branch main updated: Add very basic NimbusClientSupport tests.

Phil Smart philip.smart at jisc.ac.uk
Fri Oct 30 16:55:35 UTC 2020


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

philsmart pushed a commit to branch main
in repository java-idp-plugin-duo.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-duo.git;a=commit;h=054ba72850568e4cf23d41a311a95dad1f845642

The following commit(s) were added to refs/heads/main by this push:
       new  054ba72   Add very basic NimbusClientSupport tests.
054ba72 is described below

commit 054ba72850568e4cf23d41a311a95dad1f845642
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Fri Oct 30 16:55:28 2020 +0000

    Add very basic NimbusClientSupport tests.
---
 .../authn/duo/nimbus/NimbusClientSupport.java      |  4 ++
 .../authn/duo/nimbus/NimbusClientSupportTest.java  | 78 ++++++++++++++++++++++
 2 files changed, 82 insertions(+)

diff --git a/idp-duo-nimbus-client-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/nimbus/NimbusClientSupport.java b/idp-duo-nimbus-client-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/nimbus/NimbusClientSupport.java
index 608cabf..8548cdb 100644
--- a/idp-duo-nimbus-client-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/nimbus/NimbusClientSupport.java
+++ b/idp-duo-nimbus-client-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/nimbus/NimbusClientSupport.java
@@ -179,6 +179,10 @@ public final class NimbusClientSupport {
         
         final String signingInput = composeSigningInput(header,payload);
       
+        /*
+         * A null provider is supplied, as a result the preferred provider that supports the specified
+         *  algorithm will be used.
+         */
         final byte[] hmac = HMAC.compute(getJCAAlgorithmName(algorithm), secret, 
                 signingInput.getBytes(StandardCharsets.UTF_8), null);
         
diff --git a/idp-duo-nimbus-client-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/nimbus/NimbusClientSupportTest.java b/idp-duo-nimbus-client-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/nimbus/NimbusClientSupportTest.java
new file mode 100644
index 0000000..c6b57f7
--- /dev/null
+++ b/idp-duo-nimbus-client-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/nimbus/NimbusClientSupportTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You 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 net.shibboleth.idp.plugin.authn.duo.nimbus;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import net.shibboleth.idp.plugin.authn.duo.DefaultDuoOIDCIntegration;
+import net.shibboleth.idp.plugin.authn.duo.DuoClientException;
+
+/** Tests for the NimbusClientSupport class.*/
+public class NimbusClientSupportTest {
+    
+    /** A dummy state value.*/
+    @Nonnull static final String STATE = "adummystate";
+    
+    /** A dummy username.*/
+    @Nonnull static final  String USERNAME = "jdoe";
+    
+    /** A dummy audience.*/
+    @Nonnull static final String AUD = "audience";
+  
+    /** Class logger. */
+    @Nonnull private Logger log = LoggerFactory.getLogger(NimbusClientSupportTest.class);
+    
+    /** A dummy integration.*/
+    @Nullable private DefaultDuoOIDCIntegration integ;
+    
+
+    @BeforeMethod
+    public void setup() {
+        integ = new DefaultDuoOIDCIntegration();
+        integ.setAPIHost("host.com");
+        integ.setClientId("DIU6GEFWG5LIUBVV2M3P");
+        integ.setRedirectURI("http://localhost/");
+        integ.setSecretKey("rFvDfPul27v3Wew2zb6xRPzAJewJ34MP2w8UitPh");
+    }
+    
+    /* Simple test that a JWS string is created and contains 3 components, header.payload.signature */
+    @Test
+    public void testCreateJWSRequestObject() throws DuoClientException {              
+        final String jws = NimbusClientSupport.createJWSRequestObject(integ, STATE, USERNAME);
+        assertNotNull(jws);
+        assertEquals(jws.split("\\.").length,3);
+    }
+    
+    /* Simple test that a JWS string is created and contains 3 components, header.payload.signature */
+    @Test
+    public void testCreateJWS() throws DuoClientException {              
+        final String jws = NimbusClientSupport.createJWS(AUD,integ);
+        assertNotNull(jws);
+        assertEquals(jws.split("\\.").length,3);
+    }
+
+}

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


More information about the commits mailing list