-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7592 from ycombinator/call-with-request/passthru-…
…all-headers [4.x] Make callWithRequest pass through all headers
- Loading branch information
Showing
2 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/plugins/elasticsearch/lib/__tests__/call_with_request.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import expect from 'expect.js'; | ||
import callWithRequest from '../call_with_request'; | ||
|
||
describe('call_with_request', () => { | ||
let mockClient; | ||
|
||
beforeEach(() => { | ||
mockClient = { | ||
search(params) { | ||
this.params = params; | ||
return Promise.resolve(this); | ||
} | ||
}; | ||
}); | ||
|
||
it ('passes through all headers', () => { | ||
const mockRequest = { | ||
headers: { | ||
authorization: 'Basic QWxhZGRpbjpPcGVuU2VzYW1l', | ||
'kbn-version': '4.6.0' | ||
} | ||
}; | ||
return callWithRequest(mockClient)(mockRequest, 'search') | ||
.then(() => { | ||
expect(mockClient.params.headers).to.be(mockRequest.headers); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters