From 3c56fcc8028a589e256759964a3b96ab757e2754 Mon Sep 17 00:00:00 2001 From: R Searls Date: Mon, 26 Aug 2024 11:17:17 -0400 Subject: [PATCH] [ELY-2797] check for null Boolean and return boolean --- .../http/oidc/OidcProviderMetadata.java | 12 ++-- .../http/oidc/OidcProviderMetadataTest.java | 61 +++++++++++++++++++ 2 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 http/oidc/src/test/java/org/wildfly/security/http/oidc/OidcProviderMetadataTest.java diff --git a/http/oidc/src/main/java/org/wildfly/security/http/oidc/OidcProviderMetadata.java b/http/oidc/src/main/java/org/wildfly/security/http/oidc/OidcProviderMetadata.java index 6c964dbfe1..c319a61dca 100644 --- a/http/oidc/src/main/java/org/wildfly/security/http/oidc/OidcProviderMetadata.java +++ b/http/oidc/src/main/java/org/wildfly/security/http/oidc/OidcProviderMetadata.java @@ -330,7 +330,7 @@ public void setClaimTypesSupported(List claimTypesSupported) { } public Boolean getClaimsParameterSupported() { - return claimsParameterSupported; + return claimsParameterSupported == null ? false : claimsParameterSupported; } public void setClaimsParameterSupported(Boolean claimsParameterSupported) { @@ -346,7 +346,7 @@ public void setScopesSupported(List scopesSupported) { } public Boolean getRequestParameterSupported() { - return requestParameterSupported; + return requestParameterSupported == null ? false : requestParameterSupported; } public void setRequestParameterSupported(Boolean requestParameterSupported) { @@ -354,7 +354,7 @@ public void setRequestParameterSupported(Boolean requestParameterSupported) { } public Boolean getRequestUriParameterSupported() { - return requestUriParameterSupported; + return requestUriParameterSupported == null ? false : requestUriParameterSupported; } public void setRequestUriParameterSupported(Boolean requestUriParameterSupported) { @@ -394,11 +394,11 @@ public void setRevocationEndpointAuthSigningAlgValuesSupported(List revo } public Boolean getBackchannelLogoutSupported() { - return backchannelLogoutSupported; + return backchannelLogoutSupported == null ? false : backchannelLogoutSupported; } public Boolean getBackchannelLogoutSessionSupported() { - return backchannelLogoutSessionSupported; + return backchannelLogoutSessionSupported == null ? false : backchannelLogoutSessionSupported; } public void setBackchannelLogoutSessionSupported(Boolean backchannelLogoutSessionSupported) { @@ -417,7 +417,7 @@ public List getCodeChallengeMethodsSupported() { // KEYCLOAK-6771 Certificate Bound Token // https://tools.ietf.org/html/draft-ietf-oauth-mtls-08#section-6.2 public Boolean getTlsClientCertificateBoundAccessTokens() { - return tlsClientCertificateBoundAccessTokens; + return tlsClientCertificateBoundAccessTokens == null ? false : tlsClientCertificateBoundAccessTokens; } public List getRequestObjectEncryptionAlgValuesSupported() { diff --git a/http/oidc/src/test/java/org/wildfly/security/http/oidc/OidcProviderMetadataTest.java b/http/oidc/src/test/java/org/wildfly/security/http/oidc/OidcProviderMetadataTest.java new file mode 100644 index 0000000000..7300fcfd6e --- /dev/null +++ b/http/oidc/src/test/java/org/wildfly/security/http/oidc/OidcProviderMetadataTest.java @@ -0,0 +1,61 @@ +package org.wildfly.security.http.oidc; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Test OIDC json config class properly returns boolean values. + */ +public class OidcProviderMetadataTest { + private OidcProviderMetadata oidcSecRealm; + + @Before + public void setUp() { + oidcSecRealm = new OidcProviderMetadata(); + } + + @Test + public void testClaimsParameterSupported() throws Exception { + assertFalse(oidcSecRealm.getClaimsParameterSupported()); + oidcSecRealm.setClaimsParameterSupported(true); + assertTrue(oidcSecRealm.getClaimsParameterSupported()); + } + + @Test + public void testRequestParameterSupported() throws Exception { + assertFalse(oidcSecRealm.getRequestParameterSupported()); + oidcSecRealm.setRequestParameterSupported(true); + assertTrue(oidcSecRealm.getRequestParameterSupported()); + } + + @Test + public void testRequestUriParameterSupported() throws Exception { + assertFalse(oidcSecRealm.getRequestUriParameterSupported()); + oidcSecRealm.setRequestUriParameterSupported(true); + assertTrue(oidcSecRealm.getRequestUriParameterSupported()); + } + + @Test + public void testBackchannelLogoutSupported() throws Exception { + assertFalse(oidcSecRealm.getBackchannelLogoutSupported()); + oidcSecRealm.setBackchannelLogoutSupported(true); + assertTrue(oidcSecRealm.getBackchannelLogoutSupported()); + } + + @Test + public void testBackchannelLogoutSessionSupported() throws Exception { + assertFalse(oidcSecRealm.getBackchannelLogoutSessionSupported()); + oidcSecRealm.setBackchannelLogoutSessionSupported(true); + assertTrue(oidcSecRealm.getBackchannelLogoutSessionSupported()); + } + + @Test + public void testTlsClientCertificateBoundAccessTokens() throws Exception { + assertFalse(oidcSecRealm.getTlsClientCertificateBoundAccessTokens()); + oidcSecRealm.setTlsClientCertificateBoundAccessTokens(true); + assertTrue(oidcSecRealm.getTlsClientCertificateBoundAccessTokens()); + } +}