From 0de88b5c84d719764c01d497d00563b939aca46b Mon Sep 17 00:00:00 2001 From: Kevin Greene Date: Thu, 16 Nov 2017 13:50:23 -0800 Subject: [PATCH 1/2] [thrift] connections should take options for http or https --- types/thrift/index.d.ts | 3 ++- types/thrift/thrift-tests.ts | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/types/thrift/index.d.ts b/types/thrift/index.d.ts index a082c309ad..c5cb6f20a3 100644 --- a/types/thrift/index.d.ts +++ b/types/thrift/index.d.ts @@ -10,6 +10,7 @@ import * as net from 'net'; import * as http from 'http'; +import * as https from 'https'; import * as tls from 'tls'; // Thrift re-exports node-int64 and Q @@ -249,7 +250,7 @@ export interface ConnectOptions { retry_max_delay?: number; connect_timeout?: number; timeout?: number; - nodeOptions?: http.RequestOptions; + nodeOptions?: http.RequestOptions | https.RequestOptions; } export interface WSConnectOptions { diff --git a/types/thrift/thrift-tests.ts b/types/thrift/thrift-tests.ts index f888f28086..181ebeb20e 100644 --- a/types/thrift/thrift-tests.ts +++ b/types/thrift/thrift-tests.ts @@ -1,4 +1,5 @@ import * as http from 'http'; +import * as https from 'https'; import { createConnection, @@ -43,18 +44,33 @@ const mockGeneratedService = { createServer(mockGeneratedService, mockServiceHandlers); -const nodeOptions: http.RequestOptions = { +const httpOptions: http.RequestOptions = { timeout: 10000, headers: { 'Content-Type': 'application/octet-stream' } }; +const httpsOptions: https.RequestOptions = { + timeout: 10000, + headers: { + 'Content-Type': 'application/octet-stream' + }, + secureProtocol: 'SSLv3_method' +}; + const clientConnection = createConnection('0.0.0.0', 1234, { - transport: TBufferedTransport, - protocol: TBinaryProtocol, - nodeOptions + transport: TBufferedTransport, + protocol: TBinaryProtocol, + nodeOptions: httpOptions }); + +const secureConnection = createConnection('0.0.0.0', 1234, { + transport: TBufferedTransport, + protocol: TBinaryProtocol, + nodeOptions: httpsOptions +}) + createClient(mockGeneratedService, clientConnection); const mockBuffer: Buffer = Buffer.alloc(8); From 42f4193dbc09aec2ac3fa690ef00afba1d66b53f Mon Sep 17 00:00:00 2001 From: Kevin Greene Date: Thu, 16 Nov 2017 14:19:40 -0800 Subject: [PATCH 2/2] Fixing tests --- types/thrift/thrift-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/thrift/thrift-tests.ts b/types/thrift/thrift-tests.ts index 181ebeb20e..385a1051b9 100644 --- a/types/thrift/thrift-tests.ts +++ b/types/thrift/thrift-tests.ts @@ -67,9 +67,9 @@ const clientConnection = createConnection('0.0.0.0', 1234, { const secureConnection = createConnection('0.0.0.0', 1234, { transport: TBufferedTransport, - protocol: TBinaryProtocol, - nodeOptions: httpsOptions -}) + protocol: TBinaryProtocol, + nodeOptions: httpsOptions +}); createClient(mockGeneratedService, clientConnection);