Search in sources :

Example 11 with HumanCoffeeNetUser

use of coffee.synyx.autoconfigure.security.service.HumanCoffeeNetUser in project coffeenet-starter by coffeenet.

the class CoffeeNetPrincipalExtractorTest method extractPrincipalReturnsUnknownHumanCoffeeUserIfMapDoesNotContainPrincipalKey.

@Test
public void extractPrincipalReturnsUnknownHumanCoffeeUserIfMapDoesNotContainPrincipalKey() {
    userInfoHashMap.remove("principal");
    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));
}
Also used : HumanCoffeeNetUser(coffee.synyx.autoconfigure.security.service.HumanCoffeeNetUser) Test(org.junit.Test)

Example 12 with HumanCoffeeNetUser

use of coffee.synyx.autoconfigure.security.service.HumanCoffeeNetUser in project coffeenet-starter by coffeenet.

the class CoffeeNetPrincipalExtractorTest method extractPrincipalReturnsHumanCoffeeUserWithUnknownNameIfUsernameIsNotOfTypeString.

@Test
public void extractPrincipalReturnsHumanCoffeeUserWithUnknownNameIfUsernameIsNotOfTypeString() {
    testPrincipal.put("username", true);
    Object principal = sut.extractPrincipal(userInfoHashMap);
    assertThat(principal, instanceOf(HumanCoffeeNetUser.class));
    HumanCoffeeNetUser humanCoffeeUser = (HumanCoffeeNetUser) principal;
    assertThat(humanCoffeeUser.getEmail(), is("coffy@coffeenet"));
    assertThat(humanCoffeeUser.getUsername(), is("UNKNOWN"));
    assertThat(humanCoffeeUser.getAuthorities().size(), is(1));
}
Also used : HumanCoffeeNetUser(coffee.synyx.autoconfigure.security.service.HumanCoffeeNetUser) Test(org.junit.Test)

Aggregations

HumanCoffeeNetUser (coffee.synyx.autoconfigure.security.service.HumanCoffeeNetUser)12 Test (org.junit.Test)11 CoffeeNetUserDetails (coffee.synyx.autoconfigure.security.service.CoffeeNetUserDetails)3 Map (java.util.Map)3 CoffeeNetApp (coffee.synyx.autoconfigure.discovery.service.CoffeeNetApp)2 Collections.emptyList (java.util.Collections.emptyList)2 Collections.singletonList (java.util.Collections.singletonList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 GrantedAuthority (org.springframework.security.core.GrantedAuthority)2 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)2