use of coffee.synyx.autoconfigure.security.service.HumanCoffeeNetUser in project coffeenet-starter by coffeenet.
the class CoffeeNetPrincipalExtractorTest method extractPrincipalReturnsHumanCoffeeUserWithUnknownMailIfPrincipalDoesNotContainMailKey.
@Test
public void extractPrincipalReturnsHumanCoffeeUserWithUnknownMailIfPrincipalDoesNotContainMailKey() {
testPrincipal.remove("mail");
Object principal = sut.extractPrincipal(userInfoHashMap);
assertThat(principal, instanceOf(HumanCoffeeNetUser.class));
HumanCoffeeNetUser humanCoffeeUser = (HumanCoffeeNetUser) principal;
assertThat(humanCoffeeUser.getEmail(), is("UNKNOWN"));
assertThat(humanCoffeeUser.getUsername(), is("coffy"));
assertThat(humanCoffeeUser.getAuthorities().size(), is(1));
}
use of coffee.synyx.autoconfigure.security.service.HumanCoffeeNetUser in project coffeenet-starter by coffeenet.
the class CoffeeNetPrincipalExtractorTest method extractPrincipalReturnHumanCoffeeUser.
@Test
public void extractPrincipalReturnHumanCoffeeUser() {
Object principal = sut.extractPrincipal(userInfoHashMap);
assertThat(principal, instanceOf(HumanCoffeeNetUser.class));
HumanCoffeeNetUser humanCoffeeUser = (HumanCoffeeNetUser) principal;
assertThat(humanCoffeeUser.getEmail(), is("coffy@coffeenet"));
assertThat(humanCoffeeUser.getUsername(), is("coffy"));
assertThat(humanCoffeeUser.getAuthorities().size(), is(1));
}
use of coffee.synyx.autoconfigure.security.service.HumanCoffeeNetUser in project coffeenet-starter by coffeenet.
the class CoffeeNetPrincipalExtractorTest method extractPrincipalReturnsHumanCoffeeUserWithUnknownMailIfMailIsNotOfTypeString.
@Test
public void extractPrincipalReturnsHumanCoffeeUserWithUnknownMailIfMailIsNotOfTypeString() {
testPrincipal.put("mail", true);
Object principal = sut.extractPrincipal(userInfoHashMap);
assertThat(principal, instanceOf(HumanCoffeeNetUser.class));
HumanCoffeeNetUser humanCoffeeUser = (HumanCoffeeNetUser) principal;
assertThat(humanCoffeeUser.getEmail(), is("UNKNOWN"));
assertThat(humanCoffeeUser.getUsername(), is("coffy"));
assertThat(humanCoffeeUser.getAuthorities().size(), is(1));
}
use of coffee.synyx.autoconfigure.security.service.HumanCoffeeNetUser in project coffeenet-starter by coffeenet.
the class CoffeeNetPrincipalExtractorTest method extractPrincipalReturnsUnknownHumanCoffeeUserIfPrincipalIsNotOfTypeMap.
@Test
public void extractPrincipalReturnsUnknownHumanCoffeeUserIfPrincipalIsNotOfTypeMap() {
userInfoHashMap.put("principal", "someThingElse");
Object principal = sut.extractPrincipal(userInfoHashMap);
assertThat(principal, instanceOf(HumanCoffeeNetUser.class));
HumanCoffeeNetUser humanCoffeeUser = (HumanCoffeeNetUser) principal;
assertThat(humanCoffeeUser.getEmail(), is("UNKNOWN"));
assertThat(humanCoffeeUser.getUsername(), is("UNKNOWN"));
assertThat(humanCoffeeUser.getAuthorities().size(), is(1));
}
use of coffee.synyx.autoconfigure.security.service.HumanCoffeeNetUser in project coffeenet-starter by coffeenet.
the class CoffeeNetWebExtractorTest method extractUser.
@Test
public void extractUser() {
sut.registerService(USER_SERVICE, coffeeNetCurrentUserServiceMock);
Optional<CoffeeNetUserDetails> user = of(new HumanCoffeeNetUser("username", "email", emptyList()));
when(coffeeNetCurrentUserServiceMock.get()).thenReturn(user);
Optional<CoffeeNetWebUser> coffeeNetWebUser = sut.extractUser();
assertThat(coffeeNetWebUser.get().getEmail()).isSameAs("email");
assertThat(coffeeNetWebUser.get().getUsername()).isSameAs("username");
}
Aggregations