-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-1739611 add automated tests for okta, oauth and keypair (#976)
- Loading branch information
1 parent
e6f30aa
commit f6d50ea
Showing
15 changed files
with
396 additions
and
390 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ wss-*-agent.config | |
wss-unified-agent.jar | ||
whitesource/ | ||
.nyc_output | ||
rsa_*.p8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const assert = require('assert'); | ||
const testUtil = require('../integration/testUtil'); | ||
const snowflake = require('../../lib/snowflake'); | ||
|
||
class AuthTest { | ||
constructor() { | ||
this.connection = null; | ||
this.error = null; | ||
this.callbackCompleted = false; | ||
} | ||
|
||
connectAsyncCallback() { | ||
return (err) => { | ||
this.error = err; | ||
this.callbackCompleted = true; | ||
}; | ||
} | ||
|
||
async waitForCallbackCompletion() { | ||
const timeout = Date.now() + 5000; | ||
while (Date.now() < timeout) { | ||
await new Promise(resolve => setTimeout(resolve, 100)); | ||
if (this.callbackCompleted) { | ||
return; | ||
} | ||
} | ||
throw new Error('Connection callback did not complete'); | ||
} | ||
|
||
async createConnection(connectionOption) { | ||
this.connection = snowflake.createConnection(connectionOption); | ||
} | ||
|
||
async connectAsync() { | ||
await this.connection.connectAsync(this.connectAsyncCallback()); | ||
await this.waitForCallbackCompletion(); | ||
} | ||
|
||
async verifyConnectionIsUp() { | ||
assert.ok(await this.connection.isValidAsync(), 'Connection is not valid'); | ||
await testUtil.executeCmdAsync(this.connection, 'Select 1'); | ||
} | ||
|
||
async verifyConnectionIsNotUp(message = 'Unable to perform operation because a connection was never established.') { | ||
assert.ok(!(this.connection.isUp()), 'Connection should not be up'); | ||
try { | ||
await testUtil.executeCmdAsync(this.connection, 'Select 1'); | ||
assert.fail('Expected error was not thrown'); | ||
} catch (error) { | ||
assert.strictEqual(error.message, message); | ||
} | ||
} | ||
|
||
async destroyConnection() { | ||
if (this.connection !== undefined && this.connection !== null && this.connection.isUp()) { | ||
await testUtil.destroyConnectionAsync(this.connection); | ||
} | ||
} | ||
|
||
verifyNoErrorWasThrown() { | ||
assert.equal(this.error, null); | ||
} | ||
|
||
verifyErrorWasThrown(message) { | ||
assert.strictEqual(this.error?.message, message); | ||
} | ||
} | ||
|
||
module.exports = AuthTest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.