Quellcode durchsuchen

Test with assert if policy object is removed

tags/v0.10.5
Kristijan Mitrovic vor 4 Jahren
Ursprung
Commit
2cbc4bd930
2 geänderte Dateien mit 98 neuen und 0 gelöschten Zeilen
  1. +15
    -0
      bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java
  2. +83
    -0
      bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json

+ 15
- 0
bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java Datei anzeigen

@@ -5,13 +5,17 @@
package bubble.test.system;

import bubble.dao.account.AccountDAO;
import bubble.dao.account.AccountPolicyDAO;
import bubble.model.account.Account;
import bubble.test.ActivatedBubbleModelTestBase;
import lombok.extern.slf4j.Slf4j;
import org.cobbzilla.wizard.model.HashedPassword;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

@Slf4j
public class AccountDeletionTest extends ActivatedBubbleModelTestBase {

@@ -25,5 +29,16 @@ 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");

final var accPolicyDAO = getConfiguration().getBean(AccountPolicyDAO.class);
final var policies = accPolicyDAO.findAll();
assertEquals("Not all objects removed for deleted account", 1, policies.size());

final var accDAO = getConfiguration().getBean(AccountDAO.class);
final var acc = accDAO.findById(policies.get(0).getAccount());
assertEquals("The one policy should be for the only existing account", "root", acc.getName());
}

}

+ 83
- 0
bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json Datei anzeigen

@@ -0,0 +1,83 @@
[
{
"comment": "activate service, create account, login for block_delete",
"include": "new_account",
"params": {
"username": "user-to-partially-delete",
"password": "foobar1!",
"email": "user-partially-account-deletion@example.com",
"verifyEmail": "true"
}
},

{
"comment": "look up account policy for block_delete",
"request": { "uri": "users/{{user.uuid}}/policy" },
"response": {
"store": "policy",
"check": [
{"condition": "json.getAccountContacts() != null"},
{"condition": "json.getAccountContacts().length == 1"}
]
}
},

{
"comment": "set deletion policy to block_delete",
"request": {
"uri": "users/{{user.uuid}}/policy",
"data": "policy",
"entity": {
"deletionPolicy": "block_delete"
}
},
"response": {
"store": "policy",
"check": [
{"condition": "json.getDeletionPolicy().name() == 'block_delete'"}
]
}
},

{
"comment": "as root, block delete account",
"request": {
"session": "rootSession",
"uri": "users/{{user.uuid}}",
"method": "delete"
}
},

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

{
"comment": "try logging in as deleted user - failing now",
"request": {
"session": "new",
"uri": "auth/login",
"entity": {
"name": "{{user.name}}",
"password": "foobar1!"
}
},
"response": { "status": 404 }
}

// {
// "comment": "as root, look up account policy again - it should not be found now",
// "before": "sleep 10s",
// "request": { "session": "rootSession", "uri": "users/{{user.uuid}}/policy" },
// "response": { "status": 404 }
// }

]

Laden…
Abbrechen
Speichern