Skip to content

Commit c69ba97

Browse files
Inject self certificates
1 parent 73b72ad commit c69ba97

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

test/connection.test.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
getChinookConnection,
1414
WARN_SPEED_MS,
1515
EXPECT_SPEED_MS,
16+
SELF_SIGNED_CERTIFICATE,
1617
clearTestingDatabasesAsync
1718
} from './shared'
1819

@@ -49,33 +50,28 @@ describe('connection', () => {
4950
})
5051

5152
it('should connect with config object string', done => {
52-
const configObj = parseConnectionString(CHINOOK_DATABASE_URL)
53+
const configObj = getChinookConfig()
5354
const conn = new SQLiteCloudConnection(configObj)
5455
expect(conn).toBeDefined()
5556

56-
// already connected?
57-
if (conn.connected) {
57+
conn.connect(error => {
58+
expect(error).toBeNull()
59+
expect(conn.connected).toBe(true)
60+
5861
chinook.sendCommands('TEST STRING', (error, results) => {
5962
conn.close()
6063
expect(conn.connected).toBe(false)
6164
done()
6265
})
63-
} else {
64-
// not connected, so connect...
65-
conn.connect(error => {
66-
expect(error).toBeNull()
67-
expect(conn.connected).toBe(true)
68-
69-
chinook.sendCommands('TEST STRING', (error, results) => {
70-
conn.close()
71-
expect(conn.connected).toBe(false)
72-
done()
73-
})
74-
})
75-
}
66+
})
7667
})
7768

7869
it('should connect with connection string', done => {
70+
if (CHINOOK_DATABASE_URL.indexOf('localhost') > 0) {
71+
// skip this test when running locally since it requires a self-signed certificate
72+
done()
73+
}
74+
7975
const conn = new SQLiteCloudConnection(CHINOOK_DATABASE_URL)
8076
expect(conn).toBeDefined()
8177

test/shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const TESTING_DATABASE_URL = process.env.TESTING_DATABASE_URL as string
3131
expect(CHINOOK_DATABASE_URL).toBeDefined()
3232
expect(TESTING_DATABASE_URL).toBeDefined()
3333

34-
const SELF_SIGNED_CERTIFICATE = `-----BEGIN CERTIFICATE-----
34+
export const SELF_SIGNED_CERTIFICATE = `-----BEGIN CERTIFICATE-----
3535
MIID6zCCAtOgAwIBAgIUI0lTm5CfVf3mVP8606CkophcyB4wDQYJKoZIhvcNAQEL
3636
BQAwgYQxCzAJBgNVBAYTAklUMQswCQYDVQQIDAJNTjEQMA4GA1UEBwwHVmlhZGFu
3737
YTEbMBkGA1UECgwSU1FMaXRlIENsb3VkLCBJbmMuMRQwEgYDVQQDDAtTUUxpdGVD

0 commit comments

Comments
 (0)