Kaynağa Gözat

Add back creation of policy for deleted account

tags/v0.10.5
Kristijan Mitrovic 4 yıl önce
ebeveyn
işleme
291bd841ed
2 değiştirilmiş dosya ile 24 ekleme ve 9 silme
  1. +6
    -6
      bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java
  2. +18
    -3
      bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json

+ 6
- 6
bubble-server/src/main/java/bubble/dao/account/AccountPolicyDAO.java Dosyayı Görüntüle

@@ -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<AccountPolicy> {
@@ -38,12 +38,12 @@ public class AccountPolicyDAO extends AccountOwnedEntityDAO<AccountPolicy> {
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);
}

}

+ 18
- 3
bubble-server/src/test/resources/models/tests/account_deletion/block_delete_account.json Dosyayı Görüntüle

@@ -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()" }] }
}
]

Yükleniyor…
İptal
Kaydet