Skip to content

Commit

Permalink
Update test semantics for new changes
Browse files Browse the repository at this point in the history
This makes two minor changes to the existing test suite:

 1. Importing partial bundles should now succeed, where they'd
    previously error.
 2. fetchCertBySerial no longer handles CA certificates.

Signed-off-by: Alexander Scheel <[email protected]>
  • Loading branch information
cipherboy committed Apr 12, 2022
1 parent ba6e218 commit f7422e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
18 changes: 9 additions & 9 deletions builtin/logical/pki/ca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
// Load CA cert/key in and ensure we can fetch it back in various formats,
// unauthenticated
{
// Attempt import but only provide one the cert
// Attempt import but only provide one the cert; this should work.
{
_, err := client.Logical().WriteWithContext(context.Background(), rootName+"config/ca", map[string]interface{}{
"pem_bundle": caCert,
})
if err == nil {
t.Fatal("expected error")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
}

Expand All @@ -272,18 +272,18 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
_, err := client.Logical().WriteWithContext(context.Background(), rootName+"config/ca", map[string]interface{}{
"pem_bundle": caKey,
})
if err == nil {
t.Fatal("expected error")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
}

// Import CA bundle
// Import entire CA bundle; this should work as well
{
_, err := client.Logical().WriteWithContext(context.Background(), rootName+"config/ca", map[string]interface{}{
"pem_bundle": strings.Join([]string{caKey, caCert}, "\n"),
})
if err != nil {
t.Fatal(err)
t.Fatalf("unexpected error: %v", err)
}
}

Expand Down Expand Up @@ -464,8 +464,8 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
if err != nil {
t.Fatal(err)
}
if resp != nil {
t.Fatal("expected nil response")
if resp == nil {
t.Fatal("nil response")
}
}

Expand Down
7 changes: 0 additions & 7 deletions builtin/logical/pki/cert_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,6 @@ func TestPki_FetchCertBySerial(t *testing.T) {
Prefix string
Serial string
}{
"ca": {
&logical.Request{
Storage: storage,
},
"",
"ca",
},
"crl": {
&logical.Request{
Storage: storage,
Expand Down

0 comments on commit f7422e1

Please sign in to comment.