### Question:
DatawaveCertRolesLoginModule extends CertRolesLoginModule { @Override public boolean login() throws LoginException { if (trustedHeaderLogin) { log.trace("trustedHeaderLogin is true - returning false for login success"); return false; } 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; } DatawaveCertRolesLoginModule(); @Override void initialize(Subject subject, CallbackHandler callbackHandler, Map<String,?> sharedState, Map<String,?> options); @Override boolean login();  }### Answer:
@Test public void testSuccessfulLogin() throws Exception { String name = testUserCert.getSubjectDN().getName() + "<" + testUserCert.getIssuerDN().getName() + ">"; callbackHandler.name = name; callbackHandler.credential = testUserCert; boolean success = loginModule.login(); assertTrue("Login didn't succeed for alias in roles.properties", success); DatawavePrincipal principal = (DatawavePrincipal) field(DatawaveCertRolesLoginModule.class, "identity").get(loginModule); assertEquals(name.toLowerCase(), principal.getName()); }
@Test public void testFailedLogin() throws Exception { callbackHandler.name = "fakeUser"; callbackHandler.credential = testUserCert; boolean success = loginModule.login(); assertFalse("Login succeed for alias not in roles.properties", success); }