@@ -34,12 +34,13 @@ func TestLogBucketOrgModule(t *testing.T) {
3434 insSimpleT .DefineVerify (func (assert * assert.Assertions ) {
3535 insSimpleT .DefaultVerify (assert )
3636
37- project_id := insSimpleT .GetStringOutput ("log_bucket_project" )
37+ projectId := insSimpleT .GetStringOutput ("log_bucket_project" )
3838 logBucketName := insSimpleT .GetStringOutput ("log_bucket_name" )
3939 logSinkOrgId := insSimpleT .GetStringOutput ("log_sink_organization_id" )
4040 logSinkDestination := insSimpleT .GetStringOutput ("log_sink_destination_uri" )
41+ logSinkWriterId := insSimpleT .GetStringOutput ("log_sink_writer_identity" )
4142
42- logBucketDetails := gcloud .Runf (t , fmt .Sprintf ("logging buckets describe %s --location=%s --project=%s" , logBucketName , "global" , project_id ))
43+ logBucketDetails := gcloud .Runf (t , fmt .Sprintf ("logging buckets describe %s --location=%s --project=%s" , logBucketName , "global" , projectId ))
4344
4445 // assert log bucket name, retention days & location
4546 assert .Equal (logSinkDestination [len (logApiFdqm )+ 1 :], logBucketDetails .Get ("name" ).String (), "log bucket name should match" )
@@ -51,6 +52,9 @@ func TestLogBucketOrgModule(t *testing.T) {
5152 assert .Equal (logSinkDestination , logSinkDetails .Get ("destination" ).String (), "log sink destination should match" )
5253 assert .Equal ("resource.type = gce_instance" , logSinkDetails .Get ("filter" ).String (), "log sink filter should match" )
5354
55+ //assert writer id has the bucketWriter role
56+ logSinkServiceAccount := gcloud .Runf (t , "projects get-iam-policy %s --flatten bindings --filter bindings.role:roles/logging.bucketWriter" , projectId )
57+ assert .Contains (logSinkServiceAccount .Array ()[0 ].Get ("bindings.members" ).String (), logSinkWriterId , "log sink SA has expected role" )
5458 })
5559 insSimpleT .Test ()
5660}
0 commit comments