Skip to content

Commit

Permalink
code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-akolodziejczyk committed Nov 27, 2024
1 parent 68b3030 commit c5b3f4a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
7 changes: 2 additions & 5 deletions test/authentication/testExternalBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ describe('External browser authentication tests', function () {
connection = await snowflake.createConnection(connectionOption);

const provideCredentialsPromise = execWithTimeout('node', [provideBrowserCredentialsPath, 'fail', login, password]);
const results = await Promise.allSettled([connection.connectAsync(connectAsyncCallback()), provideCredentialsPromise]);
assert.strictEqual(results[1].status, 'fulfilled');
await Promise.allSettled([connection.connectAsync(connectAsyncCallback()), provideCredentialsPromise]);
assert.strictEqual(error?.message, 'Error while getting SAML token: Browser action timed out after 10000 ms.');
await verifyConnectionIsNotUp(connection);
});
Expand Down Expand Up @@ -133,14 +132,12 @@ async function cleanBrowserProcesses() {
}

async function verifyConnectionIsUp(connection) {
assert.ok(connection.isUp(), 'Connection is not up');
assert.ok(await connection.isValidAsync(), 'Connection is not valid');
await testUtil.executeCmdAsync(connection, 'Select 1');
}

async function verifyConnectionIsNotUp(connection, message = 'Unable to perform operation because a connection was never established.') {
assert.ok(!(connection.isUp()), 'Connection should not be up');
assert.ok(!(await connection.isValidAsync()), 'Connection should not be valid');
try {
await testUtil.executeCmdAsync(connection, 'Select 1');
assert.fail('Expected error was not thrown');
Expand All @@ -150,7 +147,7 @@ async function verifyConnectionIsNotUp(connection, message = 'Unable to perform
}

async function destroyConnection(connection) {
if (connection !== undefined && connection.isUp() && connection.isValidAsync()) {
if (connection !== undefined && connection.isUp()) {
await testUtil.destroyConnectionAsync(connection);
}
}
Expand Down
30 changes: 30 additions & 0 deletions test/integration/testManualConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,36 @@ if (process.env.RUN_MANUAL_TESTS_ONLY === 'true') {
});
});

describe('Connection test - okta', function () {
it('Simple Connect', function (done) {
const connection = snowflake.createConnection(connOption.okta);

async.series([
function (callback) {
connection.connectAsync(function (err) {
done(err);
assert.ok(!err, JSON.stringify(err));
callback();
});
},
function (callback) {
assert.ok(connection.isUp(), 'not active');
callback();
},
function (callback) {
connection.destroy(function (err) {
assert.ok(!err, JSON.stringify(err));
callback();
});
},
function (callback) {
assert.ok(!connection.isUp(), 'still active');
callback();
},
]);
});
});

describe('Connection - MFA authenticator with DUO', function () {
const connectionOption = connOption.MFA;

Expand Down

0 comments on commit c5b3f4a

Please sign in to comment.