use of uk.gov.pay.adminusers.model.ServiceName 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.ServiceName 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.ServiceName in project pay-adminusers by alphagov.
the class ServiceResourceUpdateMerchantDetailsIT method shouldSuccess_whenUpdatingMerchantDetails.
@Test
public void shouldSuccess_whenUpdatingMerchantDetails() throws Exception {
String serviceExternalId = randomUuid();
Service service = Service.from(randomInt(), serviceExternalId, new ServiceName("existing-name"));
databaseHelper.addService(service, randomInt().toString());
Map<String, Object> payload = Map.of("name", "somename", "telephone_number", "03069990000", "address_line1", "line1", "address_line2", "line2", "address_city", "city", "address_country", "country", "address_postcode", "postcode", "email", "dd-merchant@example.com", "url", "https://merchant.example.com");
givenSetup().when().contentType(JSON).accept(JSON).body(mapper.writeValueAsString(payload)).put(format(SERVICE_RESOURCE, serviceExternalId) + "/merchant-details").then().statusCode(200).body("merchant_details.name", is("somename")).body("merchant_details.telephone_number", is("03069990000")).body("merchant_details.address_line1", is("line1")).body("merchant_details.address_line2", is("line2")).body("merchant_details.address_city", is("city")).body("merchant_details.address_country", is("country")).body("merchant_details.address_postcode", is("postcode")).body("merchant_details.email", is("dd-merchant@example.com")).body("merchant_details.url", is("https://merchant.example.com"));
}
use of uk.gov.pay.adminusers.model.ServiceName in project pay-adminusers by alphagov.
the class ServiceResourceUpdateMerchantDetailsIT method shouldSuccess_whenUpdatingMerchantDetails_withoutOptionalFields.
@Test
public void shouldSuccess_whenUpdatingMerchantDetails_withoutOptionalFields() throws Exception {
String serviceExternalId = randomUuid();
Service service = Service.from(randomInt(), serviceExternalId, new ServiceName("existing-name"));
databaseHelper.addService(service, randomInt().toString());
Map<String, Object> payload = Map.of("name", "somename", "address_line1", "line1", "address_city", "city", "address_country", "country", "address_postcode", "postcode");
givenSetup().when().contentType(JSON).accept(JSON).body(mapper.writeValueAsString(payload)).put(format(SERVICE_RESOURCE, serviceExternalId) + "/merchant-details").then().statusCode(200).body("merchant_details.name", is("somename")).body("merchant_details.address_line1", is("line1")).body("merchant_details.address_city", is("city")).body("merchant_details.address_country", is("country")).body("merchant_details.address_postcode", is("postcode")).body("merchant_details", not(hasKey("telephone_number"))).body("merchant_details", not(hasKey("address_line2"))).body("merchant_details", not(hasKey("email"))).body("merchant_details", not(hasKey("url")));
}
use of uk.gov.pay.adminusers.model.ServiceName in project pay-adminusers by alphagov.
the class ServiceResourceUpdateMerchantDetailsIT method shouldFail_whenUpdatingMerchantDetails_withMissingMandatoryFieldName.
@Test
public void shouldFail_whenUpdatingMerchantDetails_withMissingMandatoryFieldName() throws Exception {
String serviceExternalId = randomUuid();
Service service = Service.from(randomInt(), serviceExternalId, new ServiceName("existing-name"));
databaseHelper.addService(service, randomInt().toString());
Map<String, Object> payload = Map.of("telephone_number", "03069990000", "address_line1", "line1", "address_line2", "line2", "address_city", "city", "address_country", "country", "address_postcode", "postcode");
givenSetup().when().contentType(JSON).accept(JSON).body(mapper.writeValueAsString(payload)).put(format(SERVICE_RESOURCE, serviceExternalId) + "/merchant-details").then().statusCode(400).body("errors", hasSize(1)).body("errors", hasItems("Field [name] is required"));
}
Aggregations