Purge old/unverified keys or keys without an uploaded attribute.
This commit is contained in:
@@ -104,6 +104,62 @@ describe('Public Key Integration Tests', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('_purgeOldUnverified', () => {
|
||||
let key;
|
||||
|
||||
beforeEach(async () => {
|
||||
key = pgp.parseKey(publicKeyArmored);
|
||||
});
|
||||
|
||||
it('should work for no keys', async () => {
|
||||
const r = await publicKey._purgeOldUnverified();
|
||||
expect(r.deletedCount).to.equal(0);
|
||||
});
|
||||
|
||||
it('should not remove a current unverified key', async () => {
|
||||
await publicKey._persisKey(key);
|
||||
const r = await publicKey._purgeOldUnverified();
|
||||
expect(r.deletedCount).to.equal(0);
|
||||
});
|
||||
|
||||
it('should not remove a current verified key', async () => {
|
||||
key.userIds[0].verified = true;
|
||||
await publicKey._persisKey(key);
|
||||
const r = await publicKey._purgeOldUnverified();
|
||||
expect(r.deletedCount).to.equal(0);
|
||||
});
|
||||
|
||||
it('should not remove an old verified key', async () => {
|
||||
key.uploaded.setDate(key.uploaded.getDate() - 31);
|
||||
key.userIds[0].verified = true;
|
||||
await publicKey._persisKey(key);
|
||||
const r = await publicKey._purgeOldUnverified();
|
||||
expect(r.deletedCount).to.equal(0);
|
||||
});
|
||||
|
||||
it('should remove an old unverified key', async () => {
|
||||
key.uploaded.setDate(key.uploaded.getDate() - 31);
|
||||
await publicKey._persisKey(key);
|
||||
const r = await publicKey._purgeOldUnverified();
|
||||
expect(r.deletedCount).to.equal(1);
|
||||
});
|
||||
|
||||
it('should remove an unverified key with no uploaded attribute', async () => {
|
||||
delete key.uploaded;
|
||||
await publicKey._persisKey(key);
|
||||
const r = await publicKey._purgeOldUnverified();
|
||||
expect(r.deletedCount).to.equal(1);
|
||||
});
|
||||
|
||||
it('should not remove a verified key with no uploaded attribute', async () => {
|
||||
key.userIds[0].verified = true;
|
||||
delete key.uploaded;
|
||||
await publicKey._persisKey(key);
|
||||
const r = await publicKey._purgeOldUnverified();
|
||||
expect(r.deletedCount).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('verify', () => {
|
||||
it('should update the document', async () => {
|
||||
await publicKey.put({publicKeyArmored, primaryEmail, origin});
|
||||
|
||||
Reference in New Issue
Block a user