Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions builtin/logical/totp/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ func TestBackend_keyCrudDefaultValues(t *testing.T) {
testAccStepReadKey(t, "test", expected),
testAccStepValidateCode(t, "test", code, true, false),
// Next step should fail because it should be in the used cache
testAccStepValidateCode(t, "test", code+" ", false, true),
testAccStepValidateCode(t, "test", " "+code, false, true),
testAccStepValidateCode(t, "test", code, false, true),
testAccStepValidateCode(t, "test", invalidCode, false, false),
testAccStepDeleteKey(t, "test"),
Expand Down
3 changes: 2 additions & 1 deletion builtin/logical/totp/path_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package totp
import (
"context"
"fmt"
"strings"
"time"

"github.com/hashicorp/vault/sdk/framework"
Expand Down Expand Up @@ -86,7 +87,7 @@ func (b *backend) pathReadCode(ctx context.Context, req *logical.Request, data *

func (b *backend) pathValidateCode(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
name := data.Get("name").(string)
code := data.Get("code").(string)
code := strings.TrimSpace(data.Get("code").(string))

// Enforce input value requirements
if code == "" {
Expand Down
Loading