Browse Source

Add initial test for keeping payment info of delete account

tags/v0.10.5
Kristijan Mitrovic 4 years ago
parent
commit
9f9d2693f6
2 changed files with 144 additions and 2 deletions
  1. +5
    -2
      bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java
  2. +139
    -0
      bubble-server/src/test/resources/models/tests/account_deletion/delete_account_with_payments.json

+ 5
- 2
bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java View File

@@ -5,10 +5,8 @@
package bubble.test.system;

import bubble.test.ActivatedBubbleModelTestBase;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

@Slf4j
public class AccountDeletionTest extends ActivatedBubbleModelTestBase {

@Override protected String getManifest() { return "manifest-test"; }
@@ -16,4 +14,9 @@ public class AccountDeletionTest extends ActivatedBubbleModelTestBase {
@Test public void testFullAccountDeletion() throws Exception { modelTest("account_deletion/full_delete_account"); }
@Test public void testBlockAccountDeletion() throws Exception { modelTest("account_deletion/block_delete_account"); }

@Test public void testDeleteAccountWithPayments() throws Exception {
modelTest("account_deletion/delete_account_with_payments");

// TODO: Check if all payment data is archived for the deleted user
}
}

+ 139
- 0
bubble-server/src/test/resources/models/tests/account_deletion/delete_account_with_payments.json View File

@@ -0,0 +1,139 @@
[
{
"comment": "create a user account",
"request": {
"uri": "users",
"method": "put",
"entity": {
"name": "user_with_payment_to_delete",
"password": "password1!",
"agreeToTerms": true,
"contact": { "type": "email", "info": "user_with_payment_to_delete@example.com" }
}
},
"response": { "store": "testAccount" }
},

{
"comment": "login as new user",
"request": {
"session": "new",
"uri": "auth/login",
"entity": { "name": "{{ testAccount.name }}", "password": "password1!" }
},
"response": {
"store": "testAccount",
"sessionName": "userSession",
"session": "token"
}
},

{
"comment": "get plans",
"request": { "uri": "plans" },
"response": { "store": "plans", "check": [{ "condition": "len(json) >= 1" }] }
},

{
"comment": "add plan, using 'free' payment method",
"request": {
"uri": "me/plans",
"method": "put",
"entity": {
"name": "test-net-{{rand 5}}",
"domain": "{{defaultDomain}}",
"locale": "en_US",
"timezone": "EST",
"plan": "{{plans.[0].name}}",
"footprint": "US",
"paymentMethodObject": { "paymentMethodType": "free", "paymentInfo": "free" }
}
},
"response": { "store": "accountPlan" }
},

{
"comment": "as root, verify bill exists and is paid",
"before": "sleep 15s",
"request": { "session": "rootSession", "uri": "users/{{testAccount.uuid}}/bills" },
"response": {
"store": "bills",
"check": [
{ "condition": "len(json) === 1" },
{ "condition": "json[0].getPlan() === plans[0].getUuid()" },
{ "condition": "json[0].getAccountPlan() === accountPlan.getUuid()" },
{ "condition": "json[0].getTotal() === plans[0].getPrice()" },
{ "condition": "json[0].getStatus().name() === 'paid'" }
]
}
},

{
"comment": "verify payment exists and is successful",
"request": { "uri": "users/{{testAccount.uuid}}/payments" },
"response": {
"store": "payments",
"check": [
{ "condition": "len(json) === 1" },
{ "condition": "json[0].getPlan() === plans[0].getUuid()" },
{ "condition": "json[0].getAccountPlan() === accountPlan.getUuid()" },
{ "condition": "json[0].getAmount() === plans[0].getPrice()" },
{ "condition": "json[0].getStatus().name() === 'success'" },
{ "condition": "json[0].getBill() === bills[0].getUuid()" }
]
}
},

{
"comment": "verify account payment methods, should be one",
"request": { "uri": "users/{{testAccount.uuid}}/paymentMethods" },
"response": {
"check": [
{ "condition": "len(json) === 1" },
{ "condition": "json[0].getPaymentMethodType().name() === 'free'" },
{ "condition": "json[0].getMaskedPaymentInfo() === 'XXXXXXXX'" },
{ "condition": "json[0].getUuid() === payments[0].getPaymentMethod()" }
]
}
},

{
"comment": "now (block) delete the account",
"request": {
"uri": "users/{{testAccount.uuid}}",
"method": "delete"
}
},

{
"comment": "lookup user, expect that it is still there, just marked as deleted",
"request": { "uri": "users/{{testAccount.uuid}}" },
"response": {
"check": [
{ "condition": "json.getUuid() === testAccount.getUuid()" },
{ "condition": "json.getName() === testAccount.getName()" },
{ "condition": "json.deleted()" }
]
}
},

{
"comment": "look up for deleted account's bills - none",
"request": { "uri": "users/{{testAccount.uuid}}/bills" },
"response": { "check": [{ "condition": "len(json) === 0" }] }
},

{
"comment": "look up for deleted account's payments - none",
"request": { "uri": "users/{{testAccount.uuid}}/payments" },
"response": { "check": [{ "condition": "len(json) === 0" }] }
},

{
"comment": "look up for deleted account's payment methods - none",
"request": { "uri": "users/{{testAccount.uuid}}/paymentMethods" },
"response": { "check": [{ "condition": "len(json) === 0" }] }
}

// test continues within Java's JUnit test as there are not resource methods implemented for archived payment data
]

Loading…
Cancel
Save