@Override public AccountData getAccount(ParticipantId id) { AccountData account = accounts.get(id); if (account == null && !id.getAddress().startsWith("xxx")) { account = new HumanAccountDataImpl(id, new PasswordDigest("".toCharArray())); accounts.put(id, account); } return account; }
private HumanAccountData objectToHuman(ParticipantId id, DBObject object) { PasswordDigest passwordDigest = null; DBObject digestObj = (DBObject) object.get(HUMAN_PASSWORD_FIELD); if (digestObj != null) { byte[] salt = (byte[]) digestObj.get(PASSWORD_SALT_FIELD); byte[] digest = (byte[]) digestObj.get(PASSWORD_DIGEST_FIELD); passwordDigest = PasswordDigest.from(salt, digest); } return new HumanAccountDataImpl(id, passwordDigest); }
@Override protected void setUp() throws Exception { waveletProvider = new WaveletProviderStub(); AccountStore accountStore = new MemoryStore(); accountStore.putAccount(new HumanAccountDataImpl(ParticipantId.ofUnsafe("fred@example.com"))); org.eclipse.jetty.server.SessionManager jettySessionManager = mock(org.eclipse.jetty.server.SessionManager.class); SessionManager sessionManager = new SessionManagerImpl(accountStore, jettySessionManager); session = mock(HttpSession.class); when(session.getAttribute(SessionManager.USER_FIELD)).thenReturn(ParticipantId.ofUnsafe("fred@example.com")); servlet = new FetchServlet(waveletProvider, protoSerializer, sessionManager); }
public void testUnregisterFailsOnHumanAccount() throws PersistenceException { when(accountStore.getAccount(HUMAN_ID)).thenReturn( new HumanAccountDataImpl(ParticipantId.ofUnsafe(HUMAN_ID.getAddress()))); try { registrar.unregister(HUMAN_ID); fail(); } catch (RobotRegistrationException e) { // Expected. } }
public void testReRegisterFailsOnExistingHumanAccount() throws PersistenceException { when(accountStore.getAccount(HUMAN_ID)).thenReturn( new HumanAccountDataImpl(ParticipantId.ofUnsafe(HUMAN_ID.getAddress()))); try { registrar.registerOrUpdate(HUMAN_ID, OTHER_LOCATION); fail(); } catch (RobotRegistrationException e) { // Expected. } }
public void testUserWithNoPasswordHasNoPasswordDigest() { HumanAccountData account = new HumanAccountDataImpl(ParticipantId.ofUnsafe("moist@example.com")); assertNull(account.getPasswordDigest()); } }
@Override protected void setUp() throws Exception { MockitoAnnotations.initMocks(this); AccountStore store = new MemoryStore(); account = new HumanAccountDataImpl(ParticipantId.ofUnsafe("tubes@example.com")); store.putAccount(account); sessionManager = new SessionManagerImpl(store, jettySessionManager); }
public void testUserWithNoPasswordHasNoPasswordDigest() { HumanAccountData account = new HumanAccountDataImpl(ParticipantId.ofUnsafe("moist@example.com")); assertNull(account.getPasswordDigest()); } }
public void testReRegisterFailsOnExistingHumanAccount() throws PersistenceException { when(accountStore.getAccount(HUMAN_ID)).thenReturn( new HumanAccountDataImpl(ParticipantId.ofUnsafe(HUMAN_ID.getAddress()))); try { registrar.registerOrUpdate(HUMAN_ID, OTHER_LOCATION); fail(); } catch (RobotRegistrationException e) { // Expected. } }
protected static HumanAccountData createHumanAccount(ParticipantId pid, String email, String avatarFileId, String locale) { HumanAccountData account = new HumanAccountDataImpl(pid); account.setAvatarFileId(avatarFileId); account.setEmail(email); account.setLocale(locale); return account; }
@Override protected void setUp() throws Exception { AccountStore store = new MemoryStore(); store.putAccount(new HumanAccountDataImpl( ParticipantId.ofUnsafe("haspwd@example.com"), new PasswordDigest("pwd".toCharArray()))); store.putAccount(new HumanAccountDataImpl(ParticipantId.ofUnsafe("nopwd@example.com"))); AccountStoreHolder.init(store, "example.com"); }
@Override protected void setUp() throws Exception { AccountStore store = new MemoryStore(); store.putAccount(new HumanAccountDataImpl( ParticipantId.ofUnsafe("haspwd@example.com"), new PasswordDigest("pwd".toCharArray()))); store.putAccount(new HumanAccountDataImpl(ParticipantId.ofUnsafe("nopwd@example.com"))); AccountStoreHolder.init(store, "example.com"); }
public final void testRoundtripHumanAccount() throws Exception { AccountStore accountStore = newAccountStore(); HumanAccountDataImpl account = new HumanAccountDataImpl(HUMAN_ID); accountStore.putAccount(account); AccountData retrievedAccount = accountStore.getAccount(HUMAN_ID); assertEquals(account, retrievedAccount); }
public final void testRoundtripHumanAccount() throws Exception { AccountStore accountStore = newAccountStore(); HumanAccountDataImpl account = new HumanAccountDataImpl(HUMAN_ID); accountStore.putAccount(account); AccountData retrievedAccount = accountStore.getAccount(HUMAN_ID); assertEquals(account, retrievedAccount); }
@Override protected void setUp() throws Exception { waveletProvider = new WaveletProviderStub(); AccountStore accountStore = new MemoryStore(); accountStore.putAccount(new HumanAccountDataImpl(ParticipantId.ofUnsafe("fred@example.com"))); org.eclipse.jetty.server.SessionManager jettySessionManager = mock(org.eclipse.jetty.server.SessionManager.class); SessionManager sessionManager = new SessionManagerImpl(accountStore, jettySessionManager); servlet = new FetchServlet(waveletProvider, protoSerializer, sessionManager); }
public void testPasswordDigestVerifies() { HumanAccountData account = new HumanAccountDataImpl(ParticipantId.ofUnsafe("captainhammer@example.com"), new PasswordDigest("wonderflownium".toCharArray())); assertNotNull(account.getPasswordDigest()); assertTrue(account.getPasswordDigest().verify("wonderflownium".toCharArray())); }
public final void testRoundtripHumanAccountWithPassword() throws Exception { AccountStore accountStore = newAccountStore(); accountStore.putAccount( new HumanAccountDataImpl(HUMAN_ID, new PasswordDigest("internet".toCharArray()))); AccountData retrievedAccount = accountStore.getAccount(HUMAN_ID); assertTrue(retrievedAccount.asHuman().getPasswordDigest().verify("internet".toCharArray())); }
public final void testRoundtripHumanAccountWithPassword() throws Exception { AccountStore accountStore = newAccountStore(); accountStore.putAccount( new HumanAccountDataImpl(HUMAN_ID, new PasswordDigest("internet".toCharArray()))); AccountData retrievedAccount = accountStore.getAccount(HUMAN_ID); assertTrue(retrievedAccount.asHuman().getPasswordDigest().verify("internet".toCharArray())); }
public void testUserAddressReturnsCorrectResult() { ParticipantId id = ParticipantId.ofUnsafe("drhorrible@example.com"); HumanAccountData account = new HumanAccountDataImpl(id); assertEquals(account.getId(), id); assertTrue(account.isHuman()); assertFalse(account.isRobot()); }
public void testUserAddressReturnsCorrectResult() { ParticipantId id = ParticipantId.ofUnsafe("drhorrible@example.com"); HumanAccountData account = new HumanAccountDataImpl(id); assertEquals(account.getId(), id); assertTrue(account.isHuman()); assertFalse(account.isRobot()); }