Skip to content

Commit

Permalink
Fix check and add a test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
strehle committed Nov 30, 2024
1 parent d3548f8 commit fb47e38
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private void validateRegexStrings(List<String> uris, String fieldName) throws In

private void failIfPartialCertKeyInfo(String samlSpCert, String samlSpKey, String samlSpkeyPassphrase) throws InvalidIdentityZoneConfigurationException {
if ((samlSpCert == null && samlSpKey == null && samlSpkeyPassphrase == null) ||
(samlSpCert != null && samlSpKey != null && samlSpkeyPassphrase == null)) {
(samlSpCert != null && samlSpKey != null)) {
return;
}
throw new InvalidIdentityZoneConfigurationException("Identity zone cannot be updated with partial Saml CertKey config.", null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,22 @@ void keyIdNullException() {
assertThatExceptionOfType(InvalidIdentityZoneDetailsException.class).isThrownBy(() -> bootstrap.afterPropertiesSet());
}

@Test
void passphraseOnlyException() {
bootstrap.setSamlSpPrivateKey(key1());
bootstrap.setSamlSpCertificate(certificate1());
bootstrap.setSamlSpPrivateKeyPassphrase(passphrase1());
Map<String, Map<String, String>> keys = new HashMap<>();
Map<String, String> key1 = new HashMap<>();
key1.put("passphrase", passphrase1());
keys.put("key1", key1);
bootstrap.setActiveKeyId(null);
bootstrap.setSamlKeys(keys);
assertThatExceptionOfType(InvalidIdentityZoneDetailsException.class)
.isThrownBy(() -> bootstrap.afterPropertiesSet())
.withMessage("The zone configuration is invalid. Identity zone cannot be updated with partial Saml CertKey config.");
}

@Test
void samlKeysAndSigningConfigs() throws Exception {
bootstrap.setSamlSpPrivateKey(key1());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ void testUpdateWithPartialSamlKeyCertPair() throws Exception {
samlConfig.setPrivateKey(serviceProviderKey);
samlConfig.setPrivateKeyPassword(null);
samlConfig.setCertificate(serviceProviderCertificate);
updateZone(created, HttpStatus.UNPROCESSABLE_ENTITY, identityClientToken);
updateZone(created, HttpStatus.OK, identityClientToken);

samlConfig = created.getConfig().getSamlConfig();
samlConfig.setPrivateKey(null);
Expand Down

0 comments on commit fb47e38

Please sign in to comment.