def test_jgp_gen_s3_entry(): ''' Test gen_s3_entry in c3.utils.jgp ''' config = os.getcwd() + '/tests/confs/opsqa-devzzz.ini' ini = c3gen_entry.read_config(config) entry = c3gen_entry.gen_s3_entry(ini, 'devzzz', 'opsqa') assert entry == [ 'Allow|s3:get*,s3:list*|devzzz|opsqa|mybucket/*|'\ 'IpAddress,aws:SourceIp,216.1.187.128/27', 'Allow|s3:putObject|devzzz|opsqa|mybucket/foo/bar/baz|empty', 'Deny|s3:*|devzzz|opsqa|mybucket/foobar/barbaz|empty']
def generate_entries(user, config): ''' Generates entries from config files ''' ini = gen_entry.read_config(config) if 'cidr-networks' in user: acct_id = 'cidr-networks' user = '******' else: (user_acct, user) = user.split('-', 1) if user_acct.isdigit(): acct_id = user_acct else: acct_id = accounts.get_account_id(user_acct) return gen_entry.gen_s3_entry(ini, user, acct_id)