2019-04-01 06:36:59 +00:00
|
|
|
'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'] };
|
2019-04-01 06:36:59 +00:00
|
|
|
if (utils.certHasDomain(cert, 'bad.com')) {
|
2019-10-08 10:51:15 +00:00
|
|
|
throw new Error('allowed bad domain');
|
2019-04-01 06:36:59 +00:00
|
|
|
}
|
|
|
|
if (!utils.certHasDomain(cert, 'example.com')) {
|
2019-10-08 10:51:15 +00:00
|
|
|
throw new Error('missed subject');
|
2019-04-01 06:36:59 +00:00
|
|
|
}
|
|
|
|
if (utils.certHasDomain(cert, 'bar.com')) {
|
2019-10-08 10:51:15 +00:00
|
|
|
throw new Error('allowed bad (missing) sub');
|
2019-04-01 06:36:59 +00:00
|
|
|
}
|
|
|
|
if (!utils.certHasDomain(cert, 'foo.bar.com')) {
|
2019-10-08 10:51:15 +00:00
|
|
|
throw new Error("didn't allow valid wildcarded-domain");
|
2019-04-01 06:36:59 +00:00
|
|
|
}
|
|
|
|
if (utils.certHasDomain(cert, 'dub.foo.bar.com')) {
|
2019-10-08 10:51:15 +00:00
|
|
|
throw new Error('allowed sub-sub domain');
|
2019-04-01 06:36:59 +00:00
|
|
|
}
|
|
|
|
if (!utils.certHasDomain(cert, 'foo.net')) {
|
2019-10-08 10:51:15 +00:00
|
|
|
throw new Error('missed altname');
|
2019-04-01 06:36:59 +00:00
|
|
|
}
|
|
|
|
|
2019-10-08 10:51:15 +00:00
|
|
|
console.info('PASSED');
|