(t *testing.T)
| 278 | } |
| 279 | |
| 280 | func 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 | |
| 308 | func getTwoBoringCerts(t *testing.T) (*ssh.Certificate, *ssh.Certificate) { |
| 309 | pubKeyOne, _, _, _, err := ssh.ParseAuthorizedKey([]byte(boringUserCertString)) |
nothing calls this directly
no test coverage detected