本文整理匯總了Java中org.springframework.vault.support.VaultResponse.setData方法的典型用法代碼示例。如果您正苦於以下問題:Java VaultResponse.setData方法的具體用法?Java VaultResponse.setData怎麽用?Java VaultResponse.setData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.vault.support.VaultResponse
的用法示例。
在下文中一共展示了VaultResponse.setData方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: shouldSelfLookupToken
import org.springframework.vault.support.VaultResponse; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void shouldSelfLookupToken() {
VaultResponse vaultResponse = new VaultResponse();
vaultResponse.setData(Collections.singletonMap("ttl", 100));
when(clientAuthentication.login()).thenReturn(VaultToken.of("login"));
when(
restOperations.exchange(anyString(), any(), any(),
ArgumentMatchers.<Class> any())).thenReturn(
new ResponseEntity<>(vaultResponse, HttpStatus.OK));
LoginToken sessionToken = (LoginToken) sessionManager.getSessionToken();
assertThat(sessionToken.getLeaseDuration()).isEqualTo(Duration.ofSeconds(100));
verify(restOperations).exchange(eq("auth/token/lookup-self"), eq(HttpMethod.GET),
eq(new HttpEntity<>(VaultHttpHeaders.from(LoginToken.of("login")))),
any(Class.class));
}
示例2: shouldContinueIfSelfLookupFails
import org.springframework.vault.support.VaultResponse; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void shouldContinueIfSelfLookupFails() {
VaultResponse vaultResponse = new VaultResponse();
vaultResponse.setData(Collections.singletonMap("ttl", 100));
when(clientAuthentication.login()).thenReturn(VaultToken.of("login"));
when(
restOperations.exchange(anyString(), any(), any(),
ArgumentMatchers.<Class> any())).thenThrow(
new HttpClientErrorException(HttpStatus.FORBIDDEN));
VaultToken sessionToken = sessionManager.getSessionToken();
assertThat(sessionToken).isExactlyInstanceOf(VaultToken.class);
}
示例3: shouldSelfLookupToken
import org.springframework.vault.support.VaultResponse; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void shouldSelfLookupToken() {
VaultResponse vaultResponse = new VaultResponse();
vaultResponse.setData(Collections.singletonMap("ttl", 100));
mockToken(VaultToken.of("login"));
when(responseSpec.bodyToMono((Class) any())).thenReturn(Mono.just(vaultResponse));
sessionManager
.getSessionToken()
.as(StepVerifier::create)
.assertNext(
it -> {
LoginToken sessionToken = (LoginToken) it;
assertThat(sessionToken.getLeaseDuration()).isEqualTo(
Duration.ofSeconds(100));
}).verifyComplete();
verify(webClient.get()).uri("auth/token/lookup-self");
}
開發者ID:spring-projects,項目名稱:spring-vault,代碼行數:25,代碼來源:ReactiveLifecycleAwareSessionManagerUnitTests.java
示例4: shouldContinueIfSelfLookupFails
import org.springframework.vault.support.VaultResponse; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void shouldContinueIfSelfLookupFails() {
VaultResponse vaultResponse = new VaultResponse();
vaultResponse.setData(Collections.singletonMap("ttl", 100));
mockToken(VaultToken.of("login"));
when(responseSpec.bodyToMono((Class) any())).thenReturn(
Mono.error(new WebClientResponseException("forbidden", 403, "Forbidden",
null, null, null)));
sessionManager.getSessionToken().as(StepVerifier::create).assertNext(it -> {
assertThat(it).isExactlyInstanceOf(VaultToken.class);
}).verifyComplete();
}
開發者ID:spring-projects,項目名稱:spring-vault,代碼行數:18,代碼來源:ReactiveLifecycleAwareSessionManagerUnitTests.java
示例5: shouldAcceptSecretsWithoutLease
import org.springframework.vault.support.VaultResponse; //導入方法依賴的package包/類
@Test
public void shouldAcceptSecretsWithoutLease() {
VaultResponse secrets = new VaultResponse();
secrets.setData(Collections.singletonMap("key", (Object) "value"));
when(vaultOperations.read(requestedSecret.getPath())).thenReturn(secrets);
secretLeaseContainer.addRequestedSecret(requestedSecret);
secretLeaseContainer.start();
verifyZeroInteractions(taskScheduler);
verify(leaseListenerAdapter).onLeaseEvent(captor.capture());
SecretLeaseCreatedEvent leaseCreatedEvent = (SecretLeaseCreatedEvent) captor
.getValue();
assertThat(leaseCreatedEvent.getSource()).isEqualTo(requestedSecret);
assertThat(leaseCreatedEvent.getLease()).isNotNull();
assertThat(leaseCreatedEvent.getSecrets()).containsKey("key");
}
示例6: shouldAcceptSecretsWithStaticLease
import org.springframework.vault.support.VaultResponse; //導入方法依賴的package包/類
@Test
public void shouldAcceptSecretsWithStaticLease() {
VaultResponse secrets = new VaultResponse();
secrets.setLeaseId("lease");
secrets.setRenewable(false);
secrets.setData(Collections.singletonMap("key", (Object) "value"));
when(vaultOperations.read(requestedSecret.getPath())).thenReturn(secrets);
secretLeaseContainer.addRequestedSecret(requestedSecret);
secretLeaseContainer.start();
verifyZeroInteractions(taskScheduler);
verify(leaseListenerAdapter).onLeaseEvent(captor.capture());
SecretLeaseCreatedEvent leaseCreatedEvent = (SecretLeaseCreatedEvent) captor
.getValue();
assertThat(leaseCreatedEvent.getSource()).isEqualTo(requestedSecret);
assertThat(leaseCreatedEvent.getLease()).isNotNull();
assertThat(leaseCreatedEvent.getSecrets()).containsKey("key");
}
示例7: shouldNotRevokeSecretsWithoutLease
import org.springframework.vault.support.VaultResponse; //導入方法依賴的package包/類
@Test
public void shouldNotRevokeSecretsWithoutLease() throws Exception {
VaultResponse secrets = new VaultResponse();
secrets.setData(Collections.singletonMap("key", (Object) "value"));
when(vaultOperations.read(requestedSecret.getPath())).thenReturn(secrets);
secretLeaseContainer.addRequestedSecret(requestedSecret);
secretLeaseContainer.start();
secretLeaseContainer.destroy();
verifyZeroInteractions(taskScheduler);
verify(leaseListenerAdapter, never()).onLeaseEvent(
any(BeforeSecretLeaseRevocationEvent.class));
verify(leaseListenerAdapter, never()).onLeaseEvent(
any(AfterSecretLeaseRevocationEvent.class));
}
示例8: prepareResponse
import org.springframework.vault.support.VaultResponse; //導入方法依賴的package包/類
private void prepareResponse() {
Map<String, Object> data = new LinkedHashMap<String, Object>();
data.put("key", "value");
data.put("integer", 1);
data.put("empty", null);
data.put("complex", Collections.singletonMap("key", "value"));
VaultResponse vaultResponse = new VaultResponse();
vaultResponse.setData(data);
when(vaultTemplate.read("secret/myapp")).thenReturn(vaultResponse);
}
示例9: shouldNotRotateExpiringLease
import org.springframework.vault.support.VaultResponse; //導入方法依賴的package包/類
@Test
public void shouldNotRotateExpiringLease() {
when(taskScheduler.schedule(any(Runnable.class), any(Trigger.class))).thenReturn(
scheduledFuture);
VaultResponse first = createSecrets();
VaultResponse second = createSecrets();
second.setData(Collections.singletonMap("foo", (Object) "bar"));
when(vaultOperations.read(requestedSecret.getPath())).thenReturn(first, second);
when(vaultOperations.doWithSession(any(RestOperationsCallback.class)))
.thenReturn(getResponseEntity("new_lease", true, 5, HttpStatus.OK));
secretLeaseContainer.requestRotatingSecret("my-secret");
secretLeaseContainer.start();
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
verify(taskScheduler).schedule(captor.capture(), any(Trigger.class));
captor.getValue().run();
verify(taskScheduler, times(2)).schedule(captor.capture(), any(Trigger.class));
ArgumentCaptor<SecretLeaseCreatedEvent> createdEvents = ArgumentCaptor
.forClass(SecretLeaseCreatedEvent.class);
verify(leaseListenerAdapter, times(3)).onLeaseEvent(createdEvents.capture());
List<SecretLeaseCreatedEvent> events = createdEvents.getAllValues();
assertThat(events).hasSize(3);
assertThat(events.get(0)).isInstanceOf(SecretLeaseCreatedEvent.class);
assertThat(events.get(0).getSecrets()).containsOnlyKeys("key");
assertThat(events.get(1)).isInstanceOf(SecretLeaseExpiredEvent.class);
assertThat(events.get(2)).isInstanceOf(SecretLeaseCreatedEvent.class);
assertThat(events.get(2).getSecrets()).containsOnlyKeys("foo");
}
示例10: createSecrets
import org.springframework.vault.support.VaultResponse; //導入方法依賴的package包/類
private VaultResponse createSecrets() {
VaultResponse secrets = new VaultResponse();
secrets.setLeaseId("lease");
secrets.setRenewable(true);
secrets.setLeaseDuration(100);
secrets.setData(Collections.singletonMap("key", (Object) "value"));
return secrets;
}
示例11: createGenericSecrets
import org.springframework.vault.support.VaultResponse; //導入方法依賴的package包/類
private VaultResponse createGenericSecrets(Map<String, Object> data) {
VaultResponse secrets = new VaultResponse();
secrets.setRenewable(false);
secrets.setLeaseDuration(100);
secrets.setData(data);
return secrets;
}