Skip to content

Commit 542b106

Browse files
committed
fallback using username pw
1 parent f93935a commit 542b106

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/common/identity.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ export async function getBoilingDataCredentials(
101101
} else if (authContext && authContext.idToken?.jwtToken) {
102102
logger?.debug("Using existing ID token");
103103
idToken = new CognitoIdToken({ IdToken: authContext.idToken?.jwtToken });
104+
} else if (username && password) {
105+
logger?.debug("Fetching ID token with username and pw (no jwtToken in authContext)");
106+
idToken = await getIdToken(username, password, mfa, logger);
104107
} else {
105108
throw new Error("No credentials for creating signed WS URL");
106109
}

src/tests/query.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,45 @@ const globalCallbacks = globalCallbacksList
2121
globalCallbacks.onSocketOpen = () => logger.info("connected.");
2222
globalCallbacks.onSocketClose = () => logger.info("connection closed.");
2323

24+
describe.only("error handling", () => {
25+
let bdInstance: BoilingData = new BoilingData({ username, password, globalCallbacks, logLevel, region: "eu-west-1" });
26+
27+
beforeAll(async () => {
28+
bdInstance = new BoilingData({ username, password, globalCallbacks, logLevel });
29+
await bdInstance.connect();
30+
logger.info("connected.");
31+
});
32+
33+
afterAll(async () => {
34+
await bdInstance.close();
35+
logger.info("connection closed.");
36+
});
37+
38+
it("missing catalog", async () => {
39+
const sql = "SELECT * FROM taxi_locations_limited;";
40+
try {
41+
const rows = await bdInstance.execQueryPromise({ sql });
42+
console.log({ rows });
43+
} catch (err) {
44+
// console.error(err);
45+
// console.log(err.logMessage);
46+
expect(err.logMessage).toContain("Catalog Error: Table with name taxi_locations_limited does not exist");
47+
}
48+
});
49+
50+
it("random test queries", async () => {
51+
try {
52+
const sql = "DESCRIBE taxi_locations; -- Database: boiling.sharedtome";
53+
const rows = await bdInstance.execQueryPromise({ sql });
54+
console.log({ rows });
55+
} catch (err) {
56+
//console.error(err);
57+
//console.log(err.logMessage);
58+
expect(err.logMessage).toContain('Error: syntax error at or near "taxi_locations"');
59+
}
60+
});
61+
});
62+
2463
describe("boilingdata with DuckDB", () => {
2564
let bdInstance: BoilingData = new BoilingData({ username, password, globalCallbacks, logLevel, region: "eu-west-1" });
2665

0 commit comments

Comments
 (0)