-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to provide a custom http agent and disable the auth header (#284)
- Loading branch information
Showing
14 changed files
with
350 additions
and
66 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
export default '1.1.0' | ||
export default '1.2.0' |
33 changes: 33 additions & 0 deletions
33
packages/client-node/__tests__/integration/node_custom_http_agent.test.ts
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,33 @@ | ||
import { TestEnv, whenOnEnv } from '@test/utils' | ||
import http from 'http' | ||
import Http from 'http' | ||
import { createClient } from '../../src' | ||
|
||
/** HTTPS agent tests are in tls.test.ts as it requires a secure connection. */ | ||
describe('[Node.js] custom HTTP agent', () => { | ||
let httpRequestStub: jasmine.Spy<typeof Http.request> | ||
beforeEach(() => { | ||
httpRequestStub = spyOn(Http, 'request').and.callThrough() | ||
}) | ||
|
||
// disabled with Cloud as it uses a simple HTTP agent | ||
whenOnEnv(TestEnv.LocalSingleNode, TestEnv.LocalCluster).it( | ||
'should use provided http agent instead of the default one', | ||
async () => { | ||
const agent = new http.Agent({ | ||
maxFreeSockets: 5, | ||
}) | ||
const client = createClient({ | ||
http_agent: agent, | ||
}) | ||
const rs = await client.query({ | ||
query: 'SELECT 42 AS result', | ||
format: 'JSONEachRow', | ||
}) | ||
expect(await rs.json()).toEqual([{ result: 42 }]) | ||
expect(httpRequestStub).toHaveBeenCalledTimes(1) | ||
const callArgs = httpRequestStub.calls.mostRecent().args | ||
expect(callArgs[1].agent).toBe(agent) | ||
}, | ||
) | ||
}) |
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
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
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
Oops, something went wrong.