diff --git a/package.json b/package.json index beed55f..0acc5e5 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "scripts": { "start": "node --experimental-fetch ./", "dev": "LOG_LEVEL=debug yarn run watch & yarn run build:static:dev", - "test": "yarn run standard:check && yarn run rome:check && mocha --loader=esmock", "test": "yarn run lint && mocha --loader=esmock", "watch": "./node_modules/.bin/nodemon --config nodemon.json ./", "build": "yarn run build:server & yarn run build:static", diff --git a/src/server/index.js b/src/server/index.js index 19f217f..6990187 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -38,7 +38,7 @@ const generateAspeProfile = async (id) => { return doipjs.asp.fetchASPE(id) .then(profile => { - profile.addVerifier('keyoxide', `https://${process.env.DOMAIN}/${id}`) + profile.addVerifier('keyoxide', `${getScheme()}://${process.env.DOMAIN}/${id}`) profile = processAspProfile(profile) return profile }) diff --git a/test/server.test.js b/test/server.test.js index 192d53f..1674161 100644 --- a/test/server.test.js +++ b/test/server.test.js @@ -1,5 +1,6 @@ import 'chai/register-should.js' import esmock from 'esmock' +import * as doipjs from 'doipjs' import * as utils from '../src/server/utils.js' @@ -41,6 +42,8 @@ describe('server', function () { let index; let fingerprint; + /** @type {import('doipjs').Profile */ + let profile; this.beforeEach(async () => { @@ -48,36 +51,16 @@ describe('server', function () { fingerprint = '79895B2E0F87503F1DDE80B649765D7F0DDD9BD5' process.env.DOMAIN = "keyoxide.org" + const persona = new doipjs.Persona("test", [new doipjs.Claim('dns:domain.tld?type=TXT')]) + + profile = new doipjs.Profile(doipjs.enums.ProfileType.OPENPGP, fingerprint, [persona]) + // mock the appropriate pieces of our dependencies so we // can test just the `keyoxide.url` return value. index = await esmock('../src/server/index.js', { - '../src/server/keys.js': { + '../src/server/openpgpProfiles.js': { fetchHKP: () => { - return Promise.resolve({ - publicKey: { - getPrimaryUser: () => { - return { - user: { - userID: { - email: "example@example.net" - } - } - } - } - }, - fetchURL: 'example.com' - }) - } - }, - 'doipjs': { - keys: { - process: () => { - return { - key: {}, - 'fingerprint': fingerprint, - users: [] - } - } + return Promise.resolve(profile) } }, 'libravatar': { @@ -101,7 +84,7 @@ describe('server', function () { const local = await index.generateHKPProfile(fingerprint) // Assert - local.keyoxide.url.should.equal(`https://keyoxide.org/hkp/${fingerprint}`) + local.verifiers[0].url.should.equal(`https://keyoxide.org/hkp/${fingerprint}`) }) @@ -114,7 +97,7 @@ describe('server', function () { const local = await index.generateHKPProfile(fingerprint) // Assert - local.keyoxide.url.should.equal(`http://keyoxide.org/hkp/${fingerprint}`) + local.verifiers[0].url.should.equal(`http://keyoxide.org/hkp/${fingerprint}`) }) @@ -127,10 +110,10 @@ describe('server', function () { const local = await index.generateHKPProfile(fingerprint) // Assert - local.keyoxide.url.should.equal(`https://keyoxide.org/hkp/${fingerprint}`) + local.verifiers[0].url.should.equal(`https://keyoxide.org/hkp/${fingerprint}`) }) }) }) -}) \ No newline at end of file +})