From 6a3a36513a777912861c2aa51538d82269902273 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Thu, 1 Oct 2015 10:49:58 -0400 Subject: [PATCH] Add failure test for sts tokens --- awx/main/tests/inventory.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/awx/main/tests/inventory.py b/awx/main/tests/inventory.py index b4ba836e00..de7149df3e 100644 --- a/awx/main/tests/inventory.py +++ b/awx/main/tests/inventory.py @@ -1691,6 +1691,28 @@ class InventoryUpdatesTest(BaseTransactionTest): source_vars='---\n\nnested_groups: false\ncache_path: %s\n' % cache_path) self.check_inventory_source(inventory_source) + def test_update_from_ec2_sts_iam_bad_token(self): + source_username = getattr(settings, 'TEST_AWS_ACCESS_KEY_ID', '') + source_password = getattr(settings, 'TEST_AWS_SECRET_ACCESS_KEY', '') + source_regions = getattr(settings, 'TEST_AWS_REGIONS', 'all') + self.create_test_license_file() + credential = Credential.objects.create(kind='aws', + user=self.super_django_user, + username=source_username, + password=source_password, + security_token="BADTOKEN") + # Set parent group name to one that might be created by the sync. + group = self.group + group.name = 'ec2' + group.save() + self.group = group + cache_path = tempfile.mkdtemp(prefix='awx_ec2_') + self._temp_paths.append(cache_path) + inventory_source = self.update_inventory_source(self.group, + source='ec2', credential=credential, source_regions=source_regions, + source_vars='---\n\nnested_groups: false\ncache_path: %s\n' % cache_path) + self.check_inventory_update(inventory_source, should_fail=True) + def test_update_from_ec2_without_credential(self): self.create_test_license_file() group = self.group