@Test public void testUserRegistry() throws CryptoException, L2pSecurityException, AgentException { UserAgent a = UserAgent.createUserAgent("a"); UserAgent b = UserAgent.createUserAgent("b"); a.unlockPrivateKey("a"); b.unlockPrivateKey("b"); a.setLoginName("alpha"); b.setLoginName("beta"); LocalNode testee = LocalNode.launchNode(); testee.storeAgent(a); testee.storeAgent(b); assertEquals(a.getId(), testee.getAgentIdForLogin("alpha")); assertEquals(b.getId(), testee.getAgentIdForLogin("beta")); try { testee.getAgentIdForLogin("bla"); fail("AgentNotKnownException expected"); } catch (AgentNotKnownException e) { // corrects } }
@Test public void testUserRegDistribution() throws L2pSecurityException, AgentException, CryptoException, ArtifactNotFoundException { LocalNode testee1 = LocalNode.launchNode(); long id = Envelope.getClassEnvelopeId(UserAgentList.class, "mainlist"); for (int i = 0; i < 11; i++) { UserAgent a = UserAgent.createUserAgent("pass" + i); a.unlockPrivateKey("pass" + i); a.setLoginName("login_" + i); testee1.storeAgent(a); } // check, that the user list is stored testee1.fetchArtifact(id); LocalNode testee2 = LocalNode.launchNode(); // check, that the user list is stored testee2.fetchArtifact(id); testee2.getAgentIdForLogin("login_2"); }