Skip to content

Commit

Permalink
Add missing error handling and a few more test assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
stevendpclark committed Dec 12, 2024
1 parent 4af9d43 commit bdc4abd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions builtin/logical/pki/path_acme_account_mgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ func (b *backend) pathAcmeMgmtUpdateAccount(ctx context.Context, r *logical.Requ
}

status, err := convertToAccountStatus(d.Get("status"))
if err != nil {
return logical.ErrorResponse(err.Error()), logical.ErrInvalidRequest
}
if status != AccountStatusValid && status != AccountStatusRevoked {
return logical.ErrorResponse("invalid status %q", status), logical.ErrInvalidRequest
}
Expand Down
6 changes: 5 additions & 1 deletion builtin/logical/pki/path_acme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1860,7 +1860,11 @@ func TestVaultOperatorACMEDisableWorkflow(t *testing.T) {
require.ErrorContains(t, err, "account in status: revoked", "Requesting an order with a revoked account should have failed")

// Switch the account back to valid and make sure we can use it again
_, err = vaultClient.Logical().WriteWithContext(testCtx, "pki/acme/mgmt/account/keyid/"+kid, map[string]interface{}{"status": "valid"})
resp, err = vaultClient.Logical().WriteWithContext(testCtx, "pki/acme/mgmt/account/keyid/"+kid, map[string]interface{}{"status": "valid"})
require.NoError(t, err, "failed updating writing ACME with account key")
require.Empty(t, resp.Data["revoked_time"], "revoked_time should have been reset")
require.Equal(t, "valid", resp.Data["status"], "status should have been reset to valid")

doACMEOrderWorkflow(t, vaultClient, acmeClient, acct)
}

Expand Down

0 comments on commit bdc4abd

Please sign in to comment.