@@ -15,6 +15,7 @@ const AuthOkta = require('./../../../lib/authentication/auth_okta');
1515const AuthIDToken = require ( './../../../lib/authentication/auth_idtoken' ) ;
1616const AuthenticationTypes = require ( './../../../lib/authentication/authentication_types' ) ;
1717const MockTestUtil = require ( './../mock/mock_test_util' ) ;
18+ const { getPortFree } = require ( '../test_util' ) ;
1819
1920// get connection options to connect to this mock snowflake instance
2021const mockConnectionOptions = MockTestUtil . connectionOptions ;
@@ -117,13 +118,14 @@ describe('external browser authentication', function () {
117118
118119 const credentials = connectionOptionsExternalBrowser ;
119120 const BROWSER_ACTION_TIMEOUT = 10000 ;
121+
120122 const connectionConfig = {
121123 getBrowserActionTimeout : ( ) => BROWSER_ACTION_TIMEOUT ,
122124 getProxy : ( ) => { } ,
123125 getAuthenticator : ( ) => credentials . authenticator ,
124126 getServiceName : ( ) => '' ,
125127 getDisableConsoleLogin : ( ) => true ,
126- getSamlRedirectUri : ( ) => credentials . samlRedirectUri ,
128+ getSamlRedirectUri : ( ) => '' ,
127129 host : 'fakehost'
128130 } ;
129131
@@ -166,7 +168,13 @@ describe('external browser authentication', function () {
166168 } ) ;
167169
168170 it ( 'external browser - get success' , async function ( ) {
169- const auth = new AuthWeb ( connectionConfig , httpclient , webbrowser . open ) ;
171+ const availablePort = await getPortFree ( ) ;
172+ const localConnectionConfig = {
173+ ...connectionConfig ,
174+ getSamlRedirectUri : ( ) => `localhost:${ availablePort } `
175+ } ;
176+
177+ const auth = new AuthWeb ( localConnectionConfig , httpclient , webbrowser . open ) ;
170178 await auth . authenticate ( credentials . authenticator , '' , credentials . account , credentials . username ) ;
171179
172180 const body = { data : { } } ;
@@ -204,14 +212,15 @@ describe('external browser authentication', function () {
204212
205213 webbrowser = require ( 'webbrowser' ) ;
206214 httpclient = require ( 'httpclient' ) ;
215+ const availablePort = await getPortFree ( ) ;
207216
208217 const fastFailConnectionConfig = {
209218 getBrowserActionTimeout : ( ) => 10 ,
210219 getProxy : ( ) => { } ,
211220 getAuthenticator : ( ) => credentials . authenticator ,
212221 getServiceName : ( ) => '' ,
213222 getDisableConsoleLogin : ( ) => true ,
214- getSamlRedirectUri : ( ) => credentials . samlRedirectUri ,
223+ getSamlRedirectUri : ( ) => `localhost: ${ availablePort } ` ,
215224 host : 'fakehost'
216225 } ;
217226
0 commit comments