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(),
         )
예제 #2
0
 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(),
         )
예제 #3
0
 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(),
         )