Search in sources :

Example 1 with CustomUser

use of org.baeldung.methodsecurity.entity.CustomUser in project tutorials by eugenp.

the class TestWithUserDetails method whenJohn_callLoadUserDetail_thenOK.

@Test
@WithUserDetails(value = "john", userDetailsServiceBeanName = "userDetailService")
public void whenJohn_callLoadUserDetail_thenOK() {
    CustomUser user = userService.loadUserDetail("jane");
    assertEquals("jane", user.getNickName());
}
Also used : CustomUser(org.baeldung.methodsecurity.entity.CustomUser) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails)

Example 2 with CustomUser

use of org.baeldung.methodsecurity.entity.CustomUser in project tutorials by eugenp.

the class TestWithUserDetails method givenJane_callSecuredLoadUserDetailWithJane_thenOK.

@Test
@WithUserDetails(value = "jane", userDetailsServiceBeanName = "userDetailService")
public void givenJane_callSecuredLoadUserDetailWithJane_thenOK() {
    CustomUser user = userService.securedLoadUserDetail("jane");
    assertEquals("jane", user.getNickName());
    assertEquals("jane", user.getUsername());
}
Also used : CustomUser(org.baeldung.methodsecurity.entity.CustomUser) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails)

Aggregations

CustomUser (org.baeldung.methodsecurity.entity.CustomUser)2 Test (org.junit.Test)2 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)2