1
1
/* eslint-disable no-proto */
2
2
'use strict' ;
3
+
3
4
const common = require ( '../common' ) ;
4
5
if ( ! common . hasCrypto )
5
6
common . skip ( 'missing crypto' ) ;
6
7
7
8
const assert = require ( 'assert' ) ;
9
+ // Flags: --expose_internals
10
+ const internalTLS = require ( 'internal/tls' ) ;
8
11
const tls = require ( 'tls' ) ;
9
12
13
+ const noOutput = common . mustNotCall ( ) ;
14
+ common . hijackStderr ( noOutput ) ;
15
+
10
16
{
11
17
const singles = 'C=US\nST=CA\nL=SF\nO=Node.js Foundation\nOU=Node.js\n' +
12
18
13
- const singlesOut = tls . parseCertString ( singles ) ;
19
+ const singlesOut = internalTLS . parseCertString ( singles ) ;
14
20
assert . deepStrictEqual ( singlesOut , {
15
21
__proto__ : null ,
16
22
C : 'US' ,
@@ -26,7 +32,7 @@ const tls = require('tls');
26
32
{
27
33
const doubles = 'OU=Domain Control Validated\nOU=PositiveSSL Wildcard\n' +
28
34
'CN=*.nodejs.org' ;
29
- const doublesOut = tls . parseCertString ( doubles ) ;
35
+ const doublesOut = internalTLS . parseCertString ( doubles ) ;
30
36
assert . deepStrictEqual ( doublesOut , {
31
37
__proto__ : null ,
32
38
OU : [ 'Domain Control Validated' , 'PositiveSSL Wildcard' ] ,
@@ -36,7 +42,7 @@ const tls = require('tls');
36
42
37
43
{
38
44
const invalid = 'fhqwhgads' ;
39
- const invalidOut = tls . parseCertString ( invalid ) ;
45
+ const invalidOut = internalTLS . parseCertString ( invalid ) ;
40
46
assert . deepStrictEqual ( invalidOut , { __proto__ : null } ) ;
41
47
}
42
48
@@ -45,5 +51,16 @@ const tls = require('tls');
45
51
const expected = Object . create ( null ) ;
46
52
expected . __proto__ = 'mostly harmless' ;
47
53
expected . hasOwnProperty = 'not a function' ;
48
- assert . deepStrictEqual ( tls . parseCertString ( input ) , expected ) ;
54
+ assert . deepStrictEqual ( internalTLS . parseCertString ( input ) , expected ) ;
55
+ }
56
+
57
+ common . restoreStderr ( ) ;
58
+
59
+ {
60
+ common . expectWarning ( 'DeprecationWarning' ,
61
+ 'tls.parseCertString() is deprecated. ' +
62
+ 'Please use querystring.parse() instead.' ) ;
63
+
64
+ const ret = tls . parseCertString ( 'foo=bar' ) ;
65
+ assert . deepStrictEqual ( ret , { __proto__ : null , foo : 'bar' } ) ;
49
66
}
0 commit comments