[java-oidc-common] branch main updated: Transplant a couple of unit tests.

Scott Cantor cantor.2 at osu.edu
Tue Dec 7 15:42:01 UTC 2021


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

scantor pushed a commit to branch main
in repository java-oidc-common.

View the commit online:
http://git.shibboleth.net/view/?p=java-oidc-common.git;a=commit;h=474d0868e024bf17ed2ba19cf446a488ce345172

The following commit(s) were added to refs/heads/main by this push:
     new 474d086  Transplant a couple of unit tests.
474d086 is described below

commit 474d0868e024bf17ed2ba19cf446a488ce345172
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Dec 7 10:41:58 2021 -0500

    Transplant a couple of unit tests.
---
 .../config/OIDCCoreProtocolConfigurationTest.java  | 130 +++++++++++++++++++++
 .../OAuth2TokenRevocationConfigurationTest.java    |  44 +++++++
 2 files changed, 174 insertions(+)

diff --git a/oidc-common-profile-api/src/test/java/net/shibboleth/oidc/profile/config/OIDCCoreProtocolConfigurationTest.java b/oidc-common-profile-api/src/test/java/net/shibboleth/oidc/profile/config/OIDCCoreProtocolConfigurationTest.java
new file mode 100644
index 0000000..a7683e4
--- /dev/null
+++ b/oidc-common-profile-api/src/test/java/net/shibboleth/oidc/profile/config/OIDCCoreProtocolConfigurationTest.java
@@ -0,0 +1,130 @@
+/*
+ * 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.oidc.profile.config;
+
+import java.time.Duration;
+import java.util.Collections;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import net.shibboleth.idp.profile.config.SecurityConfiguration;
+import net.shibboleth.oidc.authn.principal.AuthenticationContextClassReferencePrincipal;
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+
+/**
+ * Unit tests for {@link OIDCCoreProtocolConfiguration}.
+ */
+public class OIDCCoreProtocolConfigurationTest {
+
+    private OIDCCoreProtocolConfiguration config;
+
+    @BeforeMethod
+    protected void setUp() throws Exception {
+        config = new OIDCCoreProtocolConfiguration();
+        config.setSecurityConfiguration(new SecurityConfiguration());
+        config.initialize();
+    }
+
+    @Test
+    public void testInitialState() throws ComponentInitializationException {
+        Assert.assertEquals(config.getId(), OIDCCoreProtocolConfiguration.PROFILE_ID);
+        Assert.assertTrue(config.getAuthenticationFlows(null).isEmpty());
+        Assert.assertTrue(config.getPostAuthenticationFlows(null).isEmpty());
+        Assert.assertTrue(config.getDefaultAuthenticationMethods(null).isEmpty());
+        Assert.assertTrue(config.getAdditionalAudiencesForIdToken(null).isEmpty());
+        Assert.assertEquals(config.getAuthorizeCodeLifetime(null), Duration.ofMinutes(5));
+        Assert.assertEquals(config.getIDTokenLifetime(null), Duration.ofHours(1));
+        Assert.assertEquals(config.getAccessTokenLifetime(null), Duration.ofMinutes(10));
+        Assert.assertEquals(config.getRefreshTokenLifetime(null), Duration.ofHours(2));
+        Assert.assertFalse(config.isAcrRequestAlwaysEssential(null));
+        Assert.assertTrue(config.getAdditionalAudiencesForIdToken(null).isEmpty());
+        Assert.assertTrue(config.isResolveAttributes(null));
+    }
+
+    @Test
+    void testsetResolveAttributes() {
+        Assert.assertTrue(config.isResolveAttributes(null));
+        config.setResolveAttributes(false);
+        Assert.assertFalse(config.isResolveAttributes(null));
+    }
+
+    @Test
+    void testsetDefaultAuthenticationMethods() {
+        Assert.assertTrue(config.getDefaultAuthenticationMethods(null).isEmpty());
+        config.setDefaultAuthenticationMethods(
+                Collections.singletonList(new AuthenticationContextClassReferencePrincipal("value")));
+        Assert.assertTrue(
+                config.getDefaultAuthenticationMethods(null).contains(
+                        new AuthenticationContextClassReferencePrincipal("value")));
+    }
+
+    @Test
+    void testsetRefreshTokenLifetime() {
+        config.setRefreshTokenLifetime(Duration.ofMillis(100));
+        Assert.assertEquals(config.getRefreshTokenLifetime(null), Duration.ofMillis(100));
+    }
+
+    @Test
+    void testsetAccessTokenLifetime() {
+        config.setAccessTokenLifetime(Duration.ofMillis(100));
+        Assert.assertEquals(config.getAccessTokenLifetime(null), Duration.ofMillis(100));
+    }
+
+    @Test
+    void testsetAuthorizeCodeLifetime() {
+        config.setAuthorizeCodeLifetime(Duration.ofMillis(100));
+        Assert.assertEquals(config.getAuthorizeCodeLifetime(null), Duration.ofMillis(100));
+    }
+
+    @Test
+    void testsetIDTokenLifetime() {
+        config.setIDTokenLifetime(Duration.ofMillis(100));
+        Assert.assertEquals(config.getIDTokenLifetime(null), Duration.ofMillis(100));
+    }
+
+    @Test
+    void testsetAcrRequestAlwaysEssential() {
+        Assert.assertFalse(config.isAcrRequestAlwaysEssential(null));
+        config.setAcrRequestAlwaysEssential(true);
+        Assert.assertTrue(config.isAcrRequestAlwaysEssential(null));
+    }
+
+    @Test
+    void testsetAdditionalAudiencesForIdToken() {
+        Assert.assertTrue(config.getAdditionalAudiencesForIdToken(null).isEmpty());
+        config.setAdditionalAudiencesForIdToken(Collections.singletonList("value"));
+        Assert.assertTrue(config.getAdditionalAudiencesForIdToken(null).contains("value"));
+    }
+
+    @Test
+    void testsetAuthenticationFlows() {
+        Assert.assertTrue(config.getAuthenticationFlows(null).isEmpty());
+        config.setAuthenticationFlows(Collections.singletonList("value"));
+        Assert.assertTrue(config.getAuthenticationFlows(null).contains("value"));
+    }
+
+    @Test
+    void testsetPostAuthenticationFlows() {
+        Assert.assertTrue(config.getPostAuthenticationFlows(null).isEmpty());
+        config.setPostAuthenticationFlows(Collections.singletonList("value"));
+        Assert.assertTrue(config.getPostAuthenticationFlows(null).contains("value"));
+    }
+
+}
\ No newline at end of file
diff --git a/oidc-common-profile-api/src/test/java/net/shibboleth/oidc/profile/oauth2/config/OAuth2TokenRevocationConfigurationTest.java b/oidc-common-profile-api/src/test/java/net/shibboleth/oidc/profile/oauth2/config/OAuth2TokenRevocationConfigurationTest.java
new file mode 100644
index 0000000..9b5fed0
--- /dev/null
+++ b/oidc-common-profile-api/src/test/java/net/shibboleth/oidc/profile/oauth2/config/OAuth2TokenRevocationConfigurationTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.oidc.profile.oauth2.config;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.testng.Assert;
+
+/**
+ * Tests for {@link OAuth2TokenRevocationConfiguration}, tests only constructors.
+ */
+public class OAuth2TokenRevocationConfigurationTest {
+
+    private OAuth2TokenRevocationConfiguration conf;
+
+    @BeforeMethod
+    protected void setUp() throws Exception {
+        conf = new OAuth2TokenRevocationConfiguration();
+    }
+
+    @Test
+    public void test() {
+        Assert.assertEquals(OAuth2TokenRevocationConfiguration.PROFILE_ID, conf.getId());
+        conf = new OAuth2TokenRevocationConfiguration("somethingelse");
+        Assert.assertEquals("somethingelse", conf.getId());
+    }
+
+}
\ No newline at end of file

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


More information about the commits mailing list