forked from Mirrors/keyoxide-web
Test adjustments for doipjs 1.0 and v3 API
This commit is contained in:
parent
0b9a00c69e
commit
03d7bf3446
3 changed files with 14 additions and 32 deletions
|
@ -45,7 +45,6 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node --experimental-fetch ./",
|
"start": "node --experimental-fetch ./",
|
||||||
"dev": "LOG_LEVEL=debug yarn run watch & yarn run build:static:dev",
|
"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",
|
"test": "yarn run lint && mocha --loader=esmock",
|
||||||
"watch": "./node_modules/.bin/nodemon --config nodemon.json ./",
|
"watch": "./node_modules/.bin/nodemon --config nodemon.json ./",
|
||||||
"build": "yarn run build:server & yarn run build:static",
|
"build": "yarn run build:server & yarn run build:static",
|
||||||
|
|
|
@ -38,7 +38,7 @@ const generateAspeProfile = async (id) => {
|
||||||
|
|
||||||
return doipjs.asp.fetchASPE(id)
|
return doipjs.asp.fetchASPE(id)
|
||||||
.then(profile => {
|
.then(profile => {
|
||||||
profile.addVerifier('keyoxide', `https://${process.env.DOMAIN}/${id}`)
|
profile.addVerifier('keyoxide', `${getScheme()}://${process.env.DOMAIN}/${id}`)
|
||||||
profile = processAspProfile(profile)
|
profile = processAspProfile(profile)
|
||||||
return profile
|
return profile
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'chai/register-should.js'
|
import 'chai/register-should.js'
|
||||||
import esmock from 'esmock'
|
import esmock from 'esmock'
|
||||||
|
import * as doipjs from 'doipjs'
|
||||||
|
|
||||||
import * as utils from '../src/server/utils.js'
|
import * as utils from '../src/server/utils.js'
|
||||||
|
|
||||||
|
@ -41,6 +42,8 @@ describe('server', function () {
|
||||||
|
|
||||||
let index;
|
let index;
|
||||||
let fingerprint;
|
let fingerprint;
|
||||||
|
/** @type {import('doipjs').Profile */
|
||||||
|
let profile;
|
||||||
|
|
||||||
this.beforeEach(async () => {
|
this.beforeEach(async () => {
|
||||||
|
|
||||||
|
@ -48,36 +51,16 @@ describe('server', function () {
|
||||||
fingerprint = '79895B2E0F87503F1DDE80B649765D7F0DDD9BD5'
|
fingerprint = '79895B2E0F87503F1DDE80B649765D7F0DDD9BD5'
|
||||||
process.env.DOMAIN = "keyoxide.org"
|
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
|
// mock the appropriate pieces of our dependencies so we
|
||||||
// can test just the `keyoxide.url` return value.
|
// can test just the `keyoxide.url` return value.
|
||||||
index = await esmock('../src/server/index.js', {
|
index = await esmock('../src/server/index.js', {
|
||||||
'../src/server/keys.js': {
|
'../src/server/openpgpProfiles.js': {
|
||||||
fetchHKP: () => {
|
fetchHKP: () => {
|
||||||
return Promise.resolve({
|
return Promise.resolve(profile)
|
||||||
publicKey: {
|
|
||||||
getPrimaryUser: () => {
|
|
||||||
return {
|
|
||||||
user: {
|
|
||||||
userID: {
|
|
||||||
email: "example@example.net"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fetchURL: 'example.com'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'doipjs': {
|
|
||||||
keys: {
|
|
||||||
process: () => {
|
|
||||||
return {
|
|
||||||
key: {},
|
|
||||||
'fingerprint': fingerprint,
|
|
||||||
users: []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'libravatar': {
|
'libravatar': {
|
||||||
|
@ -101,7 +84,7 @@ describe('server', function () {
|
||||||
const local = await index.generateHKPProfile(fingerprint)
|
const local = await index.generateHKPProfile(fingerprint)
|
||||||
|
|
||||||
// Assert
|
// 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)
|
const local = await index.generateHKPProfile(fingerprint)
|
||||||
|
|
||||||
// Assert
|
// 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)
|
const local = await index.generateHKPProfile(fingerprint)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
local.keyoxide.url.should.equal(`https://keyoxide.org/hkp/${fingerprint}`)
|
local.verifiers[0].url.should.equal(`https://keyoxide.org/hkp/${fingerprint}`)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue