Skip to content

Commit 963e7c5

Browse files
Neumann-Nilsdavidlehn
authored andcommitted
Add unit test for "pseudonym"
1 parent f0b6f5b commit 963e7c5

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/unit/x509.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,52 @@ var UTIL = require('../../lib/util');
616616
ASSERT.equal(attribute.value, 'Test Avenue');
617617
});
618618

619+
it('should generate a certificate with pseudonym attribute', function() {
620+
var keys = {
621+
privateKey: PKI.privateKeyFromPem(_pem.privateKey),
622+
publicKey: PKI.publicKeyFromPem(_pem.publicKey)
623+
};
624+
var attrs = [{
625+
name: 'commonName',
626+
value: 'example.org'
627+
}, {
628+
name: 'countryName',
629+
value: 'US'
630+
}, {
631+
shortName: 'ST',
632+
value: 'Virginia'
633+
}, {
634+
name: 'localityName',
635+
value: 'Blacksburg'
636+
}, {
637+
name: 'organizationName',
638+
value: 'Test'
639+
}, {
640+
shortName: 'OU',
641+
value: 'Test'
642+
}, {
643+
name: 'pseudonym',
644+
value: 'Satoshi Nakamato'
645+
}];
646+
var cert = createCertificate({
647+
publicKey: keys.publicKey,
648+
signingKey: keys.privateKey,
649+
serialNumber: '01',
650+
subject: attrs,
651+
issuer: attrs,
652+
isCA: true
653+
});
654+
655+
var pem = PKI.certificateToPem(cert);
656+
cert = PKI.certificateFromPem(pem);
657+
var index = findIndex(cert.subject.attributes, {type: '2.5.4.65'});
658+
ASSERT.ok(index !== -1);
659+
var attribute = cert.subject.attributes[index];
660+
ASSERT.equal(attribute.name, 'pseudonym');
661+
ASSERT.equal(attribute.value, 'Satoshi Nakamato');
662+
});
663+
664+
619665
it('should generate a certificate with jurisdictionOfIncorporationStateOrProvinceName attribute', function() {
620666
var keys = {
621667
privateKey: PKI.privateKeyFromPem(_pem.privateKey),

0 commit comments

Comments
 (0)