Skip to content

Commit

Permalink
Add required IAM for notification topic.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Sep 22, 2017
1 parent da6dc1c commit 7d9ee94
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions storage/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,26 @@ def topic_path(self):
return 'projects/{}/topics/{}'.format(
Config.CLIENT.project, self.TOPIC_NAME)

def setUp(self):
self.case_buckets_to_delete = []
def _intialize_topic(self):
try:
from google.cloud.pubsub_v1 import PublisherClient
except ImportError:
raise unittest.SkipTest("Cannot import pubsub")
self.publisher_client = PublisherClient()
retry_429(self.publisher_client.create_topic)(self.topic_path)
policy = self.publisher_client.get_iam_policy(self.topic_path)
binding = policy.bindings.add()
binding.role = 'roles/pubsub.publisher'
binding.members.append(
'serviceAccount:{}'
'@gs-project-accounts.iam.gserviceaccount.com'.format(
Config.CLIENT.project))
self.publisher_client.set_iam_policy(self.topic_path, policy)


def setUp(self):
self.case_buckets_to_delete = []
self._intialize_topic()

def tearDown(self):
retry_429(self.publisher_client.delete_topic)(self.topic_path)
Expand Down

0 comments on commit 7d9ee94

Please sign in to comment.