use of uk.gov.pay.adminusers.model.Permission in project pay-adminusers by alphagov.
the class ServiceDaoIT method setupUsersForServiceAndRole.
private void setupUsersForServiceAndRole(String externalId, int roleId, int noOfUsers) {
Permission perm1 = aPermission();
Permission perm2 = aPermission();
databaseHelper.add(perm1).add(perm2);
Role role = role(roleId, "role-" + roleId, "role-desc-" + roleId);
role.setPermissions(Set.of(perm1, perm2));
databaseHelper.add(role);
String gatewayAccountId1 = randomInt().toString();
Service service1 = Service.from(randomInt(), externalId, new ServiceName(Service.DEFAULT_NAME_VALUE));
databaseHelper.addService(service1, gatewayAccountId1);
range(0, noOfUsers - 1).forEach(i -> {
String username = randomUuid();
String email = username + "@example.com";
UserDbFixture.userDbFixture(databaseHelper).withServiceRole(service1, roleId).withUsername(username).withEmail(email).insertUser();
});
// unmatching service
String gatewayAccountId2 = randomInt().toString();
Integer serviceId2 = randomInt();
String externalId2 = randomUuid();
Service service2 = Service.from(serviceId2, externalId2, new ServiceName(Service.DEFAULT_NAME_VALUE));
databaseHelper.addService(service2, gatewayAccountId2);
// same user 2 diff services - should count only once
String username3 = randomUuid();
String email3 = username3 + "@example.com";
User user3 = UserDbFixture.userDbFixture(databaseHelper).withServiceRole(service1, roleId).withUsername(username3).withEmail(email3).insertUser();
databaseHelper.addUserServiceRole(user3.getId(), serviceId2, role.getId());
}
use of uk.gov.pay.adminusers.model.Permission in project pay-adminusers by alphagov.
the class RoleDbFixture method insert.
public Role insert(Role role, Permission... permissions) {
for (Permission permission : permissions) {
databaseHelper.add(permission);
}
role.setPermissions(Set.of(permissions));
databaseHelper.add(role);
return role;
}
Aggregations