use of org.springframework.security.rsocket.metadata.UsernamePasswordMetadata in project spring-security by spring-projects.
the class RSocketMessageHandlerConnectionITests method routeWhenStreamCredentialsHaveAuthority.
@Test
public void routeWhenStreamCredentialsHaveAuthority() {
UsernamePasswordMetadata connectCredentials = new UsernamePasswordMetadata("user", "password");
// @formatter:off
this.requester = requester().setupMetadata(connectCredentials, UsernamePasswordMetadata.BASIC_AUTHENTICATION_MIME_TYPE).connectTcp(this.server.address().getHostName(), this.server.address().getPort()).block();
String hiUser = this.requester.route("secure.authority.retrieve-mono").metadata(new UsernamePasswordMetadata("admin", "password"), UsernamePasswordMetadata.BASIC_AUTHENTICATION_MIME_TYPE).data("Felipe").retrieveMono(String.class).block();
// @formatter:on
assertThat(hiUser).isEqualTo("Hi Felipe");
}
use of org.springframework.security.rsocket.metadata.UsernamePasswordMetadata in project spring-security by spring-projects.
the class RSocketMessageHandlerConnectionITests method connectWithAnyRole.
@Test
public void connectWithAnyRole() {
UsernamePasswordMetadata credentials = new UsernamePasswordMetadata("user", "password");
// @formatter:off
this.requester = requester().setupMetadata(credentials, UsernamePasswordMetadata.BASIC_AUTHENTICATION_MIME_TYPE).connectTcp(this.server.address().getHostName(), this.server.address().getPort()).block();
String hiRob = this.requester.route("anyroute").data("rob").retrieveMono(String.class).block();
// @formatter:on
assertThat(hiRob).isEqualTo("Hi rob");
}
use of org.springframework.security.rsocket.metadata.UsernamePasswordMetadata in project spring-security by spring-projects.
the class RSocketMessageHandlerITests method retrieveMonoWhenAuthenticationFailedThenException.
@Test
public void retrieveMonoWhenAuthenticationFailedThenException() throws Exception {
String data = "rob";
UsernamePasswordMetadata credentials = new UsernamePasswordMetadata("invalid", "password");
// @formatter:off
assertThatExceptionOfType(ApplicationErrorException.class).isThrownBy(() -> this.requester.route("secure.retrieve-mono").metadata(credentials, UsernamePasswordMetadata.BASIC_AUTHENTICATION_MIME_TYPE).data(data).retrieveMono(String.class).block()).withMessageContaining("Invalid Credentials");
// @formatter:on
assertThat(this.controller.payloads).isEmpty();
}
use of org.springframework.security.rsocket.metadata.UsernamePasswordMetadata in project spring-security by spring-projects.
the class RSocketMessageHandlerITests method retrieveMonoWhenAuthorizedThenGranted.
@Test
public void retrieveMonoWhenAuthorizedThenGranted() throws Exception {
String data = "rob";
UsernamePasswordMetadata credentials = new UsernamePasswordMetadata("rob", "password");
// @formatter:off
String hiRob = this.requester.route("secure.retrieve-mono").metadata(credentials, UsernamePasswordMetadata.BASIC_AUTHENTICATION_MIME_TYPE).data(data).retrieveMono(String.class).block();
// @formatter:on
assertThat(hiRob).isEqualTo("Hi rob");
assertThat(this.controller.payloads).containsOnly(data);
}
Aggregations