@@ -242,6 +242,7 @@ func (s *AttributeFqnSuite) TestGetAttributeByFqn_WithKeyAccessGrants_Definition
242242
243243 // create a second kas registration and grant it to the attribute definition
244244 cachedKeyPem := "cached_key"
245+ cachedKASName := "test_kas_name"
245246 cachedKas , err := s .db .PolicyClient .CreateKeyAccessServer (s .ctx , & kasregistry.CreateKeyAccessServerRequest {
246247 Uri : "https://example.org/kas2" ,
247248 PublicKey : & policy.PublicKey {
@@ -255,6 +256,7 @@ func (s *AttributeFqnSuite) TestGetAttributeByFqn_WithKeyAccessGrants_Definition
255256 },
256257 },
257258 },
259+ Name : cachedKASName ,
258260 })
259261 s .Require ().NoError (err )
260262 s .NotNil (cachedKas )
@@ -283,6 +285,7 @@ func (s *AttributeFqnSuite) TestGetAttributeByFqn_WithKeyAccessGrants_Definition
283285 for _ , g := range got .GetGrants () {
284286 if g .GetId () == cachedKasID {
285287 s .Equal (g .GetPublicKey ().GetCached ().GetKeys ()[0 ].GetPem (), cachedKeyPem )
288+ s .Equal (g .GetName (), cachedKASName )
286289 pemIsPresent = true
287290 }
288291 }
@@ -350,13 +353,15 @@ func (s *AttributeFqnSuite) TestGetAttributeByFqn_WithKeyAccessGrants_Values() {
350353 s .Empty (got .GetValues ()[0 ].GetGrants ())
351354
352355 // create a new kas registration
356+ remoteKASName := "testing-io-remote"
353357 remoteKAS , err := s .db .PolicyClient .CreateKeyAccessServer (s .ctx , & kasregistry.CreateKeyAccessServerRequest {
354358 Uri : "https://testing.io/kas" ,
355359 PublicKey : & policy.PublicKey {
356360 PublicKey : & policy.PublicKey_Remote {
357361 Remote : "https://testing.org/kas" ,
358362 },
359363 },
364+ Name : remoteKASName ,
360365 })
361366 s .Require ().NoError (err )
362367 s .NotNil (remoteKAS )
@@ -370,7 +375,8 @@ func (s *AttributeFqnSuite) TestGetAttributeByFqn_WithKeyAccessGrants_Values() {
370375 s .NotNil (grant )
371376
372377 // create a second kas registration and grant it to the second value
373- localKAS , err := s .db .PolicyClient .CreateKeyAccessServer (s .ctx , & kasregistry.CreateKeyAccessServerRequest {
378+ cachedKASName := "testion-io-local"
379+ cachedKAS , err := s .db .PolicyClient .CreateKeyAccessServer (s .ctx , & kasregistry.CreateKeyAccessServerRequest {
374380 Uri : "https://testing.io/kas2" ,
375381 PublicKey : & policy.PublicKey {
376382 PublicKey : & policy.PublicKey_Cached {
@@ -383,12 +389,13 @@ func (s *AttributeFqnSuite) TestGetAttributeByFqn_WithKeyAccessGrants_Values() {
383389 },
384390 },
385391 },
392+ Name : cachedKASName ,
386393 })
387394 s .Require ().NoError (err )
388- s .NotNil (localKAS )
395+ s .NotNil (cachedKAS )
389396
390397 grant2 , err := s .db .PolicyClient .AssignKeyAccessServerToValue (s .ctx , & attributes.ValueKeyAccessServer {
391- KeyAccessServerId : localKAS .GetId (),
398+ KeyAccessServerId : cachedKAS .GetId (),
392399 ValueId : valueSecond .GetId (),
393400 })
394401 s .Require ().NoError (err )
@@ -410,13 +417,16 @@ func (s *AttributeFqnSuite) TestGetAttributeByFqn_WithKeyAccessGrants_Values() {
410417 s .Empty (got .GetGrants ())
411418
412419 for _ , v := range got .GetValues () {
420+ grants := v .GetGrants ()
421+ s .Require ().Len (grants , 1 )
422+ firstGrant := grants [0 ]
413423 switch v .GetId () {
414424 case valueFirst .GetId ():
415- s .Require (). Len ( v . GetGrants ( ), 1 )
416- s .Equal (remoteKAS . GetId (), v . GetGrants ()[ 0 ]. GetId ())
425+ s .Equal ( remoteKAS . GetId ( ), firstGrant . GetId () )
426+ s .Equal (remoteKASName , firstGrant . GetName ())
417427 case valueSecond .GetId ():
418- s .Require (). Len ( v . GetGrants ( ), 1 )
419- s .Equal (localKAS . GetId (), v . GetGrants ()[ 0 ]. GetId ())
428+ s .Equal ( cachedKAS . GetId ( ), firstGrant . GetId () )
429+ s .Equal (cachedKASName , firstGrant . GetName ())
420430 default :
421431 s .Fail ("unexpected value" , v )
422432 }
@@ -584,13 +594,15 @@ func (s *AttributeFqnSuite) TestGetAttributeByFqn_WithKeyAccessGrants_NamespaceG
584594 s .NotNil (attr )
585595
586596 // create a new kas registration
597+ nsKASName := "namespace-kas1"
587598 kas , err := s .db .PolicyClient .CreateKeyAccessServer (s .ctx , & kasregistry.CreateKeyAccessServerRequest {
588599 Uri : "https://testing_granted_namespace.com/kas" ,
589600 PublicKey : & policy.PublicKey {
590601 PublicKey : & policy.PublicKey_Remote {
591602 Remote : "https://testing_granted_namespace.com/kas" ,
592603 },
593604 },
605+ Name : nsKASName ,
594606 })
595607 s .Require ().NoError (err )
596608 s .NotNil (kas )
@@ -610,8 +622,10 @@ func (s *AttributeFqnSuite) TestGetAttributeByFqn_WithKeyAccessGrants_NamespaceG
610622
611623 // ensure the namespace has the grants
612624 gotNs := got .GetNamespace ()
613- s .Len (gotNs .GetGrants (), 1 )
614- s .Equal (kas .GetId (), gotNs .GetGrants ()[0 ].GetId ())
625+ grants := gotNs .GetGrants ()
626+ s .Len (grants , 1 )
627+ s .Equal (kas .GetId (), grants [0 ].GetId ())
628+ s .Equal (nsKASName , grants [0 ].GetName ())
615629}
616630
617631// for all the big tests set up:
0 commit comments