mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-02 11:46:53 +00:00
Require donation permit headers
This commit is contained in:
1 parent
3d45706a35
commit
749d9c4f92
5 files changed
+74
-3
No files matched your search
+15
@@ -203,6 +203,21 @@ class OneTimeDonationControllerTest extends AbstractV1SubscriptionControllerTest
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void createBoostPaymentIntentMissingDonationPermit() {
|
||||
when(STRIPE_MANAGER.getSupportedCurrenciesForPaymentMethod(PaymentMethod.CARD))
|
||||
.thenReturn(Set.of("usd", "jpy", "bif", "eur"));
|
||||
|
||||
try (Response response = RESOURCE_EXTENSION.target("/v1/subscription/boost/create")
|
||||
.request()
|
||||
.post(Entity.json("""
|
||||
{"currency": "USD", "amount": 300}
|
||||
"""
|
||||
))) {
|
||||
assertThat(response.getStatus()).isEqualTo(401);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateBoostPayPal() throws IOException {
|
||||
final BraintreeManager.PayPalOneTimePaymentApprovalDetails payPalOneTimePaymentApprovalDetails = mock(
|
||||
|
||||
+44
@@ -340,6 +340,7 @@ class SubscriptionControllerTest extends AbstractV1SubscriptionControllerTest {
|
||||
try (Response managerCreateNullResponse = RESOURCE_EXTENSION.target(
|
||||
String.format("/v1/subscription/%s", subscriberId))
|
||||
.request()
|
||||
.header(HeaderUtils.DONATION_PERMIT, getDonationPermitHeader())
|
||||
.put(Entity.json(""))) {
|
||||
assertThat(managerCreateNullResponse.getStatus()).isEqualTo(403);
|
||||
}
|
||||
@@ -434,6 +435,49 @@ class SubscriptionControllerTest extends AbstractV1SubscriptionControllerTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateSubscriberMissingDonationPermit() {
|
||||
final byte[] subscriberUserAndKey = new byte[32];
|
||||
Arrays.fill(subscriberUserAndKey, (byte) 1);
|
||||
final String subscriberId = Base64.getEncoder().encodeToString(subscriberUserAndKey);
|
||||
|
||||
// Creating a subscriber requires a permit
|
||||
when(SUBSCRIPTIONS.get(any(), any())).thenReturn(Subscriptions.GetResult.NOT_STORED);
|
||||
try (Response response = RESOURCE_EXTENSION.target(String.format("/v1/subscription/%s", subscriberId))
|
||||
.request()
|
||||
.put(Entity.json(""))) {
|
||||
assertThat(response.getStatus()).isEqualTo(401);
|
||||
}
|
||||
|
||||
// Updating a subscriber does not require a permit
|
||||
when(SUBSCRIPTIONS.get(any(), any())).thenReturn(Subscriptions.GetResult.found(
|
||||
Subscriptions.Record.from(Arrays.copyOfRange(subscriberUserAndKey, 0, 16), Map.of(
|
||||
Subscriptions.KEY_PASSWORD, b(new byte[16]),
|
||||
Subscriptions.KEY_CREATED_AT, n(Instant.now().getEpochSecond()),
|
||||
Subscriptions.KEY_ACCESSED_AT, n(Instant.now().getEpochSecond())
|
||||
))));
|
||||
|
||||
try (Response response = RESOURCE_EXTENSION.target(String.format("/v1/subscription/%s", subscriberId))
|
||||
.request()
|
||||
.put(Entity.json(""))) {
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void createPaymentMethodMissingDonationPermit() {
|
||||
final byte[] subscriberUserAndKey = new byte[32];
|
||||
Arrays.fill(subscriberUserAndKey, (byte) 1);
|
||||
final String subscriberId = Base64.getEncoder().encodeToString(subscriberUserAndKey);
|
||||
|
||||
try (Response response = RESOURCE_EXTENSION
|
||||
.target(String.format("/v1/subscription/%s/create_payment_method", subscriberId))
|
||||
.request()
|
||||
.post(Entity.json(""))) {
|
||||
assertThat(response.getStatus()).isEqualTo(401);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void setSubscriptionLevelMissingProcessorCustomer() {
|
||||
// set up record
|
||||
|
||||
Reference in new issue
Block a user