-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into SNOW-1631790-Transport-Layer
- Loading branch information
Showing
16 changed files
with
397 additions
and
390 deletions.
There are no files selected for viewing
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
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.