use of io.fabric8.openshift.api.model.UserBuilder in project syndesis by syndesisio.
the class UserHandlerTest method successfulWhoAmIWithoutFullName.
@Test
public void successfulWhoAmIWithoutFullName() {
openShiftServer.expect().get().withPath("/oapi/v1/users/~").andReturn(200, new UserBuilder().withNewMetadata().withName("testuser").and().build()).once();
SecurityContextHolder.getContext().setAuthentication(new PreAuthenticatedAuthenticationToken("testuser", "doesn'tmatter"));
UserHandler userHandler = new UserHandler(null, new OpenShiftServiceImpl(openShiftServer.getOpenshiftClient(), null));
User user = userHandler.whoAmI();
Assertions.assertThat(user).isNotNull();
Assertions.assertThat(user.getUsername()).isEqualTo("testuser");
Assertions.assertThat(user.getFullName()).isEmpty();
}
use of io.fabric8.openshift.api.model.UserBuilder in project syndesis by syndesisio.
the class UserHandlerTest method successfulWhoAmI.
@Test
public void successfulWhoAmI() {
openShiftServer.expect().get().withPath("/oapi/v1/users/~").andReturn(200, new UserBuilder().withFullName("Test User").withNewMetadata().withName("testuser").and().build()).once();
SecurityContextHolder.getContext().setAuthentication(new PreAuthenticatedAuthenticationToken("testuser", "doesn'tmatter"));
UserHandler userHandler = new UserHandler(null, new OpenShiftServiceImpl(openShiftServer.getOpenshiftClient(), null));
User user = userHandler.whoAmI();
Assertions.assertThat(user).isNotNull();
Assertions.assertThat(user.getUsername()).isEqualTo("testuser");
Assertions.assertThat(user.getFullName()).isNotEmpty().hasValue("Test User");
}
Aggregations