@@ -27,8 +27,19 @@ func Test_newName(t *testing.T) {
2727 PostalCode : []string {"The postalCode" },
2828 SerialNumber : "The serialNumber" ,
2929 CommonName : "The commonName" ,
30- ExtraNames : []pkix.AttributeTypeAndValue {
31- {
Type : asn1.
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value :
"[email protected] " },
30+ Names : []pkix.AttributeTypeAndValue {
31+ {Type : asn1.ObjectIdentifier {2 , 5 , 4 , 6 }, Value : "The country" },
32+ {Type : asn1.ObjectIdentifier {2 , 5 , 4 , 10 }, Value : "The organization" },
33+ {Type : asn1.ObjectIdentifier {2 , 5 , 4 , 11 }, Value : "The organizationalUnit 1" },
34+ {Type : asn1.ObjectIdentifier {2 , 5 , 4 , 11 }, Value : "The organizationalUnit 2" },
35+ {Type : asn1.ObjectIdentifier {2 , 5 , 4 , 3 }, Value : "The commonName" },
36+ {Type : asn1.ObjectIdentifier {2 , 5 , 4 , 5 }, Value : "The serialNumber" },
37+ {Type : asn1.ObjectIdentifier {2 , 5 , 4 , 7 }, Value : "The locality 1" },
38+ {Type : asn1.ObjectIdentifier {2 , 5 , 4 , 7 }, Value : "The locality 2" },
39+ {Type : asn1.ObjectIdentifier {2 , 5 , 4 , 8 }, Value : "The province" },
40+ {Type : asn1.ObjectIdentifier {2 , 5 , 4 , 9 }, Value : "The streetAddress" },
41+ {Type : asn1.ObjectIdentifier {2 , 5 , 4 , 17 }, Value : "The postalCode" },
42+ {
Type : asn1.
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value : asn1.
RawValue {
Class :
asn1 .
ClassUniversal ,
Tag :
asn1 .
TagIA5String ,
Bytes : []
byte (
"[email protected] " )}},
3243 },
3344 }}, Name {
3445 Country : []string {"The country" },
@@ -41,7 +52,7 @@ func Test_newName(t *testing.T) {
4152 SerialNumber : "The serialNumber" ,
4253 CommonName : "The commonName" ,
4354 ExtraNames : []DistinguishedName {
44- {
Type :
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value :
"[email protected] " },
55+ {
Type :
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value :
asn1. RawValue { Class : asn1 . ClassUniversal , Tag : asn1 . TagIA5String , Bytes : [] byte ( "[email protected] " )} },
4556 },
4657 }},
4758 }
@@ -127,8 +138,8 @@ func Test_newSubject(t *testing.T) {
127138 PostalCode : []string {"The postalCode" },
128139 SerialNumber : "The serialNumber" ,
129140 CommonName : "The commonName" ,
130- ExtraNames : []pkix.AttributeTypeAndValue {
131- {
Type : asn1.
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value :
"[email protected] " },
141+ Names : []pkix.AttributeTypeAndValue {
142+ {
Type : asn1.
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value :
asn1. RawValue { Class : asn1 . ClassUniversal , Tag : asn1 . TagIA5String , Bytes : [] byte ( "[email protected] " )} },
132143 },
133144 }}, Subject {
134145 Country : []string {"The country" },
@@ -141,7 +152,7 @@ func Test_newSubject(t *testing.T) {
141152 SerialNumber : "The serialNumber" ,
142153 CommonName : "The commonName" ,
143154 ExtraNames : []DistinguishedName {
144- {
Type :
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value :
"[email protected] " },
155+ {
Type :
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value :
asn1. RawValue { Class : asn1 . ClassUniversal , Tag : asn1 . TagIA5String , Bytes : [] byte ( "[email protected] " )} },
145156 },
146157 }},
147158 }
@@ -405,6 +416,7 @@ func TestIssuer_Set(t *testing.T) {
405416 CommonName : "The commonName" ,
406417 ExtraNames : []DistinguishedName {
407418 {
Type :
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value :
"[email protected] " },
419+ {
Type :
ObjectIdentifier {
1 ,
2 ,
3 ,
4 },
Value :
"[email protected] " },
408420 },
409421 }, args {& x509.Certificate {}}, & x509.Certificate {
410422 Issuer : pkix.Name {
@@ -418,7 +430,8 @@ func TestIssuer_Set(t *testing.T) {
418430 SerialNumber : "The serialNumber" ,
419431 CommonName : "The commonName" ,
420432 ExtraNames : []pkix.AttributeTypeAndValue {
421- {
Type : asn1.
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value :
"[email protected] " },
433+ {
Type : asn1.
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value : asn1.
RawValue {
Class :
asn1 .
ClassUniversal ,
Tag :
asn1 .
TagIA5String ,
Bytes : []
byte (
"[email protected] " )}},
434+ {
Type : asn1.
ObjectIdentifier {
1 ,
2 ,
3 ,
4 },
Value :
"[email protected] " },
422435 },
423436 },
424437 }},
@@ -452,7 +465,7 @@ func TestIssuer_Set(t *testing.T) {
452465 }
453466}
454467
455- func Test_newDistinguisedNames (t * testing.T ) {
468+ func Test_newExtraNames (t * testing.T ) {
456469 type args struct {
457470 atvs []pkix.AttributeTypeAndValue
458471 }
@@ -462,15 +475,18 @@ func Test_newDistinguisedNames(t *testing.T) {
462475 want []DistinguishedName
463476 }{
464477 {"ok" , args {[]pkix.AttributeTypeAndValue {
465- {
Type : asn1.
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value :
"[email protected] " },
478+ {Type : asn1.ObjectIdentifier {2 , 5 , 4 , 3 }, Value : "The commonName" },
479+ {
Type : asn1.
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value : asn1.
RawValue {
Class :
asn1 .
ClassUniversal ,
Tag :
asn1 .
TagIA5String ,
Bytes : []
byte (
"[email protected] " )}},
480+ {
Type : asn1.
ObjectIdentifier {
1 ,
2 ,
3 ,
4 },
Value :
"[email protected] " },
466481 }}, []DistinguishedName {
467- {
Type :
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value :
"[email protected] " },
482+ {
Type :
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value : asn1.
RawValue {
Class :
asn1 .
ClassUniversal ,
Tag :
asn1 .
TagIA5String ,
Bytes : []
byte (
"[email protected] " )}},
483+ {
Type :
ObjectIdentifier {
1 ,
2 ,
3 ,
4 },
Value :
"[email protected] " },
468484 }},
469485 {"ok nil" , args {nil }, nil },
470486 }
471487 for _ , tt := range tests {
472488 t .Run (tt .name , func (t * testing.T ) {
473- if got := newDistinguisedNames (tt .args .atvs ); ! reflect .DeepEqual (got , tt .want ) {
489+ if got := newExtraNames (tt .args .atvs ); ! reflect .DeepEqual (got , tt .want ) {
474490 t .Errorf ("newDistinguisedNames() = %v, want %v" , got , tt .want )
475491 }
476492 })
@@ -488,14 +504,16 @@ func Test_fromDistinguisedNames(t *testing.T) {
488504 }{
489505 {"ok" , args {[]DistinguishedName {
490506 {
Type :
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value :
"[email protected] " },
507+ {
Type :
ObjectIdentifier {
1 ,
2 ,
3 ,
4 },
Value :
"[email protected] " },
491508 }}, []pkix.AttributeTypeAndValue {
492- {
Type : asn1.
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value :
"[email protected] " },
509+ {
Type : asn1.
ObjectIdentifier {
1 ,
2 ,
840 ,
113549 ,
1 ,
9 ,
1 },
Value : asn1.
RawValue {
Class :
asn1 .
ClassUniversal ,
Tag :
asn1 .
TagIA5String ,
Bytes : []
byte (
"[email protected] " )}},
510+ {
Type : asn1.
ObjectIdentifier {
1 ,
2 ,
3 ,
4 },
Value :
"[email protected] " },
493511 }},
494512 {"ok nil" , args {nil }, nil },
495513 }
496514 for _ , tt := range tests {
497515 t .Run (tt .name , func (t * testing.T ) {
498- if got := fromDistinguisedNames (tt .args .dns ); ! reflect .DeepEqual (got , tt .want ) {
516+ if got := fromDistinguishedNames (tt .args .dns ); ! reflect .DeepEqual (got , tt .want ) {
499517 t .Errorf ("fromDistinguisedNames() = %v, want %v" , got , tt .want )
500518 }
501519 })
0 commit comments