Java Code Examples for com.netflix.spinnaker.kork.secrets.EncryptedSecret#parse()

The following examples show how to use com.netflix.spinnaker.kork.secrets.EncryptedSecret#parse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SecretsManagerSecretEngineTest.java    From kork with Apache License 2.0 5 votes vote down vote up
@Test
public void decryptStringWithKey() {
  EncryptedSecret kvSecret =
      EncryptedSecret.parse("encrypted:secrets-manager!r:us-west-2!s:test-secret!k:password");
  doReturn(kvSecretValue).when(secretsManagerSecretEngine).getSecretValue(any(), any());
  assertArrayEquals("hunter2".getBytes(), secretsManagerSecretEngine.decrypt(kvSecret));
}
 
Example 2
Source File: SecretsManagerSecretEngineTest.java    From kork with Apache License 2.0 5 votes vote down vote up
@Test
public void decryptStringWithoutKey() {
  EncryptedSecret plaintextSecret =
      EncryptedSecret.parse("encrypted:secrets-manager!r:us-west-2!s:test-secret");
  doReturn(plaintextSecretValue).when(secretsManagerSecretEngine).getSecretValue(any(), any());
  assertArrayEquals("letmein".getBytes(), secretsManagerSecretEngine.decrypt(plaintextSecret));
}
 
Example 3
Source File: SecretsManagerSecretEngineTest.java    From kork with Apache License 2.0 5 votes vote down vote up
@Test
public void decryptFileWithKey() {
  EncryptedSecret kvSecret =
      EncryptedSecret.parse("encryptedFile:secrets-manager!r:us-west-2!s:private-key!k:password");
  exceptionRule.expect(InvalidSecretFormatException.class);
  doReturn(kvSecretValue).when(secretsManagerSecretEngine).getSecretValue(any(), any());
  secretsManagerSecretEngine.validate(kvSecret);
}
 
Example 4
Source File: SecretsManagerSecretEngineTest.java    From kork with Apache License 2.0 5 votes vote down vote up
@Test
public void decryptSecretStringAsFile() {
  EncryptedSecret secretStringFile =
      EncryptedSecret.parse("encryptedFile:secrets-manager!r:us-west-2!s:private-key");
  doReturn(secretStringFileValue).when(secretsManagerSecretEngine).getSecretValue(any(), any());
  assertArrayEquals(
      "BEGIN RSA PRIVATE KEY".getBytes(), secretsManagerSecretEngine.decrypt(secretStringFile));
}
 
Example 5
Source File: SecretsManagerSecretEngineTest.java    From kork with Apache License 2.0 5 votes vote down vote up
@Test
public void decryptSecretBinaryAsFile() {
  EncryptedSecret secretBinaryFile =
      EncryptedSecret.parse("encryptedFile:secrets-manager!r:us-west-2!s:private-key");
  doReturn(binarySecretValue).when(secretsManagerSecretEngine).getSecretValue(any(), any());
  assertArrayEquals(
      "i'm binary".getBytes(), secretsManagerSecretEngine.decrypt(secretBinaryFile));
}
 
Example 6
Source File: SecretsManagerSecretEngineTest.java    From kork with Apache License 2.0 5 votes vote down vote up
@Test
public void decryptStringWithBinaryResult() {
  EncryptedSecret kvSecret =
      EncryptedSecret.parse("encrypted:secrets-manager!r:us-west-2!s:test-secret!k:password");
  doReturn(binarySecretValue).when(secretsManagerSecretEngine).getSecretValue(any(), any());
  exceptionRule.expect(SecretException.class);
  secretsManagerSecretEngine.decrypt(kvSecret);
}