use of io.rsocket.util.RSocketProxy in project spring-security by spring-projects.
the class PayloadInterceptorRSocketTests method metadataPushWhenSecurityContextThenDelegateContext.
@Test
public void metadataPushWhenSecurityContextThenDelegateContext() {
TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "password");
given(this.interceptor.intercept(any(), any())).willAnswer(withAuthenticated(authentication));
given(this.delegate.metadataPush(any())).willReturn(this.voidResult.mono());
RSocket assertAuthentication = new RSocketProxy(this.delegate) {
@Override
public Mono<Void> metadataPush(Payload payload) {
return assertAuthentication(authentication).flatMap((a) -> super.metadataPush(payload));
}
};
PayloadInterceptorRSocket interceptor = new PayloadInterceptorRSocket(assertAuthentication, Arrays.asList(this.interceptor), this.metadataMimeType, this.dataMimeType);
StepVerifier.create(interceptor.metadataPush(this.payload)).verifyComplete();
verify(this.interceptor).intercept(this.exchange.capture(), any());
assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload);
verify(this.delegate).metadataPush(this.payload);
this.voidResult.assertWasSubscribed();
}
use of io.rsocket.util.RSocketProxy in project spring-security by spring-projects.
the class PayloadInterceptorRSocketTests method fireAndForgetWhenSecurityContextThenDelegateContext.
@Test
public void fireAndForgetWhenSecurityContextThenDelegateContext() {
TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "password");
given(this.interceptor.intercept(any(), any())).willAnswer(withAuthenticated(authentication));
given(this.delegate.fireAndForget(any())).willReturn(Mono.empty());
RSocket assertAuthentication = new RSocketProxy(this.delegate) {
@Override
public Mono<Void> fireAndForget(Payload payload) {
return assertAuthentication(authentication).flatMap((a) -> super.fireAndForget(payload));
}
};
PayloadInterceptorRSocket interceptor = new PayloadInterceptorRSocket(assertAuthentication, Arrays.asList(this.interceptor), this.metadataMimeType, this.dataMimeType);
interceptor.fireAndForget(this.payload).block();
verify(this.interceptor).intercept(this.exchange.capture(), any());
assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload);
verify(this.delegate).fireAndForget(this.payload);
}
use of io.rsocket.util.RSocketProxy in project spring-security by spring-projects.
the class PayloadInterceptorRSocketTests method requestResponseWhenSecurityContextThenDelegateContext.
@Test
public void requestResponseWhenSecurityContextThenDelegateContext() {
TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "password");
given(this.interceptor.intercept(any(), any())).willAnswer(withAuthenticated(authentication));
given(this.delegate.requestResponse(any())).willReturn(this.payloadResult.mono());
RSocket assertAuthentication = new RSocketProxy(this.delegate) {
@Override
public Mono<Payload> requestResponse(Payload payload) {
return assertAuthentication(authentication).flatMap((a) -> super.requestResponse(payload));
}
};
PayloadInterceptorRSocket interceptor = new PayloadInterceptorRSocket(assertAuthentication, Arrays.asList(this.interceptor), this.metadataMimeType, this.dataMimeType);
StepVerifier.create(interceptor.requestResponse(this.payload)).then(() -> this.payloadResult.assertSubscribers()).then(() -> this.payloadResult.emit(this.payload)).expectNext(this.payload).verifyComplete();
verify(this.interceptor).intercept(this.exchange.capture(), any());
assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload);
verify(this.delegate).requestResponse(this.payload);
}
use of io.rsocket.util.RSocketProxy in project spring-security by spring-projects.
the class PayloadInterceptorRSocketTests method requestStreamWhenSecurityContextThenDelegateContext.
@Test
public void requestStreamWhenSecurityContextThenDelegateContext() {
TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "password");
given(this.interceptor.intercept(any(), any())).willAnswer(withAuthenticated(authentication));
given(this.delegate.requestStream(any())).willReturn(this.payloadResult.flux());
RSocket assertAuthentication = new RSocketProxy(this.delegate) {
@Override
public Flux<Payload> requestStream(Payload payload) {
return assertAuthentication(authentication).flatMapMany((a) -> super.requestStream(payload));
}
};
PayloadInterceptorRSocket interceptor = new PayloadInterceptorRSocket(assertAuthentication, Arrays.asList(this.interceptor), this.metadataMimeType, this.dataMimeType);
StepVerifier.create(interceptor.requestStream(this.payload)).then(() -> this.payloadResult.assertSubscribers()).then(() -> this.payloadResult.emit(this.payload)).expectNext(this.payload).verifyComplete();
verify(this.interceptor).intercept(this.exchange.capture(), any());
assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload);
verify(this.delegate).requestStream(this.payload);
}
use of io.rsocket.util.RSocketProxy in project spring-security by spring-projects.
the class PayloadInterceptorRSocketTests method requestChannelWhenSecurityContextThenDelegateContext.
@Test
public void requestChannelWhenSecurityContextThenDelegateContext() {
Mono<Payload> payload = Mono.just(this.payload);
TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "password");
given(this.interceptor.intercept(any(), any())).willAnswer(withAuthenticated(authentication));
given(this.delegate.requestChannel(any())).willReturn(this.payloadResult.flux());
RSocket assertAuthentication = new RSocketProxy(this.delegate) {
@Override
public Flux<Payload> requestChannel(Publisher<Payload> payload) {
return assertAuthentication(authentication).flatMapMany((a) -> super.requestChannel(payload));
}
};
PayloadInterceptorRSocket interceptor = new PayloadInterceptorRSocket(assertAuthentication, Arrays.asList(this.interceptor), this.metadataMimeType, this.dataMimeType);
StepVerifier.create(interceptor.requestChannel(payload)).then(() -> this.payloadResult.assertSubscribers()).then(() -> this.payloadResult.emit(this.payload)).expectNext(this.payload).verifyComplete();
verify(this.interceptor).intercept(this.exchange.capture(), any());
assertThat(this.exchange.getValue().getPayload()).isEqualTo(this.payload);
verify(this.delegate).requestChannel(any());
}
Aggregations