Skip to content

Commit

Permalink
Merge 76af28a into backport/fix-exec-reverse-proxy/absolutely-normal-…
Browse files Browse the repository at this point in the history
…buzzard
  • Loading branch information
hc-github-team-nomad-core authored Jun 6, 2022
2 parents 341f000 + 76af28a commit 9f2eb9e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ui/tests/acceptance/proxy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module('Acceptance | reverse proxy', function (hooks) {
managementToken = server.create('token');

// Prepare a setRequestHeader that accumulate headers already set. This is to avoid double setting X-Nomad-Token
this._originalXMLHttpRequestSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
this._originalXMLHttpRequestSetRequestHeader =
XMLHttpRequest.prototype.setRequestHeader;
(function (setRequestHeader) {
XMLHttpRequest.prototype.setRequestHeader = function (header, value) {
if (!this.headers) {
Expand All @@ -39,14 +40,15 @@ module('Acceptance | reverse proxy', function (hooks) {
XMLHttpRequest.prototype.send = function (data) {
if (!this.headers || !('X-Nomad-Token' in this.headers)) {
this.setRequestHeader('X-Nomad-Token', managementToken.secretId);
}
}
send.call(this, data);
};
})(this._originalXMLHttpRequestSend);
});

hooks.afterEach(function () {
XMLHttpRequest.prototype.setRequestHeader = this._originalXMLHttpRequestSetRequestHeader;
XMLHttpRequest.prototype.setRequestHeader =
this._originalXMLHttpRequestSetRequestHeader;
XMLHttpRequest.prototype.send = this._originalXMLHttpRequestSend;
});

Expand Down

0 comments on commit 9f2eb9e

Please sign in to comment.