From ec1aa81055a283e7cb59b8671fbb8587a56c569f Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Tue, 14 Apr 2020 13:51:51 +0200 Subject: [PATCH 01/12] Add port number to log msg on test server start --- .../src/test/java/bubble/test/dev/BlankDevServerTest.java | 4 +++- .../src/test/java/bubble/test/dev/DevServerTest.java | 5 ++++- .../src/test/java/bubble/test/dev/NewBlankDevServerTest.java | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bubble-server/src/test/java/bubble/test/dev/BlankDevServerTest.java b/bubble-server/src/test/java/bubble/test/dev/BlankDevServerTest.java index a3bbd091..66e60fad 100644 --- a/bubble-server/src/test/java/bubble/test/dev/BlankDevServerTest.java +++ b/bubble-server/src/test/java/bubble/test/dev/BlankDevServerTest.java @@ -10,6 +10,7 @@ import org.cobbzilla.wizard.server.RestServerLifecycleListener; import org.cobbzilla.wizard.server.listener.FlywayMigrationListener; import org.junit.Test; +import java.net.URL; import java.util.ArrayList; import java.util.Collection; @@ -33,7 +34,8 @@ public class BlankDevServerTest extends NewBlankDevServerTest { } @Test public void runBlankServer () throws Exception { - log.info("runBlankServer: Bubble API server started and model initialized. You may now begin testing."); + log.info("runBlankServer: Bubble API server started and model initialized. You may now begin testing on port: " + + new URL(this.getApi().getBaseUri()).getPort()); sleep(DAYS.toMillis(30), "running dev server"); } diff --git a/bubble-server/src/test/java/bubble/test/dev/DevServerTest.java b/bubble-server/src/test/java/bubble/test/dev/DevServerTest.java index f56b6ece..792c8ea5 100644 --- a/bubble-server/src/test/java/bubble/test/dev/DevServerTest.java +++ b/bubble-server/src/test/java/bubble/test/dev/DevServerTest.java @@ -11,6 +11,8 @@ import lombok.extern.slf4j.Slf4j; import org.cobbzilla.wizard.server.RestServer; import org.junit.Test; +import java.net.URL; + import static java.util.concurrent.TimeUnit.DAYS; import static org.cobbzilla.util.system.Sleep.sleep; @@ -31,7 +33,8 @@ public class DevServerTest extends ActivatedBubbleModelTestBase { } @Test public void runDevServer () throws Exception { - log.info("runDevServer: Bubble API server started and model initialized. You may now begin testing."); + log.info("runDevServer: Bubble API server started and model initialized. You may now begin testing on port: " + + new URL(this.getApi().getBaseUri()).getPort()); sleep(DAYS.toMillis(30), "running dev server"); } diff --git a/bubble-server/src/test/java/bubble/test/dev/NewBlankDevServerTest.java b/bubble-server/src/test/java/bubble/test/dev/NewBlankDevServerTest.java index daff68bb..a58b09b7 100644 --- a/bubble-server/src/test/java/bubble/test/dev/NewBlankDevServerTest.java +++ b/bubble-server/src/test/java/bubble/test/dev/NewBlankDevServerTest.java @@ -11,6 +11,8 @@ import lombok.extern.slf4j.Slf4j; import org.cobbzilla.wizard.server.RestServer; import org.junit.Test; +import java.net.URL; + import static java.util.concurrent.TimeUnit.DAYS; import static org.cobbzilla.util.string.StringUtil.safeParseInt; import static org.cobbzilla.util.system.Sleep.sleep; @@ -35,7 +37,8 @@ public class NewBlankDevServerTest extends BubbleModelTestBase { } @Test public void runBlankServer () throws Exception { - log.info("runBlankServer: Bubble API server started and model initialized. You may now begin testing."); + log.info("runBlankServer: Bubble API server started and model initialized. You may now begin testing on port: " + + new URL(this.getApi().getBaseUri()).getPort()); sleep(DAYS.toMillis(30), "running dev server"); } From 428b523006b529cee9468adecced026c50b9eca0 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Tue, 14 Apr 2020 15:42:40 +0200 Subject: [PATCH 02/12] Move account deletion test --- .../test/system/AccountDeletionTest.java | 29 +++++++++++++++++++ .../java/bubble/test/system/AuthTest.java | 1 - .../full_delete_account.json} | 0 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java rename bubble-server/src/test/resources/models/tests/{auth/delete_account.json => account_deletion/full_delete_account.json} (100%) diff --git a/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java b/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java new file mode 100644 index 00000000..e1bcbc09 --- /dev/null +++ b/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2020 Bubble, Inc. All rights reserved. + * For personal (non-commercial) use, see license: https://bubblev.com/bubble-license/ + */ +package bubble.test.system; + +import bubble.dao.account.AccountDAO; +import bubble.model.account.Account; +import bubble.test.ActivatedBubbleModelTestBase; +import lombok.extern.slf4j.Slf4j; +import org.cobbzilla.wizard.model.HashedPassword; +import org.junit.Before; +import org.junit.Test; + +@Slf4j +public class AccountDeletionTest extends ActivatedBubbleModelTestBase { + + @Override protected String getManifest() { return "manifest-test"; } + + @Before public void resetRootPassword() { + // reset root password, some tests change it + final AccountDAO accountDAO = getConfiguration().getBean(AccountDAO.class); + final Account rootUser = accountDAO.findFirstAdmin(); + accountDAO.update(rootUser.setHashedPassword(new HashedPassword(ROOT_PASSWORD))); + } + + @Test public void testFullAccountDeletion() throws Exception { modelTest("account_deletion/full_delete_account"); } + +} diff --git a/bubble-server/src/test/java/bubble/test/system/AuthTest.java b/bubble-server/src/test/java/bubble/test/system/AuthTest.java index e333ce36..d1c2d5b2 100644 --- a/bubble-server/src/test/java/bubble/test/system/AuthTest.java +++ b/bubble-server/src/test/java/bubble/test/system/AuthTest.java @@ -24,7 +24,6 @@ public class AuthTest extends ActivatedBubbleModelTestBase { accountDAO.update(rootUser.setHashedPassword(new HashedPassword(ROOT_PASSWORD))); } - @Test public void testAccountDeletion () throws Exception { modelTest("auth/delete_account"); } @Test public void testBasicAuth () throws Exception { modelTest("auth/basic_auth"); } @Test public void testAccountCrud () throws Exception { modelTest("auth/account_crud"); } @Test public void testDeviceCrud () throws Exception { modelTest("auth/device_crud"); } diff --git a/bubble-server/src/test/resources/models/tests/auth/delete_account.json b/bubble-server/src/test/resources/models/tests/account_deletion/full_delete_account.json similarity index 100% rename from bubble-server/src/test/resources/models/tests/auth/delete_account.json rename to bubble-server/src/test/resources/models/tests/account_deletion/full_delete_account.json From 0643518744833ad2aa54c0a84a9ac17aa082aefb Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Tue, 14 Apr 2020 15:43:45 +0200 Subject: [PATCH 03/12] Use stored user in account deletion test --- .../account_deletion/full_delete_account.json | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bubble-server/src/test/resources/models/tests/account_deletion/full_delete_account.json b/bubble-server/src/test/resources/models/tests/account_deletion/full_delete_account.json index 36f00487..9e0468c9 100644 --- a/bubble-server/src/test/resources/models/tests/account_deletion/full_delete_account.json +++ b/bubble-server/src/test/resources/models/tests/account_deletion/full_delete_account.json @@ -12,7 +12,7 @@ { "comment": "look up account policy", - "request": { "uri": "users/user-to-delete/policy" }, + "request": { "uri": "users/{{user.uuid}}/policy" }, "response": { "store": "policy", "check": [ @@ -25,7 +25,7 @@ { "comment": "set deletion policy to full_delete", "request": { - "uri": "users/user-to-delete/policy", + "uri": "users/{{user.uuid}}/policy", "data": "policy", "entity": { "deletionPolicy": "full_delete" @@ -39,11 +39,17 @@ } }, + { + "comment": "lookup user - just checking it is the one for deletion", + "request": { "uri": "users/{{user.uuid}}" }, + "response": { "check": [{ "condition": "json.getName() == 'user-to-delete'" }] } + }, + { "comment": "as root, delete account", "request": { "session": "rootSession", - "uri": "users/user-to-delete", + "uri": "users/{{user.uuid}}", "method": "delete" } }, @@ -51,8 +57,8 @@ { "comment": "lookup user, expect not found", "request": { - "uri": "users/user-to-delete" + "uri": "users/{{user.uuid}}" }, "response": { "status": 404 } } -] \ No newline at end of file +] From 2cbc4bd9305d54c6b4e61b7f559c55e7f71f8441 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Wed, 15 Apr 2020 09:46:02 +0200 Subject: [PATCH 04/12] Test with assert if policy object is removed --- .../test/system/AccountDeletionTest.java | 15 ++++ .../block_delete_account.json | 83 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json diff --git a/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java b/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java index e1bcbc09..c5943b9d 100644 --- a/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java +++ b/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java @@ -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()); + } } diff --git a/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json b/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json new file mode 100644 index 00000000..3a66bb8d --- /dev/null +++ b/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json @@ -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 } +// } + +] \ No newline at end of file From 143116ba89cf5eae5ebfc4b1d035049802cad833 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Wed, 15 Apr 2020 10:18:48 +0200 Subject: [PATCH 05/12] Break long line --- .../src/main/java/bubble/dao/account/AccountPolicyDAO.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java b/bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java index 80527bdd..f77eba69 100644 --- a/bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java +++ b/bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java @@ -33,7 +33,8 @@ public class AccountPolicyDAO extends AccountOwnedEntityDAO { public AccountPolicy findSingleByAccount(String accountUuid) { final List found = findByAccount(accountUuid); - return found.isEmpty() ? create(new AccountPolicy().setAccount(accountUuid)) : found.size() > 1 ? die("findSingleByAccount: "+found.size()+" found!") : found.get(0); + return found.isEmpty() ? create(new AccountPolicy().setAccount(accountUuid)) + : found.size() > 1 ? die("findSingleByAccount: "+found.size()+" found!") : found.get(0); } } From a3f22a29a3f77bd69a80f702711a83662fd2128e Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Wed, 15 Apr 2020 10:19:25 +0200 Subject: [PATCH 06/12] Fix test for checking deleted account policy --- .../bubble/test/system/AccountDeletionTest.java | 12 +----------- .../account_deletion/block_delete_account.json | 16 +++++++--------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java b/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java index c5943b9d..d310ee51 100644 --- a/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java +++ b/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java @@ -29,16 +29,6 @@ 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()); - } + @Test public void testBlockAccountDeletion() throws Exception { modelTest("account_deletion/block_delete_account"); } } diff --git a/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json b/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json index 3a66bb8d..e261c638 100644 --- a/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json +++ b/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json @@ -71,13 +71,11 @@ } }, "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 } -// } + }, -] \ No newline at end of file + { + "comment": "as root, look up account policy again - it should recreated for this object with full deletion policy", + "request": { "session": "rootSession", "uri": "users/{{user.uuid}}/policy" }, + "response": { "check": [{ "condition": "json.getDeletionPolicy().name() == 'block_delete'" }] } + } +] From 39d49c1d944bccaeeafb6ecf6c41fa9e56b876db Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Wed, 15 Apr 2020 11:11:38 +0200 Subject: [PATCH 07/12] Add early exit if account is deleted in login method --- .../src/main/java/bubble/resources/account/AuthResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bubble-server/src/main/java/bubble/resources/account/AuthResource.java b/bubble-server/src/main/java/bubble/resources/account/AuthResource.java index e8154b12..3e32f781 100644 --- a/bubble-server/src/main/java/bubble/resources/account/AuthResource.java +++ b/bubble-server/src/main/java/bubble/resources/account/AuthResource.java @@ -306,7 +306,7 @@ public class AuthResource { if (!request.hasName()) return invalid("err.name.required", "name is required"); if (!request.hasPassword()) return invalid("err.password.required", "password is required"); final Account account = accountDAO.findByName(request.getName()); - if (account == null) return notFound(request.getName()); + if (account == null || account.deleted()) return notFound(request.getName()); if (!account.getHashedPassword().isCorrectPassword(request.getPassword())) { return notFound(request.getName()); } From ea83da04005b918b763bfab53133b734dd1719a5 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Wed, 15 Apr 2020 11:19:33 +0200 Subject: [PATCH 08/12] Remove automatic policy creation for deleted accounts --- .../bubble/dao/account/AccountPolicyDAO.java | 19 ++++++++++++++----- .../block_delete_account.json | 5 +++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java b/bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java index f77eba69..47d0ffa1 100644 --- a/bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java +++ b/bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java @@ -8,10 +8,9 @@ import bubble.model.account.AccountPolicy; import org.cobbzilla.wizard.validation.ValidationResult; import org.springframework.stereotype.Repository; -import java.util.List; - import static org.cobbzilla.util.daemon.ZillaRuntime.die; import static org.cobbzilla.wizard.resources.ResourceUtil.invalidEx; +import static org.cobbzilla.wizard.resources.ResourceUtil.notFoundEx; @Repository public class AccountPolicyDAO extends AccountOwnedEntityDAO { @@ -32,9 +31,19 @@ public class AccountPolicyDAO extends AccountOwnedEntityDAO { } public AccountPolicy findSingleByAccount(String accountUuid) { - final List found = findByAccount(accountUuid); - return found.isEmpty() ? create(new AccountPolicy().setAccount(accountUuid)) - : found.size() > 1 ? die("findSingleByAccount: "+found.size()+" found!") : found.get(0); + final var found = findByAccount(accountUuid); + if (found.size() == 1) return found.get(0); + + if (found.size() > 1) { + die("findSingleByAccount: More than 1 policy found for account " + accountUuid + " - " + found.size()); + } + + // If there's no policy, and the account is marked as deleted - just return not found: + final var account = getConfiguration().getBean(AccountDAO.class).findById(accountUuid); + if (account.deleted()) throw notFoundEx(); + + // Else, create a policy for existing account: + return create(new AccountPolicy().setAccount(accountUuid)); } } diff --git a/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json b/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json index e261c638..304317e5 100644 --- a/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json +++ b/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json @@ -74,8 +74,9 @@ }, { - "comment": "as root, look up account policy again - it should recreated for this object with full deletion policy", + "comment": "as root, look up account policy again - it should not be found now", "request": { "session": "rootSession", "uri": "users/{{user.uuid}}/policy" }, - "response": { "check": [{ "condition": "json.getDeletionPolicy().name() == 'block_delete'" }] } + "response": { "status": 404 } } + ] From 291bd841ed44a9ae2b4c6f8efb5a8cfbd2372082 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Wed, 15 Apr 2020 11:42:34 +0200 Subject: [PATCH 09/12] Add back creation of policy for deleted account --- .../bubble/dao/account/AccountPolicyDAO.java | 12 +++++------ .../block_delete_account.json | 21 ++++++++++++++++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java b/bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java index 47d0ffa1..a627f11c 100644 --- a/bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java +++ b/bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java @@ -8,9 +8,9 @@ import bubble.model.account.AccountPolicy; import org.cobbzilla.wizard.validation.ValidationResult; import org.springframework.stereotype.Repository; +import static bubble.model.account.AccountDeletionPolicy.full_delete; import static org.cobbzilla.util.daemon.ZillaRuntime.die; import static org.cobbzilla.wizard.resources.ResourceUtil.invalidEx; -import static org.cobbzilla.wizard.resources.ResourceUtil.notFoundEx; @Repository public class AccountPolicyDAO extends AccountOwnedEntityDAO { @@ -38,12 +38,12 @@ public class AccountPolicyDAO extends AccountOwnedEntityDAO { die("findSingleByAccount: More than 1 policy found for account " + accountUuid + " - " + found.size()); } - // If there's no policy, and the account is marked as deleted - just return not found: + // If there's no policy, create one. Note that is account is marked as deleted, the new policy will be with full + // deletion set in. + final var newPolicy = new AccountPolicy().setAccount(accountUuid); final var account = getConfiguration().getBean(AccountDAO.class).findById(accountUuid); - if (account.deleted()) throw notFoundEx(); - - // Else, create a policy for existing account: - return create(new AccountPolicy().setAccount(accountUuid)); + if (account.deleted()) newPolicy.setDeletionPolicy(full_delete); + return create(newPolicy); } } diff --git a/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json b/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json index 304317e5..3d6269ae 100644 --- a/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json +++ b/bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json @@ -74,9 +74,24 @@ }, { - "comment": "as root, look up account policy again - it should not be found now", + "comment": "as root, look up account policy again - it should recreated for this object with full deletion policy", "request": { "session": "rootSession", "uri": "users/{{user.uuid}}/policy" }, - "response": { "status": 404 } - } + "response": { "check": [{ "condition": "json.getDeletionPolicy().name() == 'full_delete'" }] } + }, + + { + "comment": "try deleting the same account again - expect fully deletion this time even without policy", + "request": { "uri": "users/{{user.uuid}}", "method": "delete" } + }, + { + "comment": "lookup user, expect there's no such user now", + "request": { "uri": "users/{{user.uuid}}" }, + "response": { "status": 404 } + }, + { + "comment": "as root, look up account policy again - not found, and account uuid reported as not found resource", + "request": { "session": "rootSession", "uri": "users/{{user.uuid}}/policy" }, + "response": { "status": 404, "check": [{ "condition": "json.get('resource') == user.getUuid()" }] } + } ] From 37c74f61147e471811169fc63ad688584454201b Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Wed, 15 Apr 2020 11:59:17 +0200 Subject: [PATCH 10/12] Organize imports --- .../src/test/java/bubble/test/system/AccountDeletionTest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java b/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java index d310ee51..38226c43 100644 --- a/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java +++ b/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java @@ -5,17 +5,13 @@ 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 { From 1d91d267fa7862563d4af560318f2617a2016dbd Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Wed, 15 Apr 2020 14:34:30 +0200 Subject: [PATCH 11/12] Set INFO level to log for test scripts --- bubble-server/src/main/resources/logback.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/bubble-server/src/main/resources/logback.xml b/bubble-server/src/main/resources/logback.xml index fadc1ef9..e3f4bc31 100644 --- a/bubble-server/src/main/resources/logback.xml +++ b/bubble-server/src/main/resources/logback.xml @@ -28,6 +28,7 @@ + From 9857b042f7248fa9bf8929d954b158528089e942 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Thu, 16 Apr 2020 14:25:54 +0200 Subject: [PATCH 12/12] Remove not needed before method in test --- .../java/bubble/test/system/AccountDeletionTest.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java b/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java index 38226c43..f389155a 100644 --- a/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java +++ b/bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java @@ -4,12 +4,8 @@ */ package bubble.test.system; -import bubble.dao.account.AccountDAO; -import bubble.model.account.Account; import bubble.test.ActivatedBubbleModelTestBase; import lombok.extern.slf4j.Slf4j; -import org.cobbzilla.wizard.model.HashedPassword; -import org.junit.Before; import org.junit.Test; @Slf4j @@ -17,13 +13,6 @@ public class AccountDeletionTest extends ActivatedBubbleModelTestBase { @Override protected String getManifest() { return "manifest-test"; } - @Before public void resetRootPassword() { - // reset root password, some tests change it - final AccountDAO accountDAO = getConfiguration().getBean(AccountDAO.class); - final Account rootUser = accountDAO.findFirstAdmin(); - accountDAO.update(rootUser.setHashedPassword(new HashedPassword(ROOT_PASSWORD))); - } - @Test public void testFullAccountDeletion() throws Exception { modelTest("account_deletion/full_delete_account"); } @Test public void testBlockAccountDeletion() throws Exception { modelTest("account_deletion/block_delete_account"); }