From afacbf413fc39ae48a43a6ed25a485ba87a7552f Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Tue, 22 Aug 2017 11:26:12 +0800 Subject: [PATCH] Add `uploaded` date attribute to PGP key document in MongoDB --- src/service/pgp.js | 1 + test/unit/pgp-test.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/service/pgp.js b/src/service/pgp.js index 95c8a2f..3e525c9 100644 --- a/src/service/pgp.js +++ b/src/service/pgp.js @@ -72,6 +72,7 @@ class PGP { fingerprint, userIds, created: primaryKey.created, + uploaded: new Date(), algorithm: primaryKey.algorithm, keySize: primaryKey.getBitSize(), publicKeyArmored diff --git a/test/unit/pgp-test.js b/test/unit/pgp-test.js index 43e386f..ffa72fb 100644 --- a/test/unit/pgp-test.js +++ b/test/unit/pgp-test.js @@ -94,6 +94,7 @@ describe('PGP Unit Tests', () => { expect(params.userIds[0].name).to.equal('safewithme testuser'); expect(params.userIds[0].email).to.equal('safewithme.testuser@gmail.com'); expect(params.created.getTime()).to.exist; + expect(params.uploaded.getTime()).to.exist; expect(params.algorithm).to.equal('rsa_encrypt_sign'); expect(params.keySize).to.equal(2048); expect(params.publicKeyArmored).to.equal(key1Armored); @@ -105,6 +106,7 @@ describe('PGP Unit Tests', () => { expect(params.fingerprint).to.equal('e3317db04d3958fd5f662c37b8e4105cc9dedc77'); expect(params.userIds.length).to.equal(1); expect(params.created.getTime()).to.exist; + expect(params.uploaded.getTime()).to.exist; expect(params.algorithm).to.equal('rsa_encrypt_sign'); expect(params.keySize).to.equal(4096); expect(params.publicKeyArmored).to.equal(pgp.trimKey(key2Armored)); @@ -116,6 +118,7 @@ describe('PGP Unit Tests', () => { expect(params.fingerprint).to.equal('04062c70b446e33016e219a74001a127a90de8e1'); expect(params.userIds.length).to.equal(4); expect(params.created.getTime()).to.exist; + expect(params.uploaded.getTime()).to.exist; expect(params.algorithm).to.equal('rsa_encrypt_sign'); expect(params.keySize).to.equal(4096); expect(params.publicKeyArmored).to.equal(pgp.trimKey(key3Armored));