Skip to content

Commit e1497c8

Browse files
committed
save
1 parent d155fc7 commit e1497c8

File tree

4 files changed

+13
-35
lines changed

4 files changed

+13
-35
lines changed

service/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ require (
5656
cel.dev/expr v0.19.1 // indirect
5757
github.com/Masterminds/semver/v3 v3.3.1 // indirect
5858
github.com/containerd/continuity v0.4.4 // indirect
59+
github.com/oklog/ulid/v2 v2.1.0 // indirect
5960
github.com/stretchr/objx v0.5.2 // indirect
6061
)
6162

service/go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
256256
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
257257
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
258258
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
259+
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
260+
github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
259261
github.com/open-policy-agent/opa v1.4.2 h1:ag4upP7zMsa4WE2p1pwAFeG4Pn3mNwfAx9DLhhJfbjU=
260262
github.com/open-policy-agent/opa v1.4.2/go.mod h1:DNzZPKqKh4U0n0ANxcCVlw8lCSv2c+h5G/3QvSYdWZ8=
261263
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
@@ -282,6 +284,7 @@ github.com/ory/dockertest/v3 v3.10.0 h1:4K3z2VMe8Woe++invjaTB7VRyQXQy5UY+loujO4a
282284
github.com/ory/dockertest/v3 v3.10.0/go.mod h1:nr57ZbRWMqfsdGdFNLHz5jjNdDb7VVFnzAeW1n5N1Lg=
283285
github.com/paulmach/orb v0.10.0 h1:guVYVqzxHE/CQ1KpfGO077TR0ATHSNjp4s6XGLn3W9s=
284286
github.com/paulmach/orb v0.10.0/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU=
287+
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
285288
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
286289
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
287290
github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ=

service/integration/attribute_fqns_test.go

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package integration
22

33
import (
44
"context"
5+
"encoding/base64"
56
"fmt"
67
"log/slog"
78
"strings"
@@ -142,14 +143,6 @@ func (s *AttributeFqnSuite) TestGetAttributeByFqn_WithCasingNormalized() {
142143
valueFixture := s.f.GetAttributeValueKey(fqnFixtureKey)
143144
key := s.f.GetKasRegistryServerKeys("kas_key_1")
144145

145-
// assign a KAS grant to the value
146-
kas, err := s.db.PolicyClient.CreateKeyAccessServer(s.ctx, &kasregistry.CreateKeyAccessServerRequest{
147-
Uri: "https://testing_granted_values.com/kas",
148-
PublicKey: &policy.PublicKey{},
149-
})
150-
s.Require().NoError(err)
151-
s.NotNil(kas)
152-
153146
grant, err := s.db.PolicyClient.AssignPublicKeyToValue(s.ctx, &attributes.ValueKey{
154147
KeyId: key.ID,
155148
ValueId: valueFixture.ID,
@@ -449,14 +442,6 @@ func (s *AttributeFqnSuite) TestGetAttributeByFqn_WithKeyAccessGrants_Definition
449442
s.Require().NoError(err)
450443
s.NotNil(a)
451444

452-
// create a new kas registration
453-
remoteKAS, err := s.db.PolicyClient.CreateKeyAccessServer(s.ctx, &kasregistry.CreateKeyAccessServerRequest{
454-
Uri: "https://example.org/kas",
455-
PublicKey: &policy.PublicKey{},
456-
})
457-
s.Require().NoError(err)
458-
s.NotNil(remoteKAS)
459-
460445
// make a first grant association to the attribute definition
461446
keyMapping, err := s.db.PolicyClient.AssignPublicKeyToAttribute(s.ctx, &attributes.AttributeKey{
462447
KeyId: key.ID,
@@ -465,17 +450,6 @@ func (s *AttributeFqnSuite) TestGetAttributeByFqn_WithKeyAccessGrants_Definition
465450
s.Require().NoError(err)
466451
s.NotNil(keyMapping)
467452

468-
// create a second kas registration and grant it to the attribute definition
469-
cachedKeyPem := "cached_key"
470-
cachedKASName := "test_kas_name"
471-
cachedKas, err := s.db.PolicyClient.CreateKeyAccessServer(s.ctx, &kasregistry.CreateKeyAccessServerRequest{
472-
Uri: "https://example.org/kas2",
473-
PublicKey: &policy.PublicKey{},
474-
Name: cachedKASName,
475-
})
476-
s.Require().NoError(err)
477-
s.NotNil(cachedKas)
478-
479453
keyMapping2, err := s.db.PolicyClient.AssignPublicKeyToAttribute(s.ctx, &attributes.AttributeKey{
480454
KeyId: key2.ID,
481455
AttributeId: a.GetId(),
@@ -490,16 +464,15 @@ func (s *AttributeFqnSuite) TestGetAttributeByFqn_WithKeyAccessGrants_Definition
490464

491465
// ensure the attribute has the grants
492466
s.Len(got.GetGrants(), 2)
493-
grantIDs := []string{remoteKAS.GetId(), cachedKas.GetId()}
467+
grantIDs := []string{key.KeyAccessServerID, key2.KeyAccessServerID}
494468
s.Contains(grantIDs, got.GetGrants()[0].GetId())
495469
s.Contains(grantIDs, got.GetGrants()[1].GetId())
496-
s.NotEqual(got.GetGrants()[0].GetId(), got.GetGrants()[1].GetId())
497-
// ensure grant has cached key pem
498470
pemIsPresent := false
499-
for _, g := range got.GetGrants() {
471+
472+
for i, g := range got.GetGrants() {
500473
if g.GetId() == key2.KeyAccessServerID {
501-
s.Equal(g.GetPublicKey().GetCached().GetKeys()[0].GetPem(), cachedKeyPem)
502-
s.Equal(g.GetName(), cachedKASName)
474+
s.Equal(base64.StdEncoding.EncodeToString([]byte(g.GetPublicKey().GetCached().GetKeys()[i].GetPem())), key2.PublicKeyCtx)
475+
s.Equal(g.GetId(), key2.KeyAccessServerID)
503476
pemIsPresent = true
504477
}
505478
}

service/integration/main_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/creasty/defaults"
1313
"github.com/docker/docker/api/types/container"
1414
"github.com/docker/go-connections/nat"
15+
"github.com/oklog/ulid/v2"
1516
"github.com/opentdf/platform/service/internal/fixtures"
1617
tc "github.com/testcontainers/testcontainers-go"
1718
"github.com/testcontainers/testcontainers-go/wait"
@@ -73,14 +74,14 @@ func TestMain(m *testing.M) {
7374
ProviderType: providerType,
7475
ContainerRequest: tc.ContainerRequest{
7576
Image: "postgres:15-alpine",
76-
Name: "testcontainer-postgres",
77+
Name: "testcontainer-postgres-" + ulid.Make().String(),
7778
ExposedPorts: []string{"5432/tcp"},
7879
HostConfigModifier: func(config *container.HostConfig) {
7980
config.PortBindings = nat.PortMap{
8081
"5432/tcp": []nat.PortBinding{
8182
{
8283
HostIP: "0.0.0.0",
83-
HostPort: "54322",
84+
HostPort: "",
8485
},
8586
},
8687
}

0 commit comments

Comments
 (0)