Skip to content

Commit

Permalink
chore: update socket test
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwotherspoon committed Sep 27, 2024
1 parent d20f1ca commit a91a1c5
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions test/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ t.test('getSocket', async t => {
cert: CA_CERT,
expirationTime: '2033-01-06T10:00:00.232Z',
},
serverCaMode: 'GOOGLE_MANAGED_INTERNAL_CA',
dnsName: 'abcde.12345.us-central1.sql.goog',
});

socket.on('secureConnect', () => {
Expand All @@ -61,11 +63,15 @@ t.test('getSocket', async t => {

t.test('validateCertificate no cert', async t => {
t.match(
validateCertificate({
projectId: 'my-project',
regionId: 'region-id',
instanceId: 'my-instance',
})('hostname', {} as tls.PeerCertificate),
validateCertificate(
{
projectId: 'my-project',
regionId: 'region-id',
instanceId: 'my-instance',
},
'GOOGLE_MANAGED_INTERNAL_CA',
'abcde.12345.us-central1.sql.goog'
)('hostname', {} as tls.PeerCertificate),
{code: 'ENOSQLADMINVERIFYCERT'},
'should return a missing cert to verify error'
);
Expand All @@ -78,11 +84,15 @@ t.test('validateCertificate mismatch', async t => {
},
} as tls.PeerCertificate;
t.match(
validateCertificate({
projectId: 'my-project',
regionId: 'region-id',
instanceId: 'my-instance',
})('hostname', cert),
validateCertificate(
{
projectId: 'my-project',
regionId: 'region-id',
instanceId: 'my-instance',
},
'GOOGLE_MANAGED_INTERNAL_CA',
'abcde.12345.us-central1.sql.goog'
)('hostname', cert),
{
message:
'Certificate had CN other-project:other-instance, expected my-project:my-instance',
Expand Down

0 comments on commit a91a1c5

Please sign in to comment.