Enable Payments Beta for more country codes
This commit is contained in:
parent
1e1394560d
commit
da5c0ae4b6
|
@ -12,9 +12,9 @@ import java.util.Set;
|
||||||
public class DynamicPaymentsConfiguration {
|
public class DynamicPaymentsConfiguration {
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private Set<String> allowedCountryCodes = Collections.emptySet();
|
private Set<String> disallowedCountryCodes = Collections.emptySet();
|
||||||
|
|
||||||
public Set<String> getAllowedCountryCodes() {
|
public Set<String> getDisallowedCountryCodes() {
|
||||||
return allowedCountryCodes;
|
return disallowedCountryCodes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,11 +137,11 @@ public class ProfileController {
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Response setProfile(@Auth AuthenticatedAccount auth, @Valid CreateProfileRequest request) {
|
public Response setProfile(@Auth AuthenticatedAccount auth, @Valid CreateProfileRequest request) {
|
||||||
final Set<String> allowedPaymentsCountryCodes =
|
final Set<String> disallowedPaymentsCountryCodes =
|
||||||
dynamicConfigurationManager.getConfiguration().getPaymentsConfiguration().getAllowedCountryCodes();
|
dynamicConfigurationManager.getConfiguration().getPaymentsConfiguration().getDisallowedCountryCodes();
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(request.getPaymentAddress()) &&
|
if (StringUtils.isNotBlank(request.getPaymentAddress()) &&
|
||||||
!allowedPaymentsCountryCodes.contains(Util.getCountryCode(auth.getAccount().getNumber()))) {
|
disallowedPaymentsCountryCodes.contains(Util.getCountryCode(auth.getAccount().getNumber()))) {
|
||||||
|
|
||||||
return Response.status(Status.FORBIDDEN).build();
|
return Response.status(Status.FORBIDDEN).build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,20 +272,20 @@ class DynamicConfigurationTest {
|
||||||
final DynamicConfiguration emptyConfig =
|
final DynamicConfiguration emptyConfig =
|
||||||
DynamicConfigurationManager.parseConfiguration(emptyConfigYaml, DynamicConfiguration.class).orElseThrow();
|
DynamicConfigurationManager.parseConfiguration(emptyConfigYaml, DynamicConfiguration.class).orElseThrow();
|
||||||
|
|
||||||
assertTrue(emptyConfig.getPaymentsConfiguration().getAllowedCountryCodes().isEmpty());
|
assertTrue(emptyConfig.getPaymentsConfiguration().getDisallowedCountryCodes().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
final String paymentsConfigYaml =
|
final String paymentsConfigYaml =
|
||||||
"payments:\n"
|
"payments:\n"
|
||||||
+ " allowedCountryCodes:\n"
|
+ " disallowedCountryCodes:\n"
|
||||||
+ " - 44";
|
+ " - 44";
|
||||||
|
|
||||||
final DynamicPaymentsConfiguration config =
|
final DynamicPaymentsConfiguration config =
|
||||||
DynamicConfigurationManager.parseConfiguration(paymentsConfigYaml, DynamicConfiguration.class).orElseThrow()
|
DynamicConfigurationManager.parseConfiguration(paymentsConfigYaml, DynamicConfiguration.class).orElseThrow()
|
||||||
.getPaymentsConfiguration();
|
.getPaymentsConfiguration();
|
||||||
|
|
||||||
assertEquals(Set.of("44"), config.getAllowedCountryCodes());
|
assertEquals(Set.of("44"), config.getDisallowedCountryCodes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ class ProfileControllerTest {
|
||||||
|
|
||||||
when(dynamicConfigurationManager.getConfiguration()).thenReturn(dynamicConfiguration);
|
when(dynamicConfigurationManager.getConfiguration()).thenReturn(dynamicConfiguration);
|
||||||
when(dynamicConfiguration.getPaymentsConfiguration()).thenReturn(dynamicPaymentsConfiguration);
|
when(dynamicConfiguration.getPaymentsConfiguration()).thenReturn(dynamicPaymentsConfiguration);
|
||||||
when(dynamicPaymentsConfiguration.getAllowedCountryCodes()).thenReturn(Collections.emptySet());
|
when(dynamicPaymentsConfiguration.getDisallowedCountryCodes()).thenReturn(Collections.emptySet());
|
||||||
|
|
||||||
when(rateLimiters.getProfileLimiter()).thenReturn(rateLimiter);
|
when(rateLimiters.getProfileLimiter()).thenReturn(rateLimiter);
|
||||||
when(rateLimiters.getUsernameLookupLimiter()).thenReturn(usernameRateLimiter);
|
when(rateLimiters.getUsernameLookupLimiter()).thenReturn(usernameRateLimiter);
|
||||||
|
@ -511,9 +511,6 @@ class ProfileControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSetProfilePaymentAddress() throws InvalidInputException {
|
void testSetProfilePaymentAddress() throws InvalidInputException {
|
||||||
when(dynamicPaymentsConfiguration.getAllowedCountryCodes())
|
|
||||||
.thenReturn(Set.of(Util.getCountryCode(AuthHelper.VALID_NUMBER_TWO)));
|
|
||||||
|
|
||||||
ProfileKeyCommitment commitment = new ProfileKey(new byte[32]).getCommitment(AuthHelper.VALID_UUID);
|
ProfileKeyCommitment commitment = new ProfileKey(new byte[32]).getCommitment(AuthHelper.VALID_UUID);
|
||||||
|
|
||||||
clearInvocations(AuthHelper.VALID_ACCOUNT_TWO);
|
clearInvocations(AuthHelper.VALID_ACCOUNT_TWO);
|
||||||
|
@ -552,6 +549,9 @@ class ProfileControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSetProfilePaymentAddressCountryNotAllowed() throws InvalidInputException {
|
void testSetProfilePaymentAddressCountryNotAllowed() throws InvalidInputException {
|
||||||
|
when(dynamicPaymentsConfiguration.getDisallowedCountryCodes())
|
||||||
|
.thenReturn(Set.of(Util.getCountryCode(AuthHelper.VALID_NUMBER_TWO)));
|
||||||
|
|
||||||
ProfileKeyCommitment commitment = new ProfileKey(new byte[32]).getCommitment(AuthHelper.VALID_UUID);
|
ProfileKeyCommitment commitment = new ProfileKey(new byte[32]).getCommitment(AuthHelper.VALID_UUID);
|
||||||
|
|
||||||
clearInvocations(AuthHelper.VALID_ACCOUNT_TWO);
|
clearInvocations(AuthHelper.VALID_ACCOUNT_TWO);
|
||||||
|
@ -600,9 +600,6 @@ class ProfileControllerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSetProfileUpdatesAccountCurrentVersion() throws InvalidInputException {
|
void testSetProfileUpdatesAccountCurrentVersion() throws InvalidInputException {
|
||||||
when(dynamicPaymentsConfiguration.getAllowedCountryCodes())
|
|
||||||
.thenReturn(Set.of(Util.getCountryCode(AuthHelper.VALID_NUMBER_TWO)));
|
|
||||||
|
|
||||||
ProfileKeyCommitment commitment = new ProfileKey(new byte[32]).getCommitment(AuthHelper.VALID_UUID_TWO);
|
ProfileKeyCommitment commitment = new ProfileKey(new byte[32]).getCommitment(AuthHelper.VALID_UUID_TWO);
|
||||||
|
|
||||||
clearInvocations(AuthHelper.VALID_ACCOUNT_TWO);
|
clearInvocations(AuthHelper.VALID_ACCOUNT_TWO);
|
||||||
|
|
Loading…
Reference in New Issue