Skip to content

Commit ab78534

Browse files
committed
add test for SAN backwards compatibility with CLI
* new provisioner tokens always contain the crt.Subject.CommonName in the SANS attribute of the token claims. added tests that verifies backwards compatibility still works in cases where the token does not contain the subject as a SAN claim.
1 parent fe8c861 commit ab78534

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

ca/ca_test.go

+33
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,39 @@ ZEp7knvU2psWRw==
218218
status: http.StatusCreated,
219219
}
220220
},
221+
"ok-backwards-compat-missing-subject-SAN": func(t *testing.T) *signTest {
222+
jti, err := randutil.ASCII(32)
223+
assert.FatalError(t, err)
224+
cl := struct {
225+
jwt.Claims
226+
SANS []string `json:"sans"`
227+
}{
228+
Claims: jwt.Claims{
229+
Subject: "test.smallstep.com",
230+
Issuer: "step-cli",
231+
NotBefore: jwt.NewNumericDate(now),
232+
Expiry: jwt.NewNumericDate(now.Add(time.Minute)),
233+
Audience: validAud,
234+
ID: jti,
235+
},
236+
}
237+
raw, err := jwt.Signed(sig).Claims(cl).CompactSerialize()
238+
assert.FatalError(t, err)
239+
csr, err := getCSR(priv)
240+
assert.FatalError(t, err)
241+
body, err := json.Marshal(&api.SignRequest{
242+
CsrPEM: api.CertificateRequest{CertificateRequest: csr},
243+
OTT: raw,
244+
NotBefore: now,
245+
NotAfter: leafExpiry,
246+
})
247+
assert.FatalError(t, err)
248+
return &signTest{
249+
ca: ca,
250+
body: string(body),
251+
status: http.StatusCreated,
252+
}
253+
},
221254
}
222255

223256
for name, genTestCase := range tests {

0 commit comments

Comments
 (0)