Skip to content

Commit

Permalink
update: storage-[mysql,postgresql] SSL url param
Browse files Browse the repository at this point in the history
  • Loading branch information
chr33s committed Sep 11, 2023
1 parent 981cb75 commit 95e5eae
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/red-weeks-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/shopify-app-session-storage-mysql': patch
'@shopify/shopify-app-session-storage-postgresql': patch
---

Update adds support for SSL DB url connection param
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,21 @@ describe('MySQLSessionStorage', () => {
expect(await storage.storeSession(session)).toBeTruthy();
await storage.disconnect();
});

it(`can successfully connect with a url string and ssl param`, async () => {
const _dbURL = new URL(dbURL);
_dbURL.searchParams.append('ssl', 'true');
const storage = new MySQLSessionStorage(_dbURL.toString());
await storage.ready;
const session = new Session({
id: '456',
shop: 'test-shop.myshopify.com',
state: 'test-state',
isOnline: false,
scope: 'fake_scope',
});

expect(await storage.storeSession(session)).toBeTruthy();
await storage.disconnect();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ export class MySqlConnection implements RdbmsConnection {
password: decodeURIComponent(this.dbUrl.password),
database: this.getDatabase(),
port: Number(this.dbUrl.port),
ssl: {
rejectUnauthorized: this.dbUrl.searchParams.get('ssl') === 'true',
},
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,21 @@ describe('PostgreSQLSessionStorage', () => {
expect(await storage.storeSession(session)).toBeTruthy();
await storage.disconnect();
});

it(`can successfully connect with a url string and ssl param`, async () => {
const _dbURL = new URL(dbURL);
_dbURL.searchParams.append('ssl', 'true');
const storage = new PostgreSQLSessionStorage(_dbURL.toString());
await storage.ready;
const session = new Session({
id: '456',
shop: 'test-shop.myshopify.com',
state: 'test-state',
isOnline: false,
scope: 'fake_scope',
});

expect(await storage.storeSession(session)).toBeTruthy();
await storage.disconnect();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class PostgresConnection implements RdbmsConnection {
password: decodeURIComponent(this.dbUrl.password),
database: this.getDatabase(),
port: Number(this.dbUrl.port),
ssl: this.dbUrl.searchParams.get("ssl") === "true",
});
}
}

0 comments on commit 95e5eae

Please sign in to comment.