Search in sources :

Example 1 with UserDao

use of org.apache.atlas.web.dao.UserDao in project incubator-atlas by apache.

the class UserDaoTest method testUserDaowithInValidLogin.

@Test
public void testUserDaowithInValidLogin() {
    boolean hadException = false;
    Properties userLogins = new Properties();
    userLogins.put("admin", "ADMIN::admin123");
    userLogins.put("test", "DATA_STEWARD::test123");
    UserDao user = new UserDao();
    user.setUserLogins(userLogins);
    try {
        User userBean = user.loadUserByUsername("xyz");
    } catch (UsernameNotFoundException uex) {
        hadException = true;
    }
    assertTrue(hadException);
}
Also used : UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) User(org.apache.atlas.web.model.User) UserDao(org.apache.atlas.web.dao.UserDao) Properties(java.util.Properties) Test(org.testng.annotations.Test)

Example 2 with UserDao

use of org.apache.atlas.web.dao.UserDao in project incubator-atlas by apache.

the class UserDaoTest method testUserDaowithValidUserLoginAndPassword.

@Test
public void testUserDaowithValidUserLoginAndPassword() {
    Properties userLogins = new Properties();
    userLogins.put("admin", "ADMIN::admin123");
    UserDao user = new UserDao();
    user.setUserLogins(userLogins);
    User userBean = user.loadUserByUsername("admin");
    assertTrue(userBean.getPassword().equals("admin123"));
    Collection<? extends GrantedAuthority> authorities = userBean.getAuthorities();
    String role = "";
    for (GrantedAuthority gauth : authorities) {
        role = gauth.getAuthority();
    }
    assertTrue("ADMIN".equals(role));
}
Also used : User(org.apache.atlas.web.model.User) UserDao(org.apache.atlas.web.dao.UserDao) GrantedAuthority(org.springframework.security.core.GrantedAuthority) Properties(java.util.Properties) Test(org.testng.annotations.Test)

Aggregations

Properties (java.util.Properties)2 UserDao (org.apache.atlas.web.dao.UserDao)2 User (org.apache.atlas.web.model.User)2 Test (org.testng.annotations.Test)2 GrantedAuthority (org.springframework.security.core.GrantedAuthority)1 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)1