### Question:
DatawaveUsersRolesLoginModule extends UsersRolesLoginModule { @Override public boolean login() throws LoginException { boolean success = super.login(); int roleCount = 0; Group[] roleSets = getRoleSets(); if (roleSets != null) { for (Group roleSet : roleSets) { for (Enumeration<? extends Principal> e = roleSet.members(); e.hasMoreElements(); e.nextElement()) { ++roleCount; } } } if (roleCount == 0) { loginOk = false; success = false; } return success; } DatawaveUsersRolesLoginModule(); @Override boolean login();  }### Answer:
@Test public void testSuccessfulLogin() throws Exception { String name = testUserCert.getSubjectDN().getName() + "<" + testUserCert.getIssuerDN().getName() + ">"; callbackHandler.setSecurityInfo(new SimplePrincipal(name), new DatawaveCredential(testUserCert.getSubjectDN().getName(), testUserCert.getIssuerDN() .getName(), null, null).toString()); boolean success = loginModule.login(); assertTrue("Login didn't succeed for alias in users/roles.properties", success); DatawavePrincipal principal = (DatawavePrincipal) field(DatawaveUsersRolesLoginModule.class, "identity").get(loginModule); assertEquals(NORMALIZED_SUBJECT_DN_WITH_ISSUER_DN, principal.getName()); }
@Test public void testReverseDnSuccessfulLogin() throws Exception { String name = SUBJECT_DN_WITH_CN_LAST + "<" + ISSUER_DN_WITH_CN_LAST + ">"; callbackHandler.setSecurityInfo(new SimplePrincipal(name), new DatawaveCredential(SUBJECT_DN_WITH_CN_LAST, ISSUER_DN_WITH_CN_LAST, null, null).toString()); boolean success = loginModule.login(); assertTrue("Login didn't succeed for alias in users/roles.properties", success); DatawavePrincipal principal = (DatawavePrincipal) field(DatawaveUsersRolesLoginModule.class, "identity").get(loginModule); assertEquals(NORMALIZED_SUBJECT_DN_WITH_ISSUER_DN, principal.getName()); }
@Test public void testFailedLoginBadPassword() throws Exception { expectedException.expect(FailedLoginException.class); expectedException.expectMessage("Password invalid/Password required"); callbackHandler.setSecurityInfo(new SimplePrincipal("testUser<testIssuer>"), new DatawaveCredential("testUser", "testIssuer", null, null).toString()); boolean success = loginModule.login(); assertFalse("Login succeed for alias in users.properties with bad password", success); }