Skip to content

Commit

Permalink
Test for www-authenticate header
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrancis committed Aug 2, 2024
1 parent b1c1ffc commit 34fb33f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/integration/oauth-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ describe('oauth/', function () {
customCallbackHandler = customCallbackHandlerProvided || null;
}

it('rejects request with no JWT', async () => {
setupOAuth();

// Try using the access token
let res = await chai
.request(server)
.get(Constants.THINGS_PATH)
.set('Accept', 'application/json')
expect(res.status).toEqual(401);
expect(res.get('WWW-Authenticate')).toEqual('Bearer');
});

it('performs simple authorization', async () => {
setupOAuth();

Expand Down Expand Up @@ -204,6 +216,7 @@ describe('oauth/', function () {
.set('Accept', 'application/json')
.set(...headerAuth(jwt));
expect(err.status).toEqual(403);
expect(err.header).toHaveProperty('www-authenticate');

res = await chai
.request(server)
Expand Down Expand Up @@ -489,6 +502,7 @@ describe('oauth/', function () {
.set('Accept', 'application/json')
.set(...headerAuth(jwt));
expect(err.status).toEqual(403);
expect(err.header).toHaveProperty('www-authenticate');
});

it('rejects use of authorization code as access token', async () => {
Expand Down Expand Up @@ -522,5 +536,6 @@ describe('oauth/', function () {
.set('Accept', 'application/json')
.set(...headerAuth(jwt));
expect(err.status).toEqual(403);
expect(err.header).toHaveProperty('www-authenticate');
});
});

0 comments on commit 34fb33f

Please sign in to comment.