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 12, 2019
1 parent 3d38341 commit 22851ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion backend.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 @@ -55,7 +56,8 @@ func (b *backend) rtClient(ctx context.Context, s logical.Storage) (*rtHttpClien
}

rtDetails := rtAuth.NewArtifactoryDetails()
rtDetails.SetUrl(config.Address)
// Ensure trailing slash, rtClient assumes this when building URLs
rtDetails.SetUrl(strings.TrimSuffix(config.Address, "/") + "/")
rtDetails.SetApiKey(config.ApiKey)
rtDetails.SetUser(config.Username)
rtDetails.SetPassword(config.Password)
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 22851ae

Please sign in to comment.