Skip to content

Commit

Permalink
Redact KeyVault secret in response body of the playback file (Azure#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
YijunXieMS authored Aug 3, 2021
1 parent 2f2b42f commit fd6b9ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -580,17 +580,20 @@ public void importCertificatePkcs12ForCertificateOperationsTest() throws Excepti
Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals("CN=KeyVaultTest"));
Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals("CN=Root Agency"));

// Retrieve the secret backing the certificate
SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier();
SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier());
Assert.assertTrue(secret.managed());

// Load the secret into a KeyStore
String secretPassword = "";
KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword);

// Validate the certificate and key in the KeyStore
validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword);
// Skip retrieving secret in playback mode because the cert in response body is redacted in the playback file.
if (interceptorManager.isRecordMode()) {
// Retrieve the secret backing the certificate
SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier();
SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier());
Assert.assertTrue(secret.managed());

// Load the secret into a KeyStore
String secretPassword = "";
KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword);

// Validate the certificate and key in the KeyStore
validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword);
}

CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName);
pollOnCertificateDeletion(getVaultUri(), certificateName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"cache-control" : "no-cache",
"x-ms-keyvault-service-version" : "1.1.0.859",
"x-ms-request-id" : "5b886689-c4ee-4a64-9f8a-d8d8d0a07394",
"Body" : "{\"value\":\"MIIJKAIBAzCCCOgGCSqGSIb3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H0ICCAohj2hLwzQOkqfax1OworHjXnFX7dtHAKtQJSWxkrkktg1EL2kmAMMlAdD65Q1nn5W1SSybq+kNcR6O00mXsXn7EnmF49/LFNRITL/BfF2qZ+ryAZEiKVikQoYwUypXo9tN5IwcZW60oKvnPrkc9ptj8IRo0DpTn4FYeLTxumVsyxDXcMnuE1XQut4SEjdHLULPMPMFsCFV/kxYRWKO38m34o61rX1+UUNoaiL1UEs/GpKMnZZuhrK8TzVgtjgEY9VgVE4QYdsf0079jhA1AKR+Jb47qlsRcFNLU59h/uXVkPUE6Ylj33YdQKTPGSoEMcRBP4mtBxzaNxgrJuNIQNZ65ikHtEiitck6OrIyK5ALBPL3Kzkc7596vm1//ldlkuvhY3fjBGrqf0Rv+PtuUllJ/kvra9K59lveiae5lw1oGrS+xxGBlEl+Uu152QECYRZoHDe90DfIUCo1faOR+c+ekJFZAesOdClxpvv0T5xVsZYS/jzODIxOOKtacqJa2nd1yXV7i3Z9FajoSdN2BIdxfTiMAKkLksWyaG4XXA7wU13vYTyLneUxaJt1AChT2C41wf8CjYxf1lG8rGskSXQuJWv3a9oF4YJJIA+pSskK5ReC790cwqccifQV3ORDKV+QpYD4SPri+N8NyUfO9/KpJDlWHjEKYgPL5imSsPFAfox7v0U7JbHKeem4cLllrlh9eFk5Pw0KH8mYTIIbrDMZpGe8yw1HOmqMTNYyjZMfwgGQxdJ2XehvdzqTqabMcUt2OSTJQCX4sJTsoI8JHoS18lz6DS45juzrKbQXGbzuf+m2io4OI3Zyhw6FO+3Naex38qXoQBPJjYWc1Sv3IFDsMyECNyMtSNFAwNzAfMAcGBSsOAwIaBBTKNA64YLrBB9L1vvU6qE7lvrZU8AQULbKXVgFE2m0EMrY7K0nf2ZtaYc0=\",\"contentType\":\"application/x-pkcs12\",\"id\":\"https://azure-keyvault-3.vault.azure.net/secrets/importCertPkcs/2b6aea9a1daf43cd86ee50ad058d2db6\",\"managed\":true,\"attributes\":{\"enabled\":true,\"nbf\":1430344421,\"exp\":2208988799,\"created\":1547150893,\"updated\":1547150893,\"recoveryLevel\":\"Recoverable+Purgeable\"},\"tags\":{},\"kid\":\"https://azure-keyvault-3.vault.azure.net/keys/importCertPkcs/2b6aea9a1daf43cd86ee50ad058d2db6\"}"
"Body" : "{\"value\":\"REDACTED\",\"contentType\":\"application/x-pkcs12\",\"id\":\"https://azure-keyvault-3.vault.azure.net/secrets/importCertPkcs/2b6aea9a1daf43cd86ee50ad058d2db6\",\"managed\":true,\"attributes\":{\"enabled\":true,\"nbf\":1430344421,\"exp\":2208988799,\"created\":1547150893,\"updated\":1547150893,\"recoveryLevel\":\"Recoverable+Purgeable\"},\"tags\":{},\"kid\":\"https://azure-keyvault-3.vault.azure.net/keys/importCertPkcs/2b6aea9a1daf43cd86ee50ad058d2db6\"}"
}
}, {
"Method" : "DELETE",
Expand Down Expand Up @@ -242,4 +242,4 @@
}
} ],
"variables" : [ ]
}
}

0 comments on commit fd6b9ab

Please sign in to comment.