Skip to content

Commit b0aa428

Browse files
committed
Update error messages for external authentication in Thin mode and the corresponding test cases
1 parent 5648672 commit b0aa428

File tree

7 files changed

+44
-22
lines changed

7 files changed

+44
-22
lines changed

lib/errors.js

+4
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ const ERR_INVALID_COLL_INDEX_GET = 132;
134134
const ERR_DELETE_ELEMENTS_OF_VARRAY = 133;
135135
const ERR_WRONG_VALUE_FOR_DBOBJECT_ATTR = 134;
136136
const ERR_WRONG_VALUE_FOR_DBOBJECT_ELEM = 135;
137+
const ERR_WRONG_CRED_FOR_EXTAUTH = 136;
137138

138139
// Oracle Net layer errors start from 500
139140
const ERR_CONNECTION_CLOSED = 500;
@@ -387,6 +388,8 @@ messages.set(ERR_WRONG_VALUE_FOR_DBOBJECT_ATTR, // NJS-134
387388
'value is of wrong type for attribute %s of object %s');
388389
messages.set(ERR_WRONG_VALUE_FOR_DBOBJECT_ELEM, // NJS-135
389390
'value is of wrong type for an element of object %s');
391+
messages.set(ERR_WRONG_CRED_FOR_EXTAUTH, // NJS-136
392+
'user name and password cannot be set when using external authentication');
390393

391394
// Oracle Net layer errors
392395

@@ -755,6 +758,7 @@ module.exports = {
755758
ERR_DELETE_ELEMENTS_OF_VARRAY,
756759
ERR_WRONG_VALUE_FOR_DBOBJECT_ATTR,
757760
ERR_WRONG_VALUE_FOR_DBOBJECT_ELEM,
761+
ERR_WRONG_CRED_FOR_EXTAUTH,
758762
ERR_CONNECTION_CLOSED_CODE: `${ERR_PREFIX}-${ERR_CONNECTION_CLOSED}`,
759763
assert,
760764
assertArgCount,

lib/oracledb.js

+5
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,11 @@ async function _verifyOptions(options, inCreatePool) {
486486

487487
}
488488

489+
// Check external Auth config
490+
if (outOptions.token === undefined && outOptions.externalAuth && (outOptions.user || outOptions.password)) {
491+
errors.throwErr(errors.ERR_WRONG_CRED_FOR_EXTAUTH);
492+
}
493+
489494
return outOptions;
490495
}
491496

lib/thin/pool.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ThinPoolImpl extends PoolImpl {
4141

4242
_init(params) {
4343
if (!params.homogeneous) {
44-
errors.throwErr(errors.ERR_NOT_IMPLEMENTED, 'Heterogeneous Pool');
44+
errors.throwErr(errors.ERR_NOT_IMPLEMENTED, 'Heterogeneous Pooling');
4545
}
4646
thinUtil.checkCredentials(params);
4747

lib/thin/util.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ function checkProxyUserValidity(userName) {
268268
//---------------------------------------------------------------------------
269269
function checkCredentials(params) {
270270
if (params.token === undefined) {
271+
if (params.externalAuth === true) {
272+
errors.throwErr(errors.ERR_NOT_IMPLEMENTED, 'External Authentication');
273+
}
271274
if (params.password === undefined) {
272275
errors.throwErr(errors.ERR_MISSING_CREDENTIALS);
273276
}
274-
if (params.externalAuth === true) {
275-
errors.throwErr(errors.ERR_NOT_IMPLEMENTED, 'External Auth');
276-
}
277277
}
278278
}
279279

test/externalAuth.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ const dbConfig = require('./dbconfig.js');
7474
}
7575
);
7676
},
77-
// DPI-1032: user and password should not be set when using external authentication
78-
/DPI-1032:/
77+
// NJS-136: user and password should not be set when using external authentication
78+
/NJS-136:/
7979
);
8080

8181
}); // 5.1.2
@@ -92,8 +92,8 @@ const dbConfig = require('./dbconfig.js');
9292
}
9393
);
9494
},
95-
// ORA-01017: invalid username/password; logon denied
96-
/ORA-01017:/
95+
// NJS-136: user and password should not be set when using external authentication
96+
/NJS-136:/
9797
);
9898
}); // 5.1.3
9999

@@ -109,8 +109,8 @@ const dbConfig = require('./dbconfig.js');
109109
}
110110
);
111111
},
112-
// DPI-1032: user and password should not be set when using external authentication
113-
/DPI-1032:/
112+
// NJS-136: user and password should not be set when using external authentication
113+
/NJS-136:/
114114
);
115115
}); // 5.1.4
116116

@@ -145,8 +145,8 @@ const dbConfig = require('./dbconfig.js');
145145
}
146146
);
147147
},
148-
// DPI-1032: user and password should not be set when using external authentication
149-
/DPI-1032:/
148+
// NJS-136: user and password should not be set when using external authentication
149+
/NJS-136:/
150150
);
151151
}); // 5.1.6
152152

@@ -162,8 +162,8 @@ const dbConfig = require('./dbconfig.js');
162162
}
163163
);
164164
},
165-
// DPI-1032: user and password should not be set when using external authentication
166-
/DPI-1032:/
165+
// NJS-136: user and password should not be set when using external authentication
166+
/NJS-136:/
167167
);
168168
}); // 5.1.7
169169

@@ -179,8 +179,8 @@ const dbConfig = require('./dbconfig.js');
179179
}
180180
);
181181
},
182-
// DPI-1032: user and password should not be set when using external authentication
183-
/DPI-1032:/
182+
// NJS-136: user and password should not be set when using external authentication
183+
/NJS-136:/
184184
);
185185
}); // 5.1.8
186186

test/externalProxyAuth.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ describe('180. externalProxyAuth.js', function() {
214214
externalAuth: true,
215215
});
216216
},
217-
/DPI-1032:/
217+
/NJS-136:/
218218
);
219219
});
220220

@@ -230,7 +230,7 @@ describe('180. externalProxyAuth.js', function() {
230230
externalAuth: true,
231231
});
232232
},
233-
/DPI-1032:/
233+
/NJS-136:/
234234
);
235235
});
236236

test/pool.js

+17-4
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ describe('2. pool.js', function() {
751751
} else {
752752
await assert.rejects(
753753
async () => await oracledb.createPool(config),
754-
/NJS-101:/
754+
/NJS-089:/
755755
);
756756
}
757757
}); // 2.15.7
@@ -854,7 +854,7 @@ describe('2. pool.js', function() {
854854
} else {
855855
await assert.rejects(
856856
async () => await oracledb.createPool(config),
857-
/NJS-101:/
857+
/NJS-089:/
858858
);
859859
}
860860
}); // 2.15.13
@@ -882,10 +882,23 @@ describe('2. pool.js', function() {
882882
};
883883
await assert.rejects(
884884
async () => await oracledb.createPool(config),
885-
/DPI-1032:|NJS-089:/
885+
/NJS-136:/
886886
);
887887
}); // 2.15.15
888888

889+
it('2.15.16 empty Credentials', async function() {
890+
const config = {
891+
connectString: dbConfig.connectString,
892+
poolMin: 1,
893+
poolMax: 1,
894+
poolIncrement: 0,
895+
};
896+
await assert.rejects(
897+
async () => await oracledb.createPool(config),
898+
/ORA-24415:|NJS-101:/
899+
);
900+
}); // 2.15.16
901+
889902
}); // 2.15
890903

891904
describe('2.16 Pool non-configurable properties global/local override', function() {
@@ -1020,7 +1033,7 @@ describe('2. pool.js', function() {
10201033
} else {
10211034
await assert.rejects(
10221035
async () => await oracledb.createPool(config),
1023-
/NJS-101:/
1036+
/NJS-089:/
10241037
);
10251038
}
10261039
} finally {

0 commit comments

Comments
 (0)