Skip to content

Commit

Permalink
config: Ensure address has trailing slash
Browse files Browse the repository at this point in the history
  • Loading branch information
jsok committed Aug 10, 2019
1 parent 3d38341 commit 626cb8e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions path_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package artifactory
import (
"context"
"fmt"
"strings"

"github.com/hashicorp/vault/sdk/framework"
"github.com/hashicorp/vault/sdk/logical"
Expand Down Expand Up @@ -86,6 +87,9 @@ func (b *backend) pathConfigWrite(ctx context.Context, req *logical.Request, dat
if config.Address == "" {
return logical.ErrorResponse("address must be set"), nil
}
if !strings.HasSuffix(config.Address, "/") {
config.Address = config.Address + "/"
}
if config.ApiKey != "" && config.Username != "" {
return logical.ErrorResponse("provide either api_key or username, not both"), nil
}
Expand Down
2 changes: 1 addition & 1 deletion path_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestConfig_WriteIdempotent(t *testing.T) {
b, storage := newBackend(t)

data := map[string]interface{}{
"address": "https://example.com/artifactory",
"address": "https://example.com/artifactory/",
"api_key": "abc123",
}

Expand Down

0 comments on commit 626cb8e

Please sign in to comment.