@Test public void setSecretReturnsMetadataObject() { HashicorpSetSecretData setSecretData = new HashicorpSetSecretData("engine", "name", Collections.emptyMap()); Versioned.Metadata metadata = mock(Versioned.Metadata.class); when(delegate.set(setSecretData)).thenReturn(metadata); Object result = keyVaultService.setSecret(setSecretData); assertThat(result).isInstanceOf(Versioned.Metadata.class); assertThat(result).isEqualTo(metadata); }
@Override public Object setSecret(HashicorpSetSecretData hashicorpSetSecretData) { KeyValueOperationsDelegate keyValueOperationsDelegate = keyValueOperationsDelegateFactory.create(hashicorpSetSecretData.getSecretEngineName()); try { return keyValueOperationsDelegate.set(hashicorpSetSecretData); } catch (NullPointerException ex) { throw new HashicorpVaultException("Unable to save generated secret to vault. Ensure that the secret engine being used is a v2 kv secret engine"); } }
HashicorpKeyVaultService implements KeyVaultService<HashicorpSetSecretData, HashicorpGetSecretData> { @Override public Object setSecret(HashicorpSetSecretData hashicorpSetSecretData) { KeyValueOperationsDelegate keyValueOperationsDelegate = keyValueOperationsDelegateFactory.create(hashicorpSetSecretData.getSecretEngineName()); try { return keyValueOperationsDelegate.set(hashicorpSetSecretData); } catch (NullPointerException ex) { throw new HashicorpVaultException("Unable to save generated secret to vault. Ensure that the secret engine being used is a v2 kv secret engine"); } } }
HashicorpKeyVaultService implements KeyVaultService<HashicorpSetSecretData, HashicorpGetSecretData> { @Override public Object setSecret(HashicorpSetSecretData hashicorpSetSecretData) { KeyValueOperationsDelegate keyValueOperationsDelegate = keyValueOperationsDelegateFactory.create(hashicorpSetSecretData.getSecretEngineName()); try { return keyValueOperationsDelegate.set(hashicorpSetSecretData); } catch (NullPointerException ex) { throw new HashicorpVaultException("Unable to save generated secret to vault. Ensure that the secret engine being used is a v2 kv secret engine"); } } HashicorpKeyVaultService(KeyValueOperationsDelegateFactory keyValueOperationsDelegateFactory); }
HashicorpKeyVaultService implements KeyVaultService<HashicorpSetSecretData, HashicorpGetSecretData> { @Override public Object setSecret(HashicorpSetSecretData hashicorpSetSecretData) { KeyValueOperationsDelegate keyValueOperationsDelegate = keyValueOperationsDelegateFactory.create(hashicorpSetSecretData.getSecretEngineName()); try { return keyValueOperationsDelegate.set(hashicorpSetSecretData); } catch (NullPointerException ex) { throw new HashicorpVaultException("Unable to save generated secret to vault. Ensure that the secret engine being used is a v2 kv secret engine"); } } HashicorpKeyVaultService(KeyValueOperationsDelegateFactory keyValueOperationsDelegateFactory); @Override String getSecret(HashicorpGetSecretData hashicorpGetSecretData); @Override Object setSecret(HashicorpSetSecretData hashicorpSetSecretData); }
HashicorpKeyVaultService implements KeyVaultService<HashicorpSetSecretData, HashicorpGetSecretData> { @Override public Object setSecret(HashicorpSetSecretData hashicorpSetSecretData) { KeyValueOperationsDelegate keyValueOperationsDelegate = keyValueOperationsDelegateFactory.create(hashicorpSetSecretData.getSecretEngineName()); try { return keyValueOperationsDelegate.set(hashicorpSetSecretData); } catch (NullPointerException ex) { throw new HashicorpVaultException("Unable to save generated secret to vault. Ensure that the secret engine being used is a v2 kv secret engine"); } } HashicorpKeyVaultService(KeyValueOperationsDelegateFactory keyValueOperationsDelegateFactory); @Override String getSecret(HashicorpGetSecretData hashicorpGetSecretData); @Override Object setSecret(HashicorpSetSecretData hashicorpSetSecretData);  }