@@ -34,7 +34,17 @@ import (
34
34
"google.golang.org/protobuf/types/known/wrapperspb"
35
35
)
36
36
37
- var testAuthorizedActions = []string {"no-op" , "read" , "update" , "delete" }
37
+ var (
38
+ testAuthorizedActions = []string {"no-op" , "read" , "update" , "delete" }
39
+ testAuthorizedCollectionActions = map [string ]* structpb.ListValue {
40
+ "credential-libraries" : {
41
+ Values : []* structpb.Value {
42
+ structpb .NewStringValue ("create" ),
43
+ structpb .NewStringValue ("list" ),
44
+ },
45
+ },
46
+ }
47
+ )
38
48
39
49
func TestList (t * testing.T ) {
40
50
conn , _ := db .TestSetup (t , "postgres" )
@@ -57,14 +67,15 @@ func TestList(t *testing.T) {
57
67
var wantStores []* pb.CredentialStore
58
68
for _ , s := range vault .TestCredentialStores (t , conn , wrapper , prj .GetPublicId (), 10 ) {
59
69
wantStores = append (wantStores , & pb.CredentialStore {
60
- Id : s .GetPublicId (),
61
- ScopeId : prj .GetPublicId (),
62
- Scope : & scopepb.ScopeInfo {Id : prj .GetPublicId (), Type : scope .Project .String (), ParentScopeId : prj .GetParentId ()},
63
- CreatedTime : s .GetCreateTime ().GetTimestamp (),
64
- UpdatedTime : s .GetUpdateTime ().GetTimestamp (),
65
- Version : s .GetVersion (),
66
- Type : vault .Subtype .String (),
67
- AuthorizedActions : testAuthorizedActions ,
70
+ Id : s .GetPublicId (),
71
+ ScopeId : prj .GetPublicId (),
72
+ Scope : & scopepb.ScopeInfo {Id : prj .GetPublicId (), Type : scope .Project .String (), ParentScopeId : prj .GetParentId ()},
73
+ CreatedTime : s .GetCreateTime ().GetTimestamp (),
74
+ UpdatedTime : s .GetUpdateTime ().GetTimestamp (),
75
+ Version : s .GetVersion (),
76
+ Type : vault .Subtype .String (),
77
+ AuthorizedActions : testAuthorizedActions ,
78
+ AuthorizedCollectionActions : testAuthorizedCollectionActions ,
68
79
Attributes : func () * structpb.Struct {
69
80
attrs , err := handlers .ProtoToStruct (& pb.VaultCredentialStoreAttributes {
70
81
Address : wrapperspb .String (s .GetVaultAddress ()),
@@ -451,7 +462,8 @@ func TestCreate(t *testing.T) {
451
462
require .NoError (t , err )
452
463
return attrs
453
464
}(),
454
- AuthorizedActions : testAuthorizedActions ,
465
+ AuthorizedActions : testAuthorizedActions ,
466
+ AuthorizedCollectionActions : testAuthorizedCollectionActions ,
455
467
},
456
468
},
457
469
},
@@ -495,7 +507,8 @@ func TestCreate(t *testing.T) {
495
507
require .NoError (t , err )
496
508
return attrs
497
509
}(),
498
- AuthorizedActions : testAuthorizedActions ,
510
+ AuthorizedActions : testAuthorizedActions ,
511
+ AuthorizedCollectionActions : testAuthorizedCollectionActions ,
499
512
},
500
513
},
501
514
},
@@ -580,14 +593,15 @@ func TestGet(t *testing.T) {
580
593
id : store .GetPublicId (),
581
594
res : & pbs.GetCredentialStoreResponse {
582
595
Item : & pb.CredentialStore {
583
- Id : store .GetPublicId (),
584
- ScopeId : store .GetScopeId (),
585
- Scope : & scopepb.ScopeInfo {Id : store .GetScopeId (), Type : scope .Project .String (), ParentScopeId : prj .GetParentId ()},
586
- Type : vault .Subtype .String (),
587
- AuthorizedActions : testAuthorizedActions ,
588
- CreatedTime : store .CreateTime .GetTimestamp (),
589
- UpdatedTime : store .UpdateTime .GetTimestamp (),
590
- Version : 1 ,
596
+ Id : store .GetPublicId (),
597
+ ScopeId : store .GetScopeId (),
598
+ Scope : & scopepb.ScopeInfo {Id : store .GetScopeId (), Type : scope .Project .String (), ParentScopeId : prj .GetParentId ()},
599
+ Type : vault .Subtype .String (),
600
+ AuthorizedActions : testAuthorizedActions ,
601
+ AuthorizedCollectionActions : testAuthorizedCollectionActions ,
602
+ CreatedTime : store .CreateTime .GetTimestamp (),
603
+ UpdatedTime : store .UpdateTime .GetTimestamp (),
604
+ Version : 1 ,
591
605
Attributes : func () * structpb.Struct {
592
606
attrs , err := handlers .ProtoToStruct (& pb.VaultCredentialStoreAttributes {
593
607
Address : wrapperspb .String (store .GetVaultAddress ()),
0 commit comments