|
@@ -16,8 +16,6 @@
|
|
|
|
|
|
package org.springframework.security.core.userdetails.jdbc;
|
|
package org.springframework.security.core.userdetails.jdbc;
|
|
|
|
|
|
-import static org.assertj.core.api.Assertions.*;
|
|
|
|
-
|
|
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
|
|
import org.springframework.security.PopulatedDatabase;
|
|
import org.springframework.security.PopulatedDatabase;
|
|
@@ -25,10 +23,14 @@ import org.springframework.security.core.authority.AuthorityUtils;
|
|
import org.springframework.security.core.userdetails.UserDetails;
|
|
import org.springframework.security.core.userdetails.UserDetails;
|
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|
|
|
|
|
|
|
+import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
+import static org.assertj.core.api.Assertions.fail;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Tests {@link JdbcDaoImpl}.
|
|
* Tests {@link JdbcDaoImpl}.
|
|
*
|
|
*
|
|
* @author Ben Alex
|
|
* @author Ben Alex
|
|
|
|
+ * @author Eddú Meléndez
|
|
*/
|
|
*/
|
|
public class JdbcDaoImplTests {
|
|
public class JdbcDaoImplTests {
|
|
|
|
|
|
@@ -60,10 +62,10 @@ public class JdbcDaoImplTests {
|
|
assertThat(user.getPassword()).isEqualTo("koala");
|
|
assertThat(user.getPassword()).isEqualTo("koala");
|
|
assertThat(user.isEnabled()).isTrue();
|
|
assertThat(user.isEnabled()).isTrue();
|
|
|
|
|
|
- assertThat(AuthorityUtils.authorityListToSet(user.getAuthorities()).contains(
|
|
|
|
- "ROLE_TELLER"));
|
|
|
|
- assertThat(AuthorityUtils.authorityListToSet(user.getAuthorities()).contains(
|
|
|
|
- "ROLE_SUPERVISOR"));
|
|
|
|
|
|
+ assertThat(AuthorityUtils.authorityListToSet(user.getAuthorities()))
|
|
|
|
+ .contains("ROLE_TELLER");
|
|
|
|
+ assertThat(AuthorityUtils.authorityListToSet(user.getAuthorities()))
|
|
|
|
+ .contains("ROLE_SUPERVISOR");
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -71,8 +73,8 @@ public class JdbcDaoImplTests {
|
|
JdbcDaoImpl dao = makePopulatedJdbcDao();
|
|
JdbcDaoImpl dao = makePopulatedJdbcDao();
|
|
UserDetails user = dao.loadUserByUsername("scott");
|
|
UserDetails user = dao.loadUserByUsername("scott");
|
|
assertThat(user.getAuthorities()).hasSize(1);
|
|
assertThat(user.getAuthorities()).hasSize(1);
|
|
- assertThat(AuthorityUtils.authorityListToSet(user.getAuthorities()).contains(
|
|
|
|
- "ROLE_TELLER"));
|
|
|
|
|
|
+ assertThat(AuthorityUtils.authorityListToSet(user.getAuthorities()))
|
|
|
|
+ .contains("ROLE_TELLER");
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -133,10 +135,10 @@ public class JdbcDaoImplTests {
|
|
assertThat(user.getUsername()).isEqualTo("rod");
|
|
assertThat(user.getUsername()).isEqualTo("rod");
|
|
assertThat(user.getAuthorities()).hasSize(2);
|
|
assertThat(user.getAuthorities()).hasSize(2);
|
|
|
|
|
|
- assertThat(AuthorityUtils.authorityListToSet(user.getAuthorities()).contains(
|
|
|
|
- "ARBITRARY_PREFIX_ROLE_TELLER"));
|
|
|
|
- assertThat(AuthorityUtils.authorityListToSet(user.getAuthorities()).contains(
|
|
|
|
- "ARBITRARY_PREFIX_ROLE_SUPERVISOR"));
|
|
|
|
|
|
+ assertThat(AuthorityUtils.authorityListToSet(user.getAuthorities()))
|
|
|
|
+ .contains("ARBITRARY_PREFIX_ROLE_TELLER");
|
|
|
|
+ assertThat(AuthorityUtils.authorityListToSet(user.getAuthorities()))
|
|
|
|
+ .contains("ARBITRARY_PREFIX_ROLE_SUPERVISOR");
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|