@@ -54,22 +54,6 @@ describe('x509 Authentication', function () {
54
54
} ) ;
55
55
} ) ;
56
56
57
- context (
58
- 'when a valid cert is provided but the certificate does not correspond to a user' ,
59
- function ( ) {
60
- it . skip ( 'fails to authenticate' , async function ( ) {
61
- client = new MongoClient ( connectionString . toString ( ) , validOptions ) ;
62
- const error = await client . connect ( ) . then (
63
- ( ) => null ,
64
- e => e
65
- ) ;
66
-
67
- expect ( error ) . to . be . instanceOf ( MongoServerError ) ;
68
- expect ( error . codeName ) . to . match ( / U s e r N o t F o u n d / i) ;
69
- } ) . skipReason = 'TODO(NODE-6834): fix flaky test' ;
70
- }
71
- ) ;
72
-
73
57
context ( 'when the client connects with an invalid certificate' , function ( ) {
74
58
// unlike other authentication mechanisms, x509 authentication 1) requires TLS and
75
59
// 2) the server uses the client certificate to derive a username to authenticate with
@@ -93,6 +77,19 @@ describe('x509 Authentication', function () {
93
77
expect ( error ) . to . be . instanceOf ( MongoServerSelectionError ) ;
94
78
} ) ;
95
79
} ) ;
80
+
81
+ context (
82
+ 'when a valid cert is provided but the certificate does not correspond to a user' ,
83
+ function ( ) {
84
+ it ( 'fails to authenticate' , async function ( ) {
85
+ client = new MongoClient ( connectionString . toString ( ) , validOptions ) ;
86
+ const error = await client . connect ( ) . catch ( error => error ) ;
87
+
88
+ expect ( error ) . to . be . instanceOf ( MongoServerError ) ;
89
+ expect ( error . codeName ) . to . match ( / U s e r N o t F o u n d / i) ;
90
+ } ) ;
91
+ }
92
+ ) ;
96
93
} ) ;
97
94
98
95
async function createX509User ( ) {
@@ -110,8 +107,7 @@ async function createX509User() {
110
107
roles : [
111
108
{ role : 'readWrite' , db : 'test' } ,
112
109
{ role : 'userAdminAnyDatabase' , db : 'admin' }
113
- ] ,
114
- writeConcern : { w : 'majority' , wtimeout : 5000 }
110
+ ]
115
111
} ) ;
116
112
} finally {
117
113
await utilClient . close ( ) ;
@@ -128,8 +124,7 @@ async function dropX509User() {
128
124
try {
129
125
await utilClient . connect ( ) ;
130
126
await utilClient . db ( '$external' ) . command ( {
131
- dropUser : process . env . SUBJECT ,
132
- writeConcern : { w : 'majority' , wtimeout : 5000 }
127
+ dropUser : process . env . SUBJECT
133
128
} ) ;
134
129
} finally {
135
130
await utilClient . close ( ) ;
0 commit comments