def testFilterAllResults(self): self.client.projects_serviceAccounts_keys.List.Expect( request=self.msgs.IamProjectsServiceAccountsKeysListRequest( name=('projects/-/serviceAccounts/' '*****@*****.**'), keyTypes=iam_util.ManagedByFromString('system')), response=self.msgs.ListServiceAccountKeysResponse(keys=[ self.msgs.ServiceAccountKey( name=('projects/-/serviceAccounts/' '*****@*****.**' '/keys/abcdef1234567890'), validAfterTime='2015-09-30T09:35:00Z'), # pyformat break self.msgs.ServiceAccountKey( name=('projects/-/serviceAccounts/' '*****@*****.**' '/keys/deadbeefdeadbeef'), validAfterTime='2015-09-30T09:39:49Z') ])) self.Run('iam service-accounts keys list --managed-by system ' '--created-before 2000-01-01T00:00:00Z ' '--iam-account [email protected]') self.AssertOutputNotContains('abcdef1234567890') self.AssertOutputNotContains('2015-09-30T09:35:00Z') self.AssertOutputNotContains('deadbeefdeadbeef') self.AssertOutputNotContains('2015-09-30T09:39:49Z')
def Run(self, args): result = self.iam_client.projects_serviceAccounts_keys.List( self.messages.IamProjectsServiceAccountsKeysListRequest( name=iam_util.EmailToAccountResourceName(args.iam_account), keyTypes=iam_util.ManagedByFromString(args.managed_by))) keys = result.keys if args.created_before: ts = args.created_before keys = [ key for key in keys if times.ParseDateTime(key.validAfterTime) < ts ] return keys
def testNoResults(self): self.client.projects_serviceAccounts_keys.List.Expect( request=self.msgs.IamProjectsServiceAccountsKeysListRequest( name=('projects/-/serviceAccounts/' '*****@*****.**'), keyTypes=iam_util.ManagedByFromString('system')), response=self.msgs.ListServiceAccountKeysResponse(keys=[])) self.Run('iam service-accounts keys list --managed-by system ' '--iam-account [email protected]') self.AssertOutputNotContains('abcdef1234567890') self.AssertOutputNotContains('2015-09-30T09:35:00Z') self.AssertOutputNotContains('deadbeefdeadbeef') self.AssertOutputNotContains('2015-09-30T09:39:49Z')