use of nl.knaw.huygens.timbuctoo.security.dto.Login in project timbuctoo by HuygensING.
the class JsonBasedAuthenticatorTest method createLoginIgnoresTheAdditionOfLoginOfAKnownUserName.
@Test
public void createLoginIgnoresTheAdditionOfLoginOfAKnownUserName() throws Exception {
Login[] logins = new Login[0];
Path emptyLoginsFile = FileHelpers.makeTempFilePath(true);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.writeValue(emptyLoginsFile.toFile(), logins);
JsonBasedAuthenticator instance = backedByFile(emptyLoginsFile);
String userName = "userName";
instance.createLogin("userPid", userName, "password", "givenName", "surname", "email", "org");
instance.createLogin("userPid2", userName, "password1", "givenName2", "surname2", "email2", "org2");
List<Login> loginList = objectMapper.readValue(emptyLoginsFile.toFile(), new TypeReference<List<Login>>() {
});
long count = loginList.stream().filter(login -> Objects.equals(login.getUsername(), userName)).count();
assertThat(count, is(1L));
Files.delete(emptyLoginsFile);
}
Aggregations