|
| 1 | +/* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. */ |
| 2 | + |
| 3 | +/****************************************************************************** |
| 4 | + * |
| 5 | + * You may not use the identified files except in compliance with the Apache |
| 6 | + * License, Version 2.0 (the "License.") |
| 7 | + * |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0. |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + * |
| 18 | + * The node-oracledb test suite uses 'mocha', 'should' and 'async'. |
| 19 | + * See LICENSE.md for relevant licenses. |
| 20 | + * |
| 21 | + * NAME |
| 22 | + * 69. driverName.js |
| 23 | + * |
| 24 | + * DESCRIPTION |
| 25 | + * Testing external authentication functionality. |
| 26 | + * |
| 27 | + * Note that enabling the externalAuth feature requires configuration on the |
| 28 | + * database besides setting "externalAuth" attribute to be true. Please refer |
| 29 | + * to api doc about the configuration. |
| 30 | + * https://github.com/oracle/node-oracledb/blob/master/doc/api.md#extauth |
| 31 | + * |
| 32 | + * NUMBERING RULE |
| 33 | + * Test numbers follow this numbering rule: |
| 34 | + * 1 - 20 are reserved for basic functional tests |
| 35 | + * 21 - 50 are reserved for data type supporting tests |
| 36 | + * 51 onwards are for other tests |
| 37 | + * |
| 38 | + *****************************************************************************/ |
| 39 | + |
| 40 | +'use strict'; |
| 41 | + |
| 42 | +var oracledb = require('oracledb'); |
| 43 | +var should = require('should'); |
| 44 | +var async = require('async'); |
| 45 | +var dbConfig = require('./dbconfig.js'); |
| 46 | + |
| 47 | +describe('69. driverName.js', function() { |
| 48 | + |
| 49 | + var getAddonVer = function() { |
| 50 | + var addonVer = oracledb.version; |
| 51 | + var major = Math.floor (addonVer / 10000); |
| 52 | + var minor = Math.floor(addonVer / 100) % 100; |
| 53 | + var update = addonVer % 100; |
| 54 | + |
| 55 | + return (major + '.' + minor + '.' + update); |
| 56 | + }; |
| 57 | + |
| 58 | + it("69.1 checks the driver name", function(done) { |
| 59 | + |
| 60 | + async.waterfall([ |
| 61 | + function(cb) { |
| 62 | + oracledb.createPool(dbConfig, cb); |
| 63 | + }, |
| 64 | + function(pool, cb) { |
| 65 | + pool.should.be.ok(); |
| 66 | + pool.getConnection( function(err, connection) { |
| 67 | + cb(err, connection, pool); |
| 68 | + }); |
| 69 | + }, |
| 70 | + function(connection, pool, cb) { |
| 71 | + var sql = "select distinct client_driver from v$session_connect_info where sid = sys_context('USERENV', 'SID')"; |
| 72 | + connection.should.be.ok(); |
| 73 | + connection.execute( |
| 74 | + sql, |
| 75 | + function(err, result) { |
| 76 | + |
| 77 | + var serverVer = connection.oracleServerVersion; |
| 78 | + var dbVerMajor = Math.floor( serverVer / 100000000 ); |
| 79 | + |
| 80 | + // 12c database can return the full driver name, e.g. 'node-oracledb 1.11' |
| 81 | + if(dbVerMajor == 12) { |
| 82 | + var addonVer = getAddonVer(); |
| 83 | + (result.rows[0][0]).should.equal("node-oracledb : " + addonVer); |
| 84 | + } |
| 85 | + // 11g database only returns the first 8 characters of the driver name |
| 86 | + else if(dbVerMajor == 11) { |
| 87 | + (result.rows[0][0]).should.equal("node-ora"); |
| 88 | + } |
| 89 | + |
| 90 | + cb(err, connection, pool); |
| 91 | + } |
| 92 | + ); |
| 93 | + } |
| 94 | + ], function(err, connection, pool) { |
| 95 | + should.not.exist(err); |
| 96 | + connection.close( function(err) { |
| 97 | + should.not.exist(err); |
| 98 | + pool.close(function(err) { |
| 99 | + should.not.exist(err); |
| 100 | + done(); |
| 101 | + }); |
| 102 | + }); |
| 103 | + }); // async |
| 104 | + |
| 105 | + }); |
| 106 | +}); |
0 commit comments