use of org.springframework.security.rsocket.api.PayloadExchange in project spring-security by spring-projects.
the class PayloadSocketAcceptorTests method captureExchange.
private PayloadExchange captureExchange() {
given(this.delegate.accept(any(), any())).willReturn(Mono.just(this.rSocket));
given(this.interceptor.intercept(any(), any())).willReturn(Mono.empty());
RSocket result = this.acceptor.accept(this.setupPayload, this.rSocket).block();
assertThat(result).isInstanceOf(PayloadInterceptorRSocket.class);
given(this.rSocket.fireAndForget(any())).willReturn(Mono.empty());
result.fireAndForget(this.payload).block();
ArgumentCaptor<PayloadExchange> exchangeArg = ArgumentCaptor.forClass(PayloadExchange.class);
verify(this.interceptor, times(2)).intercept(exchangeArg.capture(), any());
return exchangeArg.getValue();
}
use of org.springframework.security.rsocket.api.PayloadExchange in project spring-security by spring-projects.
the class PayloadSocketAcceptorTests method acceptWhenDefaultMetadataMimeTypeThenDefaulted.
@Test
public void acceptWhenDefaultMetadataMimeTypeThenDefaulted() {
given(this.setupPayload.dataMimeType()).willReturn(MediaType.APPLICATION_JSON_VALUE);
PayloadExchange exchange = captureExchange();
assertThat(exchange.getMetadataMimeType().toString()).isEqualTo(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString());
assertThat(exchange.getDataMimeType()).isEqualTo(MediaType.APPLICATION_JSON);
}
use of org.springframework.security.rsocket.api.PayloadExchange in project spring-security by spring-projects.
the class AuthenticationPayloadInterceptorTests method interceptWhenBasicCredentialsThenAuthenticates.
@Test
public void interceptWhenBasicCredentialsThenAuthenticates() {
AuthenticationPayloadInterceptor interceptor = new AuthenticationPayloadInterceptor(this.authenticationManager);
PayloadExchange exchange = createExchange();
TestingAuthenticationToken expectedAuthentication = new TestingAuthenticationToken("user", "password");
given(this.authenticationManager.authenticate(any())).willReturn(Mono.just(expectedAuthentication));
AuthenticationPayloadInterceptorChain authenticationPayloadChain = new AuthenticationPayloadInterceptorChain();
interceptor.intercept(exchange, authenticationPayloadChain).block();
Authentication authentication = authenticationPayloadChain.getAuthentication();
verify(this.authenticationManager).authenticate(this.authenticationArg.capture());
assertThat(this.authenticationArg.getValue()).isEqualToComparingFieldByField(new UsernamePasswordAuthenticationToken("user", "password"));
assertThat(authentication).isEqualTo(expectedAuthentication);
}
use of org.springframework.security.rsocket.api.PayloadExchange in project spring-security by spring-projects.
the class PayloadSocketAcceptorInterceptorTests method acceptWhenDefaultDataMimeTypeThenDefaulted.
@Test
public void acceptWhenDefaultDataMimeTypeThenDefaulted() {
this.acceptorInterceptor.setDefaultDataMimeType(MediaType.APPLICATION_JSON);
PayloadExchange exchange = captureExchange();
assertThat(exchange.getMetadataMimeType().toString()).isEqualTo(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString());
assertThat(exchange.getDataMimeType()).isEqualTo(MediaType.APPLICATION_JSON);
}
use of org.springframework.security.rsocket.api.PayloadExchange in project spring-security by spring-projects.
the class PayloadSocketAcceptorInterceptorTests method applyWhenDefaultMetadataMimeTypeThenDefaulted.
@Test
public void applyWhenDefaultMetadataMimeTypeThenDefaulted() {
given(this.setupPayload.dataMimeType()).willReturn(MediaType.APPLICATION_JSON_VALUE);
PayloadExchange exchange = captureExchange();
assertThat(exchange.getMetadataMimeType().toString()).isEqualTo(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString());
assertThat(exchange.getDataMimeType()).isEqualTo(MediaType.APPLICATION_JSON);
}
Aggregations