1414 * limitations under the License.
1515 */
1616'use strict' ;
17- const assert = require ( 'assert ' ) ;
17+ const { assert } = require ( 'chai ' ) ;
1818const helper = require ( '../../../test-helper' ) ;
1919const DsePlainTextAuthProvider = require ( '../../../../lib/auth/dse-plain-text-auth-provider' ) ;
2020const Client = require ( '../../../../lib/client' ) ;
2121const vdescribe = helper . vdescribe ;
2222
2323vdescribe ( 'dse-5.0' , 'DsePlainTextAuthProvider @SERVER_API' , function ( ) {
2424 this . timeout ( 180000 ) ;
25- it ( 'should authenticate against DSE daemon instance' , function ( done ) {
26- const testClusterOptions = {
25+
26+ context ( 'with Cassandra PasswordAuthenticator' , ( ) => {
27+ helper . setup ( 1 , { initClient : false , ccmOptions : {
2728 yaml : [ 'authenticator:PasswordAuthenticator' ] ,
2829 jvmArgs : [ '-Dcassandra.superuser_setup_delay_ms=0' ]
29- } ;
30- helper . ccm . startAll ( 1 , testClusterOptions , function ( err ) {
31- assert . ifError ( err ) ;
30+ } } ) ;
31+
32+ it ( 'should authenticate against DSE daemon instance' , function ( done ) {
3233 const authProvider = new DsePlainTextAuthProvider ( 'cassandra' , 'cassandra' ) ;
3334 const clientOptions = helper . getOptions ( { authProvider : authProvider } ) ;
34- const client = new Client ( clientOptions ) ;
35+ const client = helper . shutdownAfterThisTest ( new Client ( clientOptions ) ) ;
3536 client . connect ( function ( err ) {
3637 assert . ifError ( err ) ;
3738 assert . notEqual ( client . hosts . length , 0 ) ;
@@ -40,22 +41,38 @@ vdescribe('dse-5.0', 'DsePlainTextAuthProvider @SERVER_API', function () {
4041 } ) ;
4142 } ) ;
4243
43- it ( 'should authenticate against DSE 5+ DseAuthenticator', function ( done ) {
44- const testClusterOptions = {
44+ context ( 'with DSE 5+ DseAuthenticator', ( ) => {
45+ helper . setup ( 1 , { initClient : false , ccmOptions : {
4546 yaml : [ 'authenticator:com.datastax.bdp.cassandra.auth.DseAuthenticator' ] ,
4647 jvmArgs : [ '-Dcassandra.superuser_setup_delay_ms=0' ] ,
4748 dseYaml : [ 'authentication_options.enabled:true' , 'authentication_options.default_scheme:internal' ]
48- } ;
49- helper . ccm . startAll ( 1 , testClusterOptions , function ( err ) {
50- assert . ifError ( err ) ;
49+ } } ) ;
50+
51+ it ( 'should authenticate against DSE 5+ DseAuthenticator' , async ( ) => {
5152 const authProvider = new DsePlainTextAuthProvider ( 'cassandra' , 'cassandra' ) ;
52- const clientOptions = helper . getOptions ( { authProvider : authProvider } ) ;
53- const client = new Client ( clientOptions ) ;
54- client . connect ( function ( err ) {
55- assert . ifError ( err ) ;
56- assert . notEqual ( client . hosts . length , 0 ) ;
57- client . shutdown ( done ) ;
58- } ) ;
53+ const clientOptions = helper . getOptions ( { authProvider } ) ;
54+ const client = helper . shutdownAfterThisTest ( new Client ( clientOptions ) ) ;
55+ await client . connect ( ) ;
56+ // There is an open connection
57+ assert . strictEqual ( client . getState ( ) . getOpenConnections ( client . hosts . values ( ) [ 0 ] ) , 1 ) ;
58+ await client . shutdown ( ) ;
59+ } ) ;
60+ } ) ;
61+
62+ context ( 'with transitional mode normal' , ( ) => {
63+ helper . setup ( 1 , { initClient : false , ccmOptions : {
64+ yaml : [ 'authenticator:com.datastax.bdp.cassandra.auth.DseAuthenticator' ] ,
65+ jvmArgs : [ '-Dcassandra.superuser_setup_delay_ms=0' ] ,
66+ dseYaml : [ 'authentication_options.enabled:true' , 'authentication_options.default_scheme:internal' , 'authentication_options.transitional_mode:normal' ]
67+ } } ) ;
68+
69+ it ( 'should support transitional mode' , async ( ) => {
70+ // Without setting an authenticator
71+ const clientOptions = helper . getOptions ( { } ) ;
72+ const client = helper . shutdownAfterThisTest ( new Client ( clientOptions ) ) ;
73+ await client . connect ( ) ;
74+ await client . execute ( 'SELECT * FROM system.local' ) ;
75+ await client . shutdown ( ) ;
5976 } ) ;
6077 } ) ;
61- } ) ;
78+ } ) ;
0 commit comments