greenlock.js/lib/utils-test.js

25 lines
706 B
JavaScript
Raw Normal View History

'use strict';
2019-10-08 10:51:15 +00:00
var utils = require('./utils.js');
var cert = { subject: 'example.com', altnames: ['*.bar.com', 'foo.net'] };
if (utils.certHasDomain(cert, 'bad.com')) {
2019-10-08 10:51:15 +00:00
throw new Error('allowed bad domain');
}
if (!utils.certHasDomain(cert, 'example.com')) {
2019-10-08 10:51:15 +00:00
throw new Error('missed subject');
}
if (utils.certHasDomain(cert, 'bar.com')) {
2019-10-08 10:51:15 +00:00
throw new Error('allowed bad (missing) sub');
}
if (!utils.certHasDomain(cert, 'foo.bar.com')) {
2019-10-08 10:51:15 +00:00
throw new Error("didn't allow valid wildcarded-domain");
}
if (utils.certHasDomain(cert, 'dub.foo.bar.com')) {
2019-10-08 10:51:15 +00:00
throw new Error('allowed sub-sub domain');
}
if (!utils.certHasDomain(cert, 'foo.net')) {
2019-10-08 10:51:15 +00:00
throw new Error('missed altname');
}
2019-10-08 10:51:15 +00:00
console.info('PASSED');