def test_get_policy_no_statement(self): ''' Test UploadCredentials _get_policy if statements are bad ''' upload_creds = UploadCredentials(self._test_bucket, self._test_key, self._test_name) for item in [ { 'NotStatement': ['a'] }, { 'Statement': {} }, { 'Statement': [] }, { 'Statement': None }, { 'Statement': 'a' }, ]: upload_creds._external_policy = item self.assertDictEqual( upload_creds._get_base_policy(), upload_creds._get_policy(), )
def test_get_policy_no_external(self): ''' Test UploadCredentials _get_policy if no external statements ''' upload_creds = UploadCredentials( self._test_bucket, self._test_key, self._test_name, self._test_profile_name, ) self.assertDictEqual(upload_creds._get_base_policy(), upload_creds._get_policy())
def test_get_token_default(self): ''' Test UploadCredentials _get_token with good profile_name -Test how this works on travis ''' upload_creds = UploadCredentials( self._test_bucket, self._test_key, self._test_name, ) policy = upload_creds._get_policy() token = upload_creds._get_token(policy) self.assertTrue(isinstance(token, dict))
def test_get_policy_no_external(self): ''' Test UploadCredentials _get_policy if no external statements ''' upload_creds = UploadCredentials( self._test_bucket, self._test_key, self._test_name, self._test_profile_name, ) self.assertDictEqual( upload_creds._get_base_policy(), upload_creds._get_policy() )
def test_get_policy_ext_statements(self): ''' Test UploadCredentials _get_policy if 1 or more good statements ''' upload_creds = UploadCredentials(self._test_bucket, self._test_key, self._test_name) for policy in [ {'Statement': ['a']}, {'Statement': ['a', 'b', 'c']}, ]: upload_creds._external_policy = policy base = upload_creds._get_base_policy() for statement in policy['Statement']: base['Statement'].append(statement) self.assertDictEqual( base, upload_creds._get_policy(), )
def test_get_policy_no_statement(self): ''' Test UploadCredentials _get_policy if statements are bad ''' upload_creds = UploadCredentials(self._test_bucket, self._test_key, self._test_name) for item in [ {'NotStatement': ['a']}, {'Statement': {}}, {'Statement': []}, {'Statement': None}, {'Statement': 'a'}, ]: upload_creds._external_policy = item self.assertDictEqual( upload_creds._get_base_policy(), upload_creds._get_policy(), )
def test_get_policy_ext_statements(self): ''' Test UploadCredentials _get_policy if 1 or more good statements ''' upload_creds = UploadCredentials(self._test_bucket, self._test_key, self._test_name) for policy in [ { 'Statement': ['a'] }, { 'Statement': ['a', 'b', 'c'] }, ]: upload_creds._external_policy = policy base = upload_creds._get_base_policy() for statement in policy['Statement']: base['Statement'].append(statement) self.assertDictEqual( base, upload_creds._get_policy(), )