@@ -20,6 +20,7 @@ import (
2020 "github.com/spiffe/spire-api-sdk/proto/spire/api/types"
2121 "github.com/spiffe/spire/pkg/common/idutil"
2222 "github.com/spiffe/spire/pkg/common/telemetry"
23+ "github.com/spiffe/spire/pkg/common/x509svid"
2324 "github.com/spiffe/spire/pkg/common/x509util"
2425 "github.com/spiffe/spire/pkg/server/api"
2526 "github.com/spiffe/spire/pkg/server/api/middleware"
@@ -76,7 +77,7 @@ func TestServiceMintX509SVID(t *testing.T) {
7677 URIs : []* url.URL {workloadID .URL ()},
7778 },
7879 expiredAt : expiredAt ,
79- subject : "O=SPIRE,C=US" ,
80+ subject : "O=SPIRE,C=US,2.5.4.45=#13203835323763353230323837636461376436323561613834373664386538336561 " ,
8081 expectLogs : func (csr []byte ) []spiretest.LogEntry {
8182 return []spiretest.LogEntry {
8283 {
@@ -102,7 +103,7 @@ func TestServiceMintX509SVID(t *testing.T) {
102103 URIs : []* url.URL {workloadID .URL ()},
103104 },
104105 expiredAt : customExpiresAt ,
105- subject : "O=SPIRE,C=US" ,
106+ subject : "O=SPIRE,C=US,2.5.4.45=#13203835323763353230323837636461376436323561613834373664386538336561 " ,
106107 ttl : 10 * time .Second ,
107108 expectLogs : func (csr []byte ) []spiretest.LogEntry {
108109 return []spiretest.LogEntry {
@@ -131,7 +132,7 @@ func TestServiceMintX509SVID(t *testing.T) {
131132 },
132133 dns : []string {"dns1" , "dns2" },
133134 expiredAt : expiredAt ,
134- subject : "CN=dns1,O=SPIRE,C=US" ,
135+ subject : "CN=dns1,O=SPIRE,C=US,2.5.4.45=#13203835323763353230323837636461376436323561613834373664386538336561 " ,
135136 expectLogs : func (csr []byte ) []spiretest.LogEntry {
136137 return []spiretest.LogEntry {
137138 {
@@ -161,7 +162,7 @@ func TestServiceMintX509SVID(t *testing.T) {
161162 },
162163 },
163164 expiredAt : expiredAt ,
164- subject : "O=ORG,C=EN+C=US" ,
165+ subject : "O=ORG,C=EN+C=US,2.5.4.45=#13203835323763353230323837636461376436323561613834373664386538336561 " ,
165166 expectLogs : func (csr []byte ) []spiretest.LogEntry {
166167 return []spiretest.LogEntry {
167168 {
@@ -193,7 +194,7 @@ func TestServiceMintX509SVID(t *testing.T) {
193194 },
194195 dns : []string {"dns1" , "dns2" },
195196 expiredAt : expiredAt ,
196- subject : "CN=dns1,O=ORG,C=EN+C=US" ,
197+ subject : "CN=dns1,O=ORG,C=EN+C=US,2.5.4.45=#13203835323763353230323837636461376436323561613834373664386538336561 " ,
197198 expectLogs : func (csr []byte ) []spiretest.LogEntry {
198199 return []spiretest.LogEntry {
199200 {
@@ -1719,8 +1720,8 @@ func TestServiceBatchNewX509SVID(t *testing.T) {
17191720 require .NotEmpty (t , certChain )
17201721 svid := certChain [0 ]
17211722
1722- entryID := idutil .RequireIDFromProto (entry .SpiffeId )
1723- require .Equal (t , []* url.URL {entryID .URL ()}, svid .URIs )
1723+ entrySPIFFEID := idutil .RequireIDFromProto (entry .SpiffeId )
1724+ require .Equal (t , []* url.URL {entrySPIFFEID .URL ()}, svid .URIs )
17241725
17251726 // Use entry ttl when defined
17261727 ttl := test .ca .X509SVIDTTL ()
@@ -1734,14 +1735,16 @@ func TestServiceBatchNewX509SVID(t *testing.T) {
17341735
17351736 require .Equal (t , entry .DnsNames , svid .DNSNames )
17361737
1737- expectedSubject := & pkix.Name {Country : []string {"US" }, Organization : []string {"SPIRE" }}
1738+ expectedSubject := & pkix.Name {
1739+ Organization : []string {"SPIRE" },
1740+ Country : []string {"US" },
1741+ Names : []pkix.AttributeTypeAndValue {
1742+ x509svid .UniqueIDAttribute (entrySPIFFEID ),
1743+ },
1744+ }
17381745 if len (entry .DnsNames ) > 0 {
1739- name := entry .DnsNames [0 ]
1740-
1741- expectedSubject .CommonName = name
1742- require .Equal (t , name , svid .Subject .CommonName )
1746+ expectedSubject .CommonName = entry .DnsNames [0 ]
17431747 }
1744-
17451748 require .Equal (t , expectedSubject .String (), svid .Subject .String ())
17461749 }
17471750 })
0 commit comments