MCPcopy Create free account
hub / github.com/cloudtools/ssh-cert-authority / TestValidateCert

Function TestValidateCert

sign_certd_test.go:280–306  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

278}
279
280func TestValidateCert(t *testing.T) {
281 allConfig := SetupSignerdConfig(1, 0)
282 environment := "testing"
283 envConfig := allConfig[environment]
284 requestHandler := makeCertRequestHandler(allConfig)
285
286 pubKey, _, _, _, err := ssh.ParseAuthorizedKey([]byte(boringUserCertString))
287 if err != nil {
288 t.Fatalf("Parsing canned cert failed: %v", err)
289 }
290 cert := pubKey.(*ssh.Certificate)
291
292 // test-user is *not* in the list of authorized signers
293
294 err = requestHandler.validateCert(cert, envConfig.AuthorizedSigners)
295
296 if err == nil {
297 t.Fatalf("Should have failed. Succeeded with: %v", err)
298 }
299
300 // test-user *is* in the list of authorized users
301
302 err = requestHandler.validateCert(cert, envConfig.AuthorizedUsers)
303 if err != nil {
304 t.Fatalf("Should have succeeded. Failed with: %v", err)
305 }
306}
307
308func getTwoBoringCerts(t *testing.T) (*ssh.Certificate, *ssh.Certificate) {
309 pubKeyOne, _, _, _, err := ssh.ParseAuthorizedKey([]byte(boringUserCertString))

Callers

nothing calls this directly

Calls 3

SetupSignerdConfigFunction · 0.85
makeCertRequestHandlerFunction · 0.85
validateCertMethod · 0.80

Tested by

no test coverage detected