use of uk.gov.pay.adminusers.model.ServiceRole in project pay-adminusers by alphagov.
the class UserInviteCompleterTest method aUser.
private User aUser(String email) {
Service service = Service.from(serviceId, serviceExternalId, new ServiceName(Service.DEFAULT_NAME_VALUE));
ServiceRole serviceRole = ServiceRole.from(service, role(ADMIN.getId(), "Admin", "Administrator"));
return User.from(randomInt(), randomUuid(), "a-username", "random-password", email, "784rh", "8948924", Collections.singletonList(serviceRole), null, SecondFactorMethod.SMS, null, null, null);
}
use of uk.gov.pay.adminusers.model.ServiceRole in project pay-adminusers by alphagov.
the class LinksBuilderTest method shouldConstruct_userSelfLinkCorrectly.
@Test
void shouldConstruct_userSelfLinkCorrectly() throws Exception {
Service service = Service.from(2, "34783g87ebg764r", new ServiceName(Service.DEFAULT_NAME_VALUE));
Role role = Role.role(2, "blah", "blah");
ServiceRole serviceRole = ServiceRole.from(service, role);
User user = User.from(randomInt(), randomUuid(), "a-username", "a-password", "email@example.com", "4wrwef", "123435", Collections.singletonList(serviceRole), null, SecondFactorMethod.SMS, null, null, null);
User decoratedUser = linksBuilder.decorate(user);
String linkJson = objectMapper.writeValueAsString(decoratedUser.getLinks().get(0));
assertThat(linkJson, is("{\"rel\":\"self\",\"method\":\"GET\",\"href\":\"http://localhost:8080/v1/api/users/" + decoratedUser.getExternalId() + "\"}"));
}
use of uk.gov.pay.adminusers.model.ServiceRole in project pay-adminusers by alphagov.
the class UserInviteCreatorTest method aUser.
private User aUser(String email) {
Service service = Service.from(serviceId, serviceExternalId, new ServiceName(Service.DEFAULT_NAME_VALUE));
ServiceRole serviceRole = ServiceRole.from(service, role(ADMIN.getId(), "Admin", "Administrator"));
return User.from(randomInt(), randomUuid(), "a-username", "random-password", email, "784rh", "8948924", Collections.singletonList(serviceRole), null, SecondFactorMethod.SMS, null, null, null);
}
use of uk.gov.pay.adminusers.model.ServiceRole in project pay-adminusers by alphagov.
the class UserEntity method toUser.
public User toUser() {
List<ServiceRole> serviceRoles = this.servicesRoles.stream().map(ServiceRoleEntity::toServiceRole).collect(toUnmodifiableList());
User user = User.from(getId(), externalId, username, password, email, otpKey, telephoneNumber, serviceRoles, features, secondFactor, provisionalOtpKey, provisionalOtpKeyCreatedAt, lastLoggedInAt);
user.setLoginCounter(loginCounter);
user.setDisabled(disabled);
user.setSessionVersion(sessionVersion);
return user;
}
use of uk.gov.pay.adminusers.model.ServiceRole in project pay-adminusers by alphagov.
the class UserDbFixture method insertUser.
public User insertUser() {
List<ServiceRole> serviceRoles = serviceRolePairs.stream().map(servicePair -> ServiceRole.from(servicePair.getLeft(), servicePair.getRight())).collect(toUnmodifiableList());
User user = User.from(randomInt(), externalId, username, password, email, otpKey, telephoneNumber, serviceRoles, features, secondFactorMethod, provisionalOtpKey, null, null);
databaseTestHelper.add(user);
serviceRoles.forEach(serviceRole -> databaseTestHelper.addUserServiceRole(user.getId(), serviceRole.getService().getId(), serviceRole.getRole().getId()));
return user;
}
Aggregations