Search in sources :

Example 11 with HumanCoffeeNetUser

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

the class CoffeeNetPrincipalExtractorTest method extractPrincipalReturnHumanCoffeeUserIfClientOnlyKeyIsMissing.

@Test
public void extractPrincipalReturnHumanCoffeeUserIfClientOnlyKeyIsMissing() {
    userInfoHashMap.remove("clientOnly");
    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));
}
Also used : HumanCoffeeNetUser(rocks.coffeenet.autoconfigure.security.service.HumanCoffeeNetUser) Test(org.junit.Test)

Example 12 with HumanCoffeeNetUser

use of rocks.coffeenet.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(rocks.coffeenet.autoconfigure.security.service.HumanCoffeeNetUser) Test(org.junit.Test)

Aggregations

HumanCoffeeNetUser (rocks.coffeenet.autoconfigure.security.service.HumanCoffeeNetUser)12 Test (org.junit.Test)11 Map (java.util.Map)3 CoffeeNetUserDetails (rocks.coffeenet.autoconfigure.security.service.CoffeeNetUserDetails)3 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 CoffeeNetApp (rocks.coffeenet.autoconfigure.discovery.service.CoffeeNetApp)2