Skip to content

Commit 6c7201e

Browse files
committed
fix hapi test
1 parent 729e800 commit 6c7201e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/hapi-asap/test/index_test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,25 @@ import { expect } from 'chai';
33
import { createAuthHeaderGenerator } from '@ordermentum/asap-core';
44
import { publicKey, privateKeyPem } from '@ordermentum/asap-test-helpers';
55
import Hapi from '@hapi/hapi';
6-
import registerPlugin from '../src/middleware';
6+
import { plugin as hapiAsap } from '../src/middleware';
77

88
async function init() {
99
const server = Hapi.server({
10-
port: 3000,
10+
port: 10000,
1111
host: 'localhost',
12+
plugins: [],
1213
});
1314

14-
await server.register(registerPlugin);
15+
await server.register({
16+
plugin: hapiAsap,
17+
options: {
18+
keyLoader: (_key: string) => Promise.resolve(publicKey),
19+
resourceServerAudience: 'test',
20+
maxLifeTimeSeconds: 60,
21+
},
22+
});
1523

24+
// await server.register(registerPlugin);
1625
server.auth.strategy('asap', 'hapi-asap', {
1726
keyLoader: (_key: string) => Promise.resolve(publicKey),
1827
resourceServerAudience: 'test',
@@ -35,6 +44,7 @@ async function init() {
3544
return `Ok`;
3645
}
3746

47+
// @ts-expect-error
3848
return `${asapClaims?.aud}`;
3949
},
4050
});
@@ -50,6 +60,7 @@ async function init() {
5060
path: '/required',
5161
handler(request, h) {
5262
const { asapClaims } = request.auth.artifacts ?? {};
63+
// @ts-expect-error
5364
return `test ${asapClaims?.aud}`;
5465
},
5566
});

0 commit comments

Comments
 (0)