Java Code Examples for org.springframework.vault.support.VaultResponse#setRenewable()

The following examples show how to use org.springframework.vault.support.VaultResponse#setRenewable() . 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: SecretLeaseContainerUnitTests.java    From spring-vault with Apache License 2.0 6 votes vote down vote up
@Test
void shouldAcceptSecretsWithStaticLease() {

	VaultResponse secrets = new VaultResponse();
	secrets.setLeaseId("lease");
	secrets.setRenewable(false);
	secrets.setData(Collections.singletonMap("key", "value"));

	when(this.vaultOperations.read(this.requestedSecret.getPath())).thenReturn(secrets);

	this.secretLeaseContainer.addRequestedSecret(this.requestedSecret);
	this.secretLeaseContainer.start();

	verifyZeroInteractions(this.taskScheduler);
	verify(this.leaseListenerAdapter).onLeaseEvent(this.captor.capture());

	SecretLeaseCreatedEvent leaseCreatedEvent = (SecretLeaseCreatedEvent) this.captor.getValue();

	assertThat(leaseCreatedEvent.getSource()).isEqualTo(this.requestedSecret);
	assertThat(leaseCreatedEvent.getLease()).isNotNull();
	assertThat(leaseCreatedEvent.getSecrets()).containsKey("key");
}
 
Example 2
Source File: SecretLeaseContainerUnitTests.java    From spring-vault with Apache License 2.0 5 votes vote down vote up
private VaultResponse createSecrets(String key, String value, boolean renewable) {

		VaultResponse secrets = new VaultResponse();

		secrets.setLeaseId("lease");
		secrets.setRenewable(renewable);
		secrets.setLeaseDuration(100);
		secrets.setData(Collections.singletonMap(key, value));

		return secrets;
	}
 
Example 3
Source File: SecretLeaseContainerUnitTests.java    From spring-vault with Apache License 2.0 3 votes vote down vote up
private VaultResponse createGenericSecrets(Map<String, Object> data) {

		VaultResponse secrets = new VaultResponse();

		secrets.setRenewable(false);
		secrets.setLeaseDuration(100);
		secrets.setData(data);

		return secrets;
	}