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
4 changes: 2 additions & 2 deletions store/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require (
filippo.io/age v1.3.1
github.com/danieljoos/wincred v1.2.3
github.com/docker/secrets-engine/secrets v1.0.0
github.com/docker/secrets-engine/x v0.8.5
github.com/godbus/dbus/v5 v5.1.0
github.com/stretchr/testify v1.11.1
golang.org/x/crypto v0.52.0
Expand All @@ -24,7 +23,8 @@ require (
filippo.io/edwards25519 v1.1.0 // indirect
filippo.io/hpke v0.4.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/kr/text v0.2.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
5 changes: 5 additions & 0 deletions store/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
Expand Down
46 changes: 23 additions & 23 deletions store/keychain/keychain_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package keychain
import (
"bytes"
"context"
"crypto/rand"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -27,12 +28,11 @@ import (
"github.com/docker/secrets-engine/secrets"
kc "github.com/docker/secrets-engine/store/keychain/internal/go-keychain"
"github.com/docker/secrets-engine/store/mocks"
"github.com/docker/secrets-engine/x/testhelper"
)

func TestMacosKeychain(t *testing.T) {
var (
serviceName = testhelper.RandomString()
serviceName = rand.Text()
serviceGroup = "com.test.testing"
)
keychainStore := keychainStore[*mocks.MockCredential]{
Expand All @@ -44,9 +44,9 @@ func TestMacosKeychain(t *testing.T) {
}

ids := []string{
serviceGroup + "/" + serviceName + "/" + testhelper.RandomString(),
serviceGroup + "/" + serviceName + "/" + testhelper.RandomString(),
serviceGroup + "/" + serviceName + "/" + testhelper.RandomString(),
serviceGroup + "/" + serviceName + "/" + rand.Text(),
serviceGroup + "/" + serviceName + "/" + rand.Text(),
serviceGroup + "/" + serviceName + "/" + rand.Text(),
}
t.Cleanup(func() {
for _, id := range ids {
Expand All @@ -55,8 +55,8 @@ func TestMacosKeychain(t *testing.T) {
})
for _, id := range ids {
assert.NoError(t, keychainStore.Save(t.Context(), secrets.MustParseID(id), &mocks.MockCredential{
Username: testhelper.RandomString(),
Password: testhelper.RandomString(),
Username: rand.Text(),
Password: rand.Text(),
Attributes: map[string]string{
"color": "purple",
"game": "unknown",
Expand All @@ -65,10 +65,10 @@ func TestMacosKeychain(t *testing.T) {
}

t.Run("can store secret that has no attribute", func(t *testing.T) {
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + testhelper.RandomString())
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + rand.Text())

secret := &mocks.MockCredential{
Username: testhelper.RandomString(),
Username: rand.Text(),
Password: "bob2",
}
t.Cleanup(func() {
Expand All @@ -81,14 +81,14 @@ func TestMacosKeychain(t *testing.T) {
})

t.Run("can store large attributes", func(t *testing.T) {
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + testhelper.RandomString())
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + rand.Text())
t.Cleanup(func() {
assert.NoError(t, keychainStore.Delete(t.Context(), id))
})

large := bytes.Repeat([]byte{'a'}, 1024*1024)
secret := &mocks.MockCredential{
Username: testhelper.RandomString(),
Username: rand.Text(),
Password: "bob2",
Attributes: map[string]string{
"large": string(large),
Expand All @@ -103,13 +103,13 @@ func TestMacosKeychain(t *testing.T) {
})

t.Run("filter populates both metadata and secret", func(t *testing.T) {
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + testhelper.RandomString())
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + rand.Text())

t.Cleanup(func() {
assert.NoError(t, keychainStore.Delete(t.Context(), id))
})
secret := &mocks.MockCredential{
Username: testhelper.RandomString(),
Username: rand.Text(),
Password: "bob2",
Attributes: map[string]string{
"game": "elden ring",
Expand All @@ -129,13 +129,13 @@ func TestMacosKeychain(t *testing.T) {
})

t.Run("can use pattern only matching service name", func(t *testing.T) {
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + testhelper.RandomString())
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + rand.Text())

t.Cleanup(func() {
assert.NoError(t, keychainStore.Delete(t.Context(), id))
})
secret := &mocks.MockCredential{
Username: testhelper.RandomString(),
Username: rand.Text(),
Password: "bob2",
Attributes: map[string]string{
"color": "blue",
Expand All @@ -153,7 +153,7 @@ func TestMacosKeychain(t *testing.T) {

func TestUpsert(t *testing.T) {
var (
serviceName = testhelper.RandomString()
serviceName = rand.Text()
serviceGroup = "com.test.testing"
)
ks := keychainStore[*mocks.MockCredential]{
Expand All @@ -165,7 +165,7 @@ func TestUpsert(t *testing.T) {
}

t.Run("inserts when credential does not exist", func(t *testing.T) {
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + testhelper.RandomString())
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + rand.Text())
t.Cleanup(func() {
assert.NoError(t, ks.Delete(t.Context(), id))
})
Expand All @@ -185,7 +185,7 @@ func TestUpsert(t *testing.T) {
})

t.Run("overwrites an existing credential", func(t *testing.T) {
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + testhelper.RandomString())
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + rand.Text())
t.Cleanup(func() {
assert.NoError(t, ks.Delete(t.Context(), id))
})
Expand All @@ -211,7 +211,7 @@ func TestUpsert(t *testing.T) {
})

t.Run("updates an existing credential in place", func(t *testing.T) {
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + testhelper.RandomString())
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + rand.Text())
t.Cleanup(func() {
assert.NoError(t, ks.Delete(t.Context(), id))
})
Expand Down Expand Up @@ -261,7 +261,7 @@ func TestUpsert(t *testing.T) {
return &bufferSecret{}
},
}
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + testhelper.RandomString())
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + rand.Text())
t.Cleanup(func() {
assert.NoError(t, bs.Delete(t.Context(), id))
})
Expand All @@ -281,7 +281,7 @@ func TestUpsert(t *testing.T) {
return &bufferSecret{}
},
}
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + testhelper.RandomString())
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + rand.Text())
t.Cleanup(func() {
assert.NoError(t, bs.Delete(t.Context(), id))
})
Expand All @@ -303,7 +303,7 @@ func TestUpsert(t *testing.T) {
return &bufferSecret{}
},
}
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + testhelper.RandomString())
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + rand.Text())
t.Cleanup(func() {
assert.NoError(t, bs.Delete(t.Context(), id))
})
Expand All @@ -316,7 +316,7 @@ func TestUpsert(t *testing.T) {
})

t.Run("save returns duplicate item error when credential already exists", func(t *testing.T) {
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + testhelper.RandomString())
id := secrets.MustParseID(serviceGroup + "/" + serviceName + "/" + rand.Text())
t.Cleanup(func() {
assert.NoError(t, ks.Delete(t.Context(), id))
})
Expand Down
Loading
Loading