Search in sources :

Example 1 with SimpleAuthenticationEncoder

use of org.springframework.security.rsocket.metadata.SimpleAuthenticationEncoder in project spring-boot by spring-projects.

the class SampleRSocketApplicationTests method rSocketEndpoint.

@Test
void rSocketEndpoint() {
    RSocketRequester requester = this.builder.rsocketStrategies((builder) -> builder.encoder(new SimpleAuthenticationEncoder())).setupMetadata(new UsernamePasswordMetadata("user", "password"), MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_AUTHENTICATION.getString())).tcp("localhost", this.port);
    Mono<Project> result = requester.route("find.project.spring-boot").retrieveMono(Project.class);
    StepVerifier.create(result).assertNext((project) -> Assertions.assertThat(project.getName()).isEqualTo("spring-boot")).verifyComplete();
}
Also used : Test(org.junit.jupiter.api.Test) RSocketRequester(org.springframework.messaging.rsocket.RSocketRequester) UsernamePasswordMetadata(org.springframework.security.rsocket.metadata.UsernamePasswordMetadata) WellKnownMimeType(io.rsocket.metadata.WellKnownMimeType) StepVerifier(reactor.test.StepVerifier) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SimpleAuthenticationEncoder(org.springframework.security.rsocket.metadata.SimpleAuthenticationEncoder) Assertions(org.assertj.core.api.Assertions) Autowired(org.springframework.beans.factory.annotation.Autowired) Mono(reactor.core.publisher.Mono) LocalRSocketServerPort(org.springframework.boot.rsocket.context.LocalRSocketServerPort) MimeTypeUtils(org.springframework.util.MimeTypeUtils) UsernamePasswordMetadata(org.springframework.security.rsocket.metadata.UsernamePasswordMetadata) RSocketRequester(org.springframework.messaging.rsocket.RSocketRequester) SimpleAuthenticationEncoder(org.springframework.security.rsocket.metadata.SimpleAuthenticationEncoder) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

WellKnownMimeType (io.rsocket.metadata.WellKnownMimeType)1 Assertions (org.assertj.core.api.Assertions)1 Test (org.junit.jupiter.api.Test)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 LocalRSocketServerPort (org.springframework.boot.rsocket.context.LocalRSocketServerPort)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 RSocketRequester (org.springframework.messaging.rsocket.RSocketRequester)1 SimpleAuthenticationEncoder (org.springframework.security.rsocket.metadata.SimpleAuthenticationEncoder)1 UsernamePasswordMetadata (org.springframework.security.rsocket.metadata.UsernamePasswordMetadata)1 MimeTypeUtils (org.springframework.util.MimeTypeUtils)1 Mono (reactor.core.publisher.Mono)1 StepVerifier (reactor.test.StepVerifier)1