Skip to content

Commit

Permalink
[ELY-2797] check for null Boolean and return boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
rsearls committed Aug 26, 2024
1 parent 1eb5d16 commit 3c56fcc
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public void setClaimTypesSupported(List<String> claimTypesSupported) {
}

public Boolean getClaimsParameterSupported() {
return claimsParameterSupported;
return claimsParameterSupported == null ? false : claimsParameterSupported;
}

public void setClaimsParameterSupported(Boolean claimsParameterSupported) {
Expand All @@ -346,15 +346,15 @@ public void setScopesSupported(List<String> scopesSupported) {
}

public Boolean getRequestParameterSupported() {
return requestParameterSupported;
return requestParameterSupported == null ? false : requestParameterSupported;
}

public void setRequestParameterSupported(Boolean requestParameterSupported) {
this.requestParameterSupported = requestParameterSupported;
}

public Boolean getRequestUriParameterSupported() {
return requestUriParameterSupported;
return requestUriParameterSupported == null ? false : requestUriParameterSupported;
}

public void setRequestUriParameterSupported(Boolean requestUriParameterSupported) {
Expand Down Expand Up @@ -394,11 +394,11 @@ public void setRevocationEndpointAuthSigningAlgValuesSupported(List<String> 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) {
Expand All @@ -417,7 +417,7 @@ public List<String> 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<String> getRequestObjectEncryptionAlgValuesSupported() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}

0 comments on commit 3c56fcc

Please sign in to comment.