Skip to content

Commit

Permalink
Add unit tests for SAMLSSOServiceProviderManager JDBC Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Osara-B committed Dec 19, 2024
1 parent 1b24d81 commit c67895f
Show file tree
Hide file tree
Showing 8 changed files with 2,211 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ private void validateServiceProvider(SAMLSSOServiceProviderDO serviceProviderDO)
throw new IdentityException("Issuer cannot be found in the provided arguments.");
}

if (StringUtils.isNotBlank(serviceProviderDO.getIssuerQualifier())) {
if (StringUtils.isNotBlank(serviceProviderDO.getIssuerQualifier()) &&
!serviceProviderDO.getIssuer().contains(IdentityRegistryResources.QUALIFIER_ID)) {
serviceProviderDO.setIssuer(
getIssuerWithQualifier(serviceProviderDO.getIssuer(), serviceProviderDO.getIssuerQualifier()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

public class SAMLSSOServiceProviderDO implements Serializable {

Expand Down Expand Up @@ -669,7 +670,7 @@ public String getSingleLogoutMethod() {
}

/**
* Get optional configs of the SAML SSO IdP.
* Get configs of the SAML SSO IdP.
*
* @return List of SPProperty.
*/
Expand Down Expand Up @@ -765,4 +766,69 @@ private void putIfNotNull(List<SPProperty> list, String key, String value) {
list.add(new SPProperty(key, value));
}
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SAMLSSOServiceProviderDO that = (SAMLSSOServiceProviderDO) o;
return doSingleLogout == that.doSingleLogout &&
doSignResponse == that.doSignResponse &&
doSignAssertions == that.doSignAssertions &&
enableAttributesByDefault == that.enableAttributesByDefault &&
isIdPInitSSOEnabled == that.isIdPInitSSOEnabled &&
idPInitSLOEnabled == that.idPInitSLOEnabled &&
doEnableEncryptedAssertion == that.doEnableEncryptedAssertion &&
doValidateSignatureInRequests == that.doValidateSignatureInRequests &&
doValidateSignatureInArtifactResolve == that.doValidateSignatureInArtifactResolve &&
enableSAML2ArtifactBinding == that.enableSAML2ArtifactBinding &&
samlECP == that.samlECP &&
doFrontChannelLogout == that.doFrontChannelLogout &&
Objects.equals(tenantDomain, that.tenantDomain) &&
Objects.equals(issuer, that.issuer) &&
Objects.equals(issuerQualifier, that.issuerQualifier) &&
Objects.equals(assertionConsumerUrl, that.assertionConsumerUrl) &&
Arrays.equals(assertionConsumerUrls, that.assertionConsumerUrls) &&
Objects.equals(defaultAssertionConsumerUrl, that.defaultAssertionConsumerUrl) &&
Objects.equals(certAlias, that.certAlias) &&
Objects.equals(sloResponseURL, that.sloResponseURL) &&
Objects.equals(sloRequestURL, that.sloRequestURL) &&
Objects.equals(loginPageURL, that.loginPageURL) &&
Objects.equals(attributeConsumingServiceIndex, that.attributeConsumingServiceIndex) &&
Arrays.equals(requestedClaims, that.requestedClaims) &&
Arrays.equals(requestedAudiences, that.requestedAudiences) &&
Arrays.equals(requestedRecipients, that.requestedRecipients) &&
Objects.equals(nameIdClaimUri, that.nameIdClaimUri) &&
Objects.equals(nameIDFormat, that.nameIDFormat) &&
Arrays.equals(idpInitSLOReturnToURLs, that.idpInitSLOReturnToURLs) &&
Objects.equals(signingAlgorithmUri, that.signingAlgorithmUri) &&
Objects.equals(digestAlgorithmUri, that.digestAlgorithmUri) &&
Objects.equals(assertionEncryptionAlgorithmUri, that.assertionEncryptionAlgorithmUri) &&
Objects.equals(keyEncryptionAlgorithmUri, that.keyEncryptionAlgorithmUri) &&
Objects.equals(signingCertificate, that.signingCertificate) &&
Objects.equals(encryptionCertificate, that.encryptionCertificate) &&
Objects.equals(idpEntityIDAlias, that.idpEntityIDAlias) &&
Objects.equals(frontChannelLogoutBinding, that.frontChannelLogoutBinding);
}

@Override
public int hashCode() {

int h = Objects.hash(tenantDomain, issuer, issuerQualifier, assertionConsumerUrl, defaultAssertionConsumerUrl,
certAlias, sloResponseURL, sloRequestURL, doSingleLogout, loginPageURL, doSignResponse,
doSignAssertions, attributeConsumingServiceIndex, enableAttributesByDefault, nameIdClaimUri,
nameIDFormat, isIdPInitSSOEnabled, idPInitSLOEnabled, doEnableEncryptedAssertion,
doValidateSignatureInRequests, doValidateSignatureInArtifactResolve, signingAlgorithmUri,
digestAlgorithmUri, assertionEncryptionAlgorithmUri, keyEncryptionAlgorithmUri, signingCertificate,
encryptionCertificate, isAssertionQueryRequestProfileEnabled, supportedAssertionQueryRequestTypes,
enableSAML2ArtifactBinding, samlECP, idpEntityIDAlias, doFrontChannelLogout, frontChannelLogoutBinding);
h = 31 * h + Arrays.hashCode(assertionConsumerUrls);
h = 31 * h + Arrays.hashCode(requestedClaims);
h = 31 * h + Arrays.hashCode(requestedAudiences);
h = 31 * h + Arrays.hashCode(requestedRecipients);
h = 31 * h + Arrays.hashCode(idpInitSLOReturnToURLs);
return h;
}


}
Loading

0 comments on commit c67895f

Please sign in to comment.