Skip to content

Commit

Permalink
Change capitalisation of token header
Browse files Browse the repository at this point in the history
This fixes all the test failures seen here apart from the
job adapter ones:
https://app.circleci.com/pipelines/github/hashicorp/nomad/14501/workflows/01177cd9-a2ae-4fff-94ef-6b109b778123/jobs/134238

This was last toggled in #8035 and it’s frustrating to have
to change it back but I couldn’t find another way 😞
  • Loading branch information
backspace committed Jan 28, 2021
1 parent 9ee5c96 commit 1982358
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions ui/mirage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export default function() {
});

this.get('/acl/token/self', function({ tokens }, req) {
const secret = req.requestHeaders['x-nomad-token'];
const secret = req.requestHeaders['X-Nomad-Token'];
const tokenForSecret = tokens.findBy({ secretId: secret });

// Return the token if it exists
Expand All @@ -366,7 +366,7 @@ export default function() {

this.get('/acl/token/:id', function({ tokens }, req) {
const token = tokens.find(req.params.id);
const secret = req.requestHeaders['x-nomad-token'];
const secret = req.requestHeaders['X-Nomad-Token'];
const tokenForSecret = tokens.findBy({ secretId: secret });

// Return the token only if the request header matches the token
Expand All @@ -381,7 +381,7 @@ export default function() {

this.get('/acl/policy/:id', function({ policies, tokens }, req) {
const policy = policies.find(req.params.id);
const secret = req.requestHeaders['x-nomad-token'];
const secret = req.requestHeaders['X-Nomad-Token'];
const tokenForSecret = tokens.findBy({ secretId: secret });

if (req.params.id === 'anonymous') {
Expand Down
8 changes: 4 additions & 4 deletions ui/tests/unit/adapters/job-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ module('Unit | Adapter | Job', function(hooks) {
);
});

test('When there is no token set in the token service, no x-nomad-token header is set', async function(assert) {
test('When there is no token set in the token service, no X-Nomad-Token header is set', async function(assert) {
await this.initializeUI();

const { pretender } = this.server;
Expand All @@ -143,12 +143,12 @@ module('Unit | Adapter | Job', function(hooks) {
await settled();

assert.notOk(
pretender.handledRequests.mapBy('requestHeaders').some(headers => headers['x-nomad-token']),
pretender.handledRequests.mapBy('requestHeaders').some(headers => headers['X-Nomad-Token']),
'No token header present on either job request'
);
});

test('When a token is set in the token service, then x-nomad-token header is set', async function(assert) {
test('When a token is set in the token service, then X-Nomad-Token header is set', async function(assert) {
await this.initializeUI();

const { pretender } = this.server;
Expand All @@ -162,7 +162,7 @@ module('Unit | Adapter | Job', function(hooks) {
assert.ok(
pretender.handledRequests
.mapBy('requestHeaders')
.every(headers => headers['x-nomad-token'] === secret),
.every(headers => headers['X-Nomad-Token'] === secret),
'The token header is present on both job requests'
);
});
Expand Down

0 comments on commit 1982358

Please sign in to comment.