Skip to content

Commit

Permalink
fix: Fixed broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zoemaas committed Oct 22, 2024
1 parent 547d771 commit 56ce96f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 48 deletions.
16 changes: 4 additions & 12 deletions packages/oidf-client/__tests__/localAgent.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import {createAgent} from '@veramo/core'
import oidfClientAgentLogic from './shared/oidfClientAgentLogic'
import {IOIDFClient, OIDFClient} from "../src";
import {CryptoPlatformTestCallback} from "./shared/CryptoPlatformTestCallback";
import { createObjects, getConfig } from '../../agent-config/dist'

jest.setTimeout(60000)

let agent: any

const setup = async (): Promise<boolean> => {
//const config = await getConfig('packages/oidf-client/agent.yml')
//const { localAgent } = await createObjects(config, { localAgent: '/agent' })
agent = createAgent<IOIDFClient>({
plugins: [
new OIDFClient({
cryptoServiceCallback: new CryptoPlatformTestCallback()
})
]
})
const config = await getConfig('packages/oidf-client/agent.yml')
const { localAgent } = await createObjects(config, { localAgent: '/agent' })
agent = localAgent

return true
}
Expand Down
6 changes: 4 additions & 2 deletions packages/oidf-client/__tests__/restAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import {Server} from 'http'
import {createAgent, IAgent, IAgentOptions} from '@veramo/core'
import {AgentRestClient} from '@veramo/remote-client'
import {AgentRouter, RequestWithAgentRouter} from '@veramo/remote-server'
import {createObjects, getConfig} from '../../agent-config/dist'
import oidfClientAgentLogic from './shared/oidfClientAgentLogic'
import {createObjects, getConfig} from '../../agent-config/dist'
import {IOIDFClient} from "../src";
import {IJwtService} from "@sphereon/ssi-sdk-ext.jwt-service";

jest.setTimeout(60000)

Expand All @@ -18,7 +19,7 @@ let serverAgent: IAgent
let restServer: Server

const getAgent = (options?: IAgentOptions) =>
createAgent<IOIDFClient>({
createAgent<IOIDFClient & IJwtService>({
...options,
plugins: [
new AgentRestClient({
Expand All @@ -29,6 +30,7 @@ const getAgent = (options?: IAgentOptions) =>
],
})


const setup = async (): Promise<boolean> => {
const config = await getConfig('packages/oidf-client/agent.yml')
const { agent } = await createObjects(config, { agent: '/agent' })
Expand Down
34 changes: 8 additions & 26 deletions packages/oidf-client/__tests__/shared/oidfClientAgentLogic.ts

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions packages/oidf-client/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ constants:
secretKey: 29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c
methods:
- resolveTrustChain
- registerCryptoServiceCallback
- signJwt
- verifyJwt

server:
Expand Down Expand Up @@ -72,7 +72,5 @@ agent:
$args:
- schemaValidation: false
plugins:
- $require: ./packages/oidf-client/dist#OIDFClient
$args:
- cryptoServiceCallback:
$require: './packages/oidf-client?t=class#CryptoPlatformTestCallback'
- $require: '@sphereon/ssi-sdk-ext.jwt-service#JwtService'
- $require: ./packages/oidf-client/dist#OIDFClient
13 changes: 10 additions & 3 deletions packages/oidf-client/src/agent/OIDFClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
} from "../../../../../OpenID-Federation/build/js/packages/openid-federation-modules-openid-federation-client";
import {schema} from "../index";
import FederationClient = com.sphereon.oid.fed.client.FederationClient;
import CryptoService = com.sphereon.oid.fed.client.crypto.CryptoService;

export const oidfClientMethods: Array<string> = [
'resolveTrustChain',
Expand All @@ -31,9 +30,17 @@ export class OIDFClient implements IAgentPlugin {

constructor(args?: OIDFClientArgs) {
const { cryptoServiceCallback } = { ...args }
this.oidfClient = new FederationClient()
if (cryptoServiceCallback) {
CryptoService.register(cryptoServiceCallback)
this.oidfClient = new FederationClient(null, cryptoServiceCallback)
} else {
// FIXME pass in the actual verification function
this.oidfClient = new FederationClient(
null, {
q3t: (jwt: string, key: any): Promise<boolean> => {
console.log(`${jwt}:${key} -> Custom callback function reached`)
return Promise.resolve(true)
}
})
}
}

Expand Down

0 comments on commit 56ce96f

Please sign in to comment.