Skip to content

Commit 673992d

Browse files
committed
tests: add test to sanity-check Amazon CAs
1 parent e81cdc7 commit 673992d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test/unit/test-ConnectionConfig.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var common = require('../common');
2+
var Crypto = require('crypto');
23
var test = require('utest');
34
var assert = require('assert');
45
var ConnectionConfig = common.ConnectionConfig;
@@ -168,13 +169,24 @@ test('ConnectionConfig#Constructor.ssl', {
168169
assert.equal(config.ssl, false);
169170
},
170171

171-
'string loads pre-defined profile': function() {
172+
'string "Amazon RDS" loads valid profile': function() {
172173
var config = new ConnectionConfig({
173174
ssl: 'Amazon RDS'
174175
});
175176

176177
assert.ok(config.ssl);
177-
assert.ok(/-----BEGIN CERTIFICATE-----/.test(config.ssl.ca));
178+
assert.ok(Array.isArray(config.ssl.ca));
179+
180+
config.ssl.ca.forEach(function (ca) {
181+
assert.equal(typeof ca, 'string', 'ca is a string');
182+
183+
if (Crypto.createPublicKey) {
184+
var key = null;
185+
186+
assert.doesNotThrow(function () { key = Crypto.createPublicKey(ca); });
187+
assert.equal(key.type, 'public');
188+
}
189+
});
178190
},
179191

180192
'throws on unknown profile name': function() {

0 commit comments

Comments
 (0)