Skip to content

Commit f169e01

Browse files
fix(ClientRequest): mock the TLSSocket.getCipher method (#688)
Co-authored-by: Artem Zakharchenko <kettanaito@gmail.com>
1 parent c7b48ab commit f169e01

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/interceptors/ClientRequest/MockHttpSocket.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export class MockHttpSocket extends MockSocket {
146146
Reflect.set(this, 'getProtocol', () => 'TLSv1.3')
147147
Reflect.set(this, 'getSession', () => undefined)
148148
Reflect.set(this, 'isSessionReused', () => false)
149+
Reflect.set(this, 'getCipher', () => ({ name: 'AES256-SHA', standardName: 'TLS_RSA_WITH_AES_256_CBC_SHA', version: 'TLSv1.3' }))
149150
}
150151
}
151152

@@ -258,6 +259,7 @@ export class MockHttpSocket extends MockSocket {
258259
'getProtocol',
259260
'getSession',
260261
'isSessionReused',
262+
'getCipher'
261263
]
262264

263265
tlsProperties.forEach((propertyName) => {

test/modules/http/compliance/http-ssl-socket.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ it('emits a correct TLS Socket instance for a handled HTTPS request', async () =
4141
expect(socket.getSession()).toBeUndefined()
4242
expect(socket.getProtocol()).toBe('TLSv1.3')
4343
expect(socket.isSessionReused()).toBe(false)
44+
expect(socket.getCipher()).toEqual({ name: 'AES256-SHA', standardName: 'TLS_RSA_WITH_AES_256_CBC_SHA', version: 'TLSv1.3' })
4445
})
4546

4647
it('emits a correct TLS Socket instance for a bypassed HTTPS request', async () => {
@@ -58,5 +59,5 @@ it('emits a correct TLS Socket instance for a bypassed HTTPS request', async ()
5859

5960
expect(socket.getSession()).toBeUndefined()
6061
expect(socket.getProtocol()).toBe('TLSv1.3')
61-
expect(socket.isSessionReused()).toBe(false)
62+
expect(socket.getCipher()).toEqual({ name: 'AES256-SHA', standardName: 'TLS_RSA_WITH_AES_256_CBC_SHA', version: 'TLSv1.3' })
6263
})

0 commit comments

Comments
 (0)