Skip to content

Commit

Permalink
Merge pull request #1373 from cyberark/fix-keychain-tests
Browse files Browse the repository at this point in the history
Fix Keychain tests
  • Loading branch information
BradleyBoutcher authored Feb 3, 2021
2 parents cf03dfa + 42e459f commit 418b909
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ require (
github.com/joho/godotenv v1.2.0
github.com/json-iterator/go v1.1.8 // indirect
github.com/lib/pq v0.0.0-20180123210206-19c8e9ad0095
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/pkg/errors v0.8.1
github.com/pkg/profile v1.2.1
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ github.com/containerd/containerd v1.3.2 h1:ForxmXkA6tPIvffbrDAcPUIB32QgXkt2XFj+F
github.com/containerd/containerd v1.3.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/cyberark/conjur-api-go v0.5.2 h1:8ntk07YNRz5bBwjNXkDEAPR70Yr+J2MN8NGlkhaMC3k=
github.com/cyberark/conjur-api-go v0.5.2/go.mod h1:hwaReWirzgKor+JtH6vbwZaASDXulvd0SzGCloC5uOc=
github.com/cyberark/conjur-authn-k8s-client v0.13.0/go.mod h1:JTeGIeRO59J7mMEc5yF6FPtk1QnaAzs4GyZa4WldqZc=
github.com/cyberark/conjur-authn-k8s-client v0.19.0 h1:zHjdKyZ8bu4cRyV3iYMh1/XfIVtTugoiU/CflnboP9Q=
github.com/cyberark/conjur-authn-k8s-client v0.19.0/go.mod h1:qacUJXCppU1Rg/C+br9B1jBitTq4yG04oc4a+cfI200=
github.com/cyberark/secretless-broker v1.4.1-0.20191211191712-251c5ec034af/go.mod h1:+GueI3WCJL5gDYaYa38ZokAR8ceEyCVet7MkuZyjf80=
Expand Down
6 changes: 4 additions & 2 deletions internal/plugin/v1/testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ type CanProvideTestCase struct {

// CanProvide calls GetValues on the provider and ensures that the provider response for
// the given id has the expected value and no error
func CanProvide(provider plugin_v1.Provider, id string, expectedValue string) func() {
func CanProvide(provider plugin_v1.Provider,
id string,
expectedValue string) func() {
return func() {
values, err := provider.GetValues(id)

convey.So(values[id].Error, convey.ShouldBeNil)
convey.So(err, convey.ShouldBeNil)

value := values[id]
assertGoodProviderResponse(value, expectedValue)
}
Expand Down
7 changes: 4 additions & 3 deletions test/providers/keychain/keychain_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"os"
"strconv"
"testing"

plugin_v1 "github.com/cyberark/secretless-broker/internal/plugin/v1"
Expand All @@ -24,11 +25,11 @@ func TestKeychainProvider(t *testing.T) {

// e.g. ${service}_1#${account}_1
getSecretPath := func(idx int) string {
return service + "_" + string(idx) + "#" + account + "_" + string(idx)
return service + "_" + strconv.Itoa(idx) + "#" + account + "_" + strconv.Itoa(idx)
}
// e.g. ${secret}_1
getSecretValue := func(idx int) string {
return secret + "_" + string(idx)
return secret + "_" + strconv.Itoa(idx)
}

options := plugin_v1.ProviderOptions{
Expand Down Expand Up @@ -72,7 +73,7 @@ func TestKeychainProvider(t *testing.T) {
Convey(
"Returns an error for an invalid secret value",
t,
testutils.CanProvide(
testutils.Reports(
provider,
"madeup#secret",
"The specified item could not be found in the keychain.",
Expand Down

0 comments on commit 418b909

Please sign in to comment.