@@ -70,6 +70,9 @@ describe('292. passwordExpiryWarning.js', function() {
70
70
privilege : oracledb . SYSDBA
71
71
} ;
72
72
73
+ let pool ;
74
+ let conns = [ ] ;
75
+
73
76
before ( async function ( ) {
74
77
if ( ! dbConfig . test . DBA_PRIVILEGE || dbConfig . test . drcp ) this . skip ( ) ;
75
78
@@ -89,6 +92,16 @@ describe('292. passwordExpiryWarning.js', function() {
89
92
await connAsDBA . close ( ) ;
90
93
} ) ;
91
94
95
+ afterEach ( async function ( ) {
96
+ for ( const conn of conns ) {
97
+ await conn . close ( ) ;
98
+ }
99
+ conns = [ ] ;
100
+ if ( pool ) {
101
+ await pool . close ( 0 ) ;
102
+ pool = null ;
103
+ }
104
+ } ) ;
92
105
93
106
it ( '292.1 password expiry warning' , async ( ) => {
94
107
const credentials = {
@@ -99,14 +112,14 @@ describe('292. passwordExpiryWarning.js', function() {
99
112
100
113
const isDB23ai = await testsUtil . checkPrerequisites ( undefined , 2300000000 ) ;
101
114
const conn = await oracledb . getConnection ( credentials ) ;
115
+ conns . push ( conn ) ;
102
116
if ( isDB23ai ) {
103
117
assert . strictEqual ( conn . warning . code , 'ORA-28098' ) ;
104
118
assert . strictEqual ( conn . warning . errorNum , 28098 ) ;
105
119
} else {
106
120
assert . strictEqual ( conn . warning . code , 'ORA-28002' ) ;
107
121
assert . strictEqual ( conn . warning . errorNum , 28002 ) ;
108
122
}
109
- await conn . close ( ) ;
110
123
} ) ; // 292.1
111
124
112
125
it ( '292.2 password expiry warning on a homogeneous pool' , async ( ) => {
@@ -121,16 +134,15 @@ describe('292. passwordExpiryWarning.js', function() {
121
134
homogeneous : true
122
135
} ;
123
136
const isDB23ai = await testsUtil . checkPrerequisites ( undefined , 2300000000 ) ;
124
- const pool = await oracledb . createPool ( credentials ) ;
137
+ pool = await oracledb . createPool ( credentials ) ;
125
138
const conn = await pool . getConnection ( ) ;
139
+ conns . push ( conn ) ;
126
140
await testsUtil . sleep ( 1000 ) ;
127
141
if ( isDB23ai ) {
128
142
assert . strictEqual ( conn . warning . message . startsWith ( "ORA-28098:" ) , true ) ;
129
143
} else {
130
144
assert . strictEqual ( conn . warning . message . startsWith ( "ORA-28002:" ) , true ) ;
131
145
}
132
- await conn . close ( ) ;
133
- await pool . close ( 0 ) ;
134
146
} ) ; // 292.2
135
147
136
148
it ( '292.3 password expiry warning on a heterogeneous pool' , async function ( ) {
@@ -148,18 +160,17 @@ describe('292. passwordExpiryWarning.js', function() {
148
160
homogeneous : false
149
161
} ;
150
162
const isDB23ai = await testsUtil . checkPrerequisites ( undefined , 2300000000 ) ;
151
- const pool = await oracledb . createPool ( credentials ) ;
163
+ pool = await oracledb . createPool ( credentials ) ;
152
164
const conn = await pool . getConnection ( {
153
165
user : userName ,
154
166
password : password
155
167
} ) ;
168
+ conns . push ( conn ) ;
156
169
if ( isDB23ai ) {
157
170
assert . strictEqual ( conn . warning . message . startsWith ( "ORA-28098:" ) , true ) ;
158
171
} else {
159
172
assert . strictEqual ( conn . warning . message . startsWith ( "ORA-28002:" ) , true ) ;
160
173
}
161
- await conn . close ( ) ;
162
- await pool . close ( 0 ) ;
163
174
} ) ; // 292.3
164
175
165
176
it ( '292.4 with poolMin=0 with regular user and password' , async function ( ) {
@@ -174,12 +185,10 @@ describe('292. passwordExpiryWarning.js', function() {
174
185
homogeneous : true
175
186
} ;
176
187
177
- const pool = await oracledb . createPool ( credentials ) ;
188
+ pool = await oracledb . createPool ( credentials ) ;
178
189
const conn = await pool . getConnection ( ) ;
190
+ conns . push ( conn ) ;
179
191
assert . strictEqual ( conn . warning , undefined ) ;
180
-
181
- await conn . close ( ) ;
182
- await pool . close ( ) ;
183
192
} ) ; //292.4
184
193
185
194
@@ -196,22 +205,24 @@ describe('292. passwordExpiryWarning.js', function() {
196
205
} ;
197
206
198
207
const isDB23ai = await testsUtil . checkPrerequisites ( undefined , 2300000000 ) ;
199
- const pool = await oracledb . createPool ( credentials ) ;
208
+ pool = await oracledb . createPool ( credentials ) ;
200
209
const conn = await pool . getConnection ( ) ;
210
+ conns . push ( conn ) ;
201
211
if ( isDB23ai ) {
202
212
assert . strictEqual ( conn . warning . code , 'ORA-28098' ) ;
203
213
} else {
204
214
assert . strictEqual ( conn . warning . code , 'ORA-28002' ) ;
205
215
}
206
216
207
217
await conn . close ( ) ;
218
+ conns = [ ] ;
208
219
209
220
// Check that the warning is cleared on the next connection
210
221
const conn2 = await pool . getConnection ( ) ;
222
+ conns . push ( conn2 ) ;
211
223
assert . strictEqual ( conn2 . warning , undefined ) ;
212
224
await conn2 . close ( ) ;
213
-
214
- await pool . close ( ) ;
225
+ conns = [ ] ;
215
226
} ) ; // 292.5
216
227
217
228
it ( '292.6 with poolMin=1 with password in grace time' , async function ( ) {
@@ -227,22 +238,24 @@ describe('292. passwordExpiryWarning.js', function() {
227
238
} ;
228
239
229
240
const isDB23ai = await testsUtil . checkPrerequisites ( undefined , 2300000000 ) ;
230
- const pool = await oracledb . createPool ( credentials ) ;
241
+ pool = await oracledb . createPool ( credentials ) ;
231
242
const conn = await pool . getConnection ( ) ;
243
+ conns . push ( conn ) ;
232
244
if ( isDB23ai ) {
233
245
assert . strictEqual ( conn . warning . code , 'ORA-28098' ) ;
234
246
} else {
235
247
assert . strictEqual ( conn . warning . code , 'ORA-28002' ) ;
236
248
}
237
249
238
250
await conn . close ( ) ;
251
+ conns = [ ] ;
239
252
240
253
// Check that the warning is cleared on the next connection
241
254
const conn2 = await pool . getConnection ( ) ;
255
+ conns . push ( conn2 ) ;
242
256
assert . strictEqual ( conn2 . warning , undefined ) ;
243
257
await conn2 . close ( ) ;
244
-
245
- await pool . close ( ) ;
258
+ conns = [ ] ;
246
259
} ) ; // 292.6
247
260
248
261
it ( '292.7 no warning after password change on new connection' , async ( ) => {
@@ -259,6 +272,7 @@ describe('292. passwordExpiryWarning.js', function() {
259
272
260
273
const isDB23ai = await testsUtil . checkPrerequisites ( undefined , 2300000000 ) ;
261
274
const conn = await oracledb . getConnection ( credentials ) ;
275
+ conns . push ( conn ) ;
262
276
if ( isDB23ai ) {
263
277
assert . strictEqual ( conn . warning . code , 'ORA-28098' ) ;
264
278
assert . strictEqual ( conn . warning . errorNum , 28098 ) ;
@@ -268,9 +282,8 @@ describe('292. passwordExpiryWarning.js', function() {
268
282
}
269
283
await conn . changePassword ( userName , password , newPassword ) ;
270
284
const conn1 = await oracledb . getConnection ( newCredentials ) ;
285
+ conns . push ( conn1 ) ;
271
286
assert . strictEqual ( conn1 . warning , undefined ) ;
272
- await conn . close ( ) ;
273
- await conn1 . close ( ) ;
274
287
} ) ; // 292.7
275
288
276
289
} ) ;
0 commit comments