test_anonymous_credentials.py 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. import pytest
  7. import os
  8. import logging
  9. import ly_test_tools.log.log_monitor
  10. # fixture imports
  11. from AWS.Windows.resource_mappings.resource_mappings import resource_mappings
  12. from AWS.Windows.cdk.cdk_utils import Cdk
  13. from AWS.common.aws_utils import AwsUtils
  14. from assetpipeline.ap_fixtures.asset_processor_fixture import asset_processor as asset_processor
  15. AWS_PROJECT_NAME = 'AWS-AutomationTest'
  16. AWS_CLIENT_AUTH_FEATURE_NAME = 'AWSClientAuth'
  17. AWS_CLIENT_AUTH_DEFAULT_PROFILE_NAME = 'default'
  18. GAME_LOG_NAME = 'Game.log'
  19. logger = logging.getLogger(__name__)
  20. @pytest.mark.SUITE_periodic
  21. @pytest.mark.usefixtures('automatic_process_killer')
  22. @pytest.mark.usefixtures('asset_processor')
  23. @pytest.mark.usefixtures('workspace')
  24. @pytest.mark.parametrize('project', ['AutomatedTesting'])
  25. @pytest.mark.parametrize('level', ['AWS/ClientAuth'])
  26. @pytest.mark.usefixtures('cdk')
  27. @pytest.mark.parametrize('feature_name', [AWS_CLIENT_AUTH_FEATURE_NAME])
  28. @pytest.mark.usefixtures('resource_mappings')
  29. @pytest.mark.parametrize('resource_mappings_filename', ['default_aws_resource_mappings.json'])
  30. @pytest.mark.usefixtures('aws_utils')
  31. @pytest.mark.parametrize('region_name', ['us-west-2'])
  32. @pytest.mark.parametrize('assume_role_arn', ['arn:aws:iam::645075835648:role/o3de-automation-tests'])
  33. @pytest.mark.parametrize('session_name', ['o3de-Automation-session'])
  34. class TestAWSClientAuthAnonymousCredentials(object):
  35. """
  36. Test class to verify AWS Cognito Identity pool anonymous authorization.
  37. """
  38. def test_anonymous_credentials(self,
  39. level: str,
  40. launcher: pytest.fixture,
  41. cdk: pytest.fixture,
  42. resource_mappings: pytest.fixture,
  43. workspace: pytest.fixture,
  44. asset_processor: pytest.fixture
  45. ):
  46. """
  47. Setup: Deploys cdk and updates resource mapping file.
  48. Tests: Getting AWS credentials for no signed in user.
  49. Verification: Log monitor looks for success credentials log.
  50. """
  51. logger.info(f'Cdk stack names:\n{cdk.list()}')
  52. stacks = cdk.deploy()
  53. resource_mappings.populate_output_keys(stacks)
  54. asset_processor.start()
  55. asset_processor.wait_for_idle()
  56. file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), GAME_LOG_NAME)
  57. log_monitor = ly_test_tools.log.log_monitor.LogMonitor(launcher=launcher, log_file_path=file_to_monitor)
  58. launcher.args = ['+LoadLevel', level]
  59. launcher.args.extend(['-rhi=null'])
  60. with launcher.start(launch_ap=False):
  61. result = log_monitor.monitor_log_for_lines(
  62. expected_lines=['(Script) - Success anonymous credentials'],
  63. unexpected_lines=['(Script) - Fail anonymous credentials'],
  64. halt_on_unexpected=True,
  65. )
  66. assert result, 'Anonymous credentials fetched successfully.'