@@ -2,6 +2,7 @@ package integration
22
33import (
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 }
0 commit comments