Skip to content

Commit 43c28b5

Browse files
committed
adjust tests
1 parent 08a8c24 commit 43c28b5

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

test/index.entitlement.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ test('authentication does fail – invalid token', async (t) => {
8484

8585
t.truthy(res)
8686
t.is(res.statusCode, 401)
87-
t.is(res.headers['www-authenticate'], 'Bearer strategy="keycloak-jwt", error="Retrieving the RPT failed"')
87+
t.is(res.headers['www-authenticate'], 'Bearer strategy="keycloak-jwt", error="Invalid credentials", reason="Retrieving the RPT failed"')
8888
})
8989

9090
test('authentication does fail – invalid header', async (t) => {

test/index.verify.buffer.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test('authentication does fail – expired token', async (t) => {
4949

5050
t.truthy(res)
5151
t.is(res.statusCode, 401)
52-
t.is(res.headers['www-authenticate'], 'Bearer strategy="keycloak-jwt", error="invalid token (expired)"')
52+
t.is(res.headers['www-authenticate'], 'Bearer strategy="keycloak-jwt", error="Invalid credentials", reason="invalid token (expired)"')
5353
})
5454

5555
test('authentication does fail – invalid header', async (t) => {

test/index.verify.jwk.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ test('authentication does fail – expired token', async (t) => {
5353

5454
t.truthy(res)
5555
t.is(res.statusCode, 401)
56-
t.is(res.headers['www-authenticate'], 'Bearer strategy="keycloak-jwt", error="invalid token (expired)"')
56+
t.is(res.headers['www-authenticate'], 'Bearer strategy="keycloak-jwt", error="Invalid credentials", reason="invalid token (expired)"')
5757
})
5858

5959
test('authentication does fail – invalid header', async (t) => {

test/index.verify.pem.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test('authentication does fail – expired token', async (t) => {
4949

5050
t.truthy(res)
5151
t.is(res.statusCode, 401)
52-
t.is(res.headers['www-authenticate'], 'Bearer strategy="keycloak-jwt", error="invalid token (expired)"')
52+
t.is(res.headers['www-authenticate'], 'Bearer strategy="keycloak-jwt", error="Invalid credentials", reason="invalid token (expired)"')
5353
})
5454

5555
test('authentication does fail – invalid header', async (t) => {

test/utils.spec.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test('get boom error with default message', (t) => {
1111
})
1212

1313
test('get boom error with reason', (t) => {
14-
const result = utils.raiseUnauthorized(null, null, 'foobar')
14+
const result = utils.raiseUnauthorized(null, 'foobar')
1515
t.truthy(result)
1616
t.deepEqual(result, boom.unauthorized(undefined, 'Bearer', {
1717
strategy: 'keycloak-jwt',
@@ -20,27 +20,28 @@ test('get boom error with reason', (t) => {
2020
})
2121

2222
test('get boom error with custom scheme', (t) => {
23-
const result = utils.raiseUnauthorized(null, null, null, 'custom')
23+
const result = utils.raiseUnauthorized(null, null, 'custom')
2424
t.truthy(result)
2525
t.deepEqual(result, boom.unauthorized(undefined, 'custom', {
2626
strategy: 'keycloak-jwt'
2727
}))
2828
})
2929

3030
test('get boom error with default message', (t) => {
31-
const result = utils.raiseUnauthorized(undefined, 'foobar')
31+
const result = utils.raiseUnauthorized('foobar')
3232
t.truthy(result)
33-
t.deepEqual(result, boom.unauthorized('foobar', 'Bearer', {
34-
strategy: 'keycloak-jwt'
33+
t.deepEqual(result, boom.unauthorized(null, 'Bearer', {
34+
strategy: 'keycloak-jwt',
35+
error: 'foobar'
3536
}))
3637
})
3738

3839
test('get boom error with error message', (t) => {
39-
const mockErr = new Error('barfoo')
40-
const result = utils.raiseUnauthorized(mockErr, 'foobar')
40+
const result = utils.raiseUnauthorized('foobar')
4141
t.truthy(result)
42-
t.deepEqual(result, boom.unauthorized(mockErr.message, 'Bearer', {
43-
strategy: 'keycloak-jwt'
42+
t.deepEqual(result, boom.unauthorized(null, 'Bearer', {
43+
strategy: 'keycloak-jwt',
44+
error: 'foobar'
4445
}))
4546
})
4647

0 commit comments

Comments
 (0)