Skip to content

Commit 9e5c889

Browse files
committed
Fix incorrect entity error message. Closes hapijs#3101
1 parent ed195fa commit 9e5c889

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

lib/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ internals.Authenticator = class {
458458

459459
// Entity error
460460

461-
if (requestEntity === 'user') {
461+
if (requestEntity === 'app') {
462462
request._log(['auth', 'entity', 'user', 'error', name]);
463463
return next(Boom.forbidden('Application credentials cannot be used on a user endpoint'));
464464
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "hapi",
33
"description": "HTTP Server framework",
44
"homepage": "http://hapijs.com",
5-
"version": "13.2.1",
5+
"version": "13.2.2",
66
"repository": {
77
"type": "git",
88
"url": "git://github.com/hapijs/hapi"

test/auth.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ describe('authentication', () => {
10011001
server.inject({ url: '/test', headers: { authorization: 'Custom steve' } }, (res) => {
10021002

10031003
expect(res.statusCode).to.equal(403);
1004+
expect(res.result.message).to.equal('Insufficient scope');
10041005
done();
10051006
});
10061007
});
@@ -1030,6 +1031,7 @@ describe('authentication', () => {
10301031
server.inject({ url: '/', headers: { authorization: 'Custom steve' } }, (res) => {
10311032

10321033
expect(res.statusCode).to.equal(403);
1034+
expect(res.result.message).to.equal('Insufficient scope');
10331035
done();
10341036
});
10351037
});
@@ -1059,6 +1061,7 @@ describe('authentication', () => {
10591061
server.inject({ url: '/', headers: { authorization: 'Custom steve' } }, (res) => {
10601062

10611063
expect(res.statusCode).to.equal(403);
1064+
expect(res.result.message).to.equal('Insufficient scope');
10621065
done();
10631066
});
10641067
});
@@ -1088,6 +1091,7 @@ describe('authentication', () => {
10881091
server.inject({ url: '/', headers: { authorization: 'Custom steve' } }, (res) => {
10891092

10901093
expect(res.statusCode).to.equal(403);
1094+
expect(res.result.message).to.equal('Insufficient scope');
10911095
done();
10921096
});
10931097
});
@@ -1123,6 +1127,8 @@ describe('authentication', () => {
11231127
server.inject({ url: '/', headers: { authorization: 'Custom steve' } }, (res1) => {
11241128

11251129
expect(res1.statusCode).to.equal(403);
1130+
expect(res1.result.message).to.equal('Insufficient scope');
1131+
11261132
server.inject({ url: '/', headers: { authorization: 'Custom john' } }, (res2) => {
11271133

11281134
expect(res2.statusCode).to.equal(200);
@@ -1162,6 +1168,8 @@ describe('authentication', () => {
11621168
server.inject({ url: '/', headers: { authorization: 'Custom steve' } }, (res1) => {
11631169

11641170
expect(res1.statusCode).to.equal(403);
1171+
expect(res1.result.message).to.equal('Insufficient scope');
1172+
11651173
server.inject({ url: '/', headers: { authorization: 'Custom john' } }, (res2) => {
11661174

11671175
expect(res2.statusCode).to.equal(200);
@@ -1204,6 +1212,8 @@ describe('authentication', () => {
12041212
server.inject({ url: '/', headers: { authorization: 'Custom steve' } }, (res1) => {
12051213

12061214
expect(res1.statusCode).to.equal(403);
1215+
expect(res1.result.message).to.equal('Insufficient scope');
1216+
12071217
server.inject({ url: '/', headers: { authorization: 'Custom john' } }, (res2) => {
12081218

12091219
expect(res2.statusCode).to.equal(200);
@@ -1213,9 +1223,12 @@ describe('authentication', () => {
12131223
server.inject({ url: '/', headers: { authorization: 'Custom lucy' } }, (res4) => {
12141224

12151225
expect(res4.statusCode).to.equal(403);
1226+
expect(res4.result.message).to.equal('Insufficient scope');
1227+
12161228
server.inject({ url: '/', headers: { authorization: 'Custom larry' } }, (res5) => {
12171229

12181230
expect(res5.statusCode).to.equal(403);
1231+
expect(res5.result.message).to.equal('Insufficient scope');
12191232
done();
12201233
});
12211234
});
@@ -1249,6 +1262,7 @@ describe('authentication', () => {
12491262
server.inject({ url: '/', headers: { authorization: 'Custom steve' } }, (res) => {
12501263

12511264
expect(res.statusCode).to.equal(403);
1265+
expect(res.result.message).to.equal('Insufficient scope');
12521266
done();
12531267
});
12541268
});
@@ -1378,6 +1392,7 @@ describe('authentication', () => {
13781392
server.inject({ url: '/', headers: { authorization: 'Custom steve' } }, (res) => {
13791393

13801394
expect(res.statusCode).to.equal(403);
1395+
expect(res.result.message).to.equal('Insufficient scope');
13811396
done();
13821397
});
13831398
});
@@ -1459,6 +1474,7 @@ describe('authentication', () => {
14591474
server.inject({ url: '/', headers: { authorization: 'Custom client' } }, (res) => {
14601475

14611476
expect(res.statusCode).to.equal(403);
1477+
expect(res.result.message).to.equal('Application credentials cannot be used on a user endpoint');
14621478
done();
14631479
});
14641480
});
@@ -1513,6 +1529,7 @@ describe('authentication', () => {
15131529
server.inject({ url: '/', headers: { authorization: 'Custom steve' } }, (res) => {
15141530

15151531
expect(res.statusCode).to.equal(403);
1532+
expect(res.result.message).to.equal('User credentials cannot be used on an application endpoint');
15161533
done();
15171534
});
15181535
});

0 commit comments

Comments
 (0)