Skip to content

Commit

Permalink
backport of commit 76af28a
Browse files Browse the repository at this point in the history
  • Loading branch information
legege committed May 10, 2022
1 parent 861f9e9 commit bc082ab
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 bc082ab

Please sign in to comment.