├── tests ├── core │ ├── test_data │ │ ├── testFiles │ │ │ ├── credentialsTests │ │ │ │ └── test_credentials │ │ │ ├── fileUtilTests │ │ │ │ ├── TestReadEmptyFile.txt │ │ │ │ ├── HashDirTest │ │ │ │ │ ├── TestReadEmptyFile.txt │ │ │ │ │ ├── TestReadFile.txt │ │ │ │ │ └── TestReadNonAsciiCharacters.txt │ │ │ │ ├── TestReadNonAsciiCharacters.txt │ │ │ │ ├── TestReadFile.txt │ │ │ │ └── TestWriteExistingFile.txt │ │ │ ├── gameSavingTests │ │ │ │ ├── TestSaveEmpty.dat │ │ │ │ ├── testSlot.txt │ │ │ │ ├── TestSave.dat │ │ │ │ ├── InvalidSavedSlotInformation.json │ │ │ │ ├── ExpectedSavedSlotInformationLocalOnly.json │ │ │ │ ├── NullSavedSlotInformation.json │ │ │ │ └── ExpectedSavedSlotInformation.json │ │ │ ├── zipperTests │ │ │ │ └── testFiles │ │ │ │ │ ├── intoZip.txt │ │ │ │ │ └── intoZip2.txt │ │ │ └── regionMappingsTests │ │ │ │ └── misc │ │ │ │ └── awsGameKitAwsRegionMappings.yml │ │ └── sampleplugin │ │ │ ├── base │ │ │ ├── functions │ │ │ │ ├── gamesaving │ │ │ │ │ ├── save │ │ │ │ │ │ └── index.py │ │ │ │ │ ├── delete │ │ │ │ │ │ └── index.py │ │ │ │ │ └── getall │ │ │ │ │ │ └── index.py │ │ │ │ ├── achievements │ │ │ │ │ ├── getall │ │ │ │ │ │ ├── index.py │ │ │ │ │ │ ├── testdir │ │ │ │ │ │ │ └── testdir.py │ │ │ │ │ │ └── another.py │ │ │ │ │ ├── unlock │ │ │ │ │ │ └── index.py │ │ │ │ │ └── geticons │ │ │ │ │ │ └── index.py │ │ │ │ └── identity │ │ │ │ │ └── getuser │ │ │ │ │ └── index.py │ │ │ ├── cloudformation │ │ │ │ ├── main │ │ │ │ │ ├── parameters.yml │ │ │ │ │ └── cloudFormation.yml │ │ │ │ ├── gamesaving │ │ │ │ │ ├── parameters.yml │ │ │ │ │ └── cloudFormation.yml │ │ │ │ ├── achievements │ │ │ │ │ ├── parameters.yml │ │ │ │ │ └── cloudFormation.yml │ │ │ │ └── identity │ │ │ │ │ ├── parameters.yml │ │ │ │ │ └── cloudFormation.yml │ │ │ ├── misc │ │ │ │ └── awsGameKitAwsRegionMappings.yml │ │ │ └── configOutputs │ │ │ │ └── identity │ │ │ │ └── clientConfig.yml │ │ │ ├── instance │ │ │ └── testgame │ │ │ │ ├── dev │ │ │ │ ├── cloudformation │ │ │ │ │ ├── identity │ │ │ │ │ │ ├── dashboard.yml │ │ │ │ │ │ ├── parameters.yml │ │ │ │ │ │ └── cloudFormation.yml │ │ │ │ │ ├── main │ │ │ │ │ │ ├── dashboard.yml │ │ │ │ │ │ ├── parameters.yml │ │ │ │ │ │ └── cloudFormation.yml │ │ │ │ │ ├── achievements │ │ │ │ │ │ ├── dashboard.yml │ │ │ │ │ │ ├── parameters.yml │ │ │ │ │ │ └── cloudFormation.yml │ │ │ │ │ └── gamesaving │ │ │ │ │ │ ├── dashboard.yml │ │ │ │ │ │ ├── parameters.yml │ │ │ │ │ │ └── cloudFormation.yml │ │ │ │ ├── functions │ │ │ │ │ ├── gamesaving │ │ │ │ │ │ ├── delete │ │ │ │ │ │ │ └── index.py │ │ │ │ │ │ ├── getall │ │ │ │ │ │ │ └── index.py │ │ │ │ │ │ └── save │ │ │ │ │ │ │ └── index.py │ │ │ │ │ ├── achievements │ │ │ │ │ │ ├── getall │ │ │ │ │ │ │ ├── index.py │ │ │ │ │ │ │ ├── testdir │ │ │ │ │ │ │ │ └── testdir.py │ │ │ │ │ │ │ └── another.py │ │ │ │ │ │ ├── geticons │ │ │ │ │ │ │ └── index.py │ │ │ │ │ │ └── unlock │ │ │ │ │ │ │ └── index.py │ │ │ │ │ └── identity │ │ │ │ │ │ └── getuser │ │ │ │ │ │ └── index.py │ │ │ │ └── awsGameKitClientConfig.yml │ │ │ │ ├── functions │ │ │ │ └── identity │ │ │ │ │ └── getuser │ │ │ │ │ └── index.py │ │ │ │ └── cloudformation │ │ │ │ └── identity │ │ │ │ ├── parameters.yml │ │ │ │ └── cloudFormation.yml │ │ │ └── alternativeInstance │ │ │ └── testgame │ │ │ └── dev │ │ │ └── awsGameKitClientConfig.yml │ ├── aws_region_mappings_test.h │ ├── gamekit_settings_exports_tests.h │ ├── gamekit_settings_test.h │ ├── mocks │ │ ├── mock_ssm_client.h │ │ ├── mock_gamekit_account.h │ │ ├── mock_sts_client.h │ │ ├── mock_apigateway_client.h │ │ ├── mock_time_provider.h │ │ ├── mock_secretsmanager_client.h │ │ ├── mock_s3_client.h │ │ ├── mock_cognito_client.h │ │ └── mock_feature_resources.h │ ├── simple_integration_test.h │ ├── feature_resources_test.h │ ├── test_common.h │ ├── count_ticker_tests.cpp │ ├── timestamp_ticker_tests.cpp │ ├── sts_tests.h │ ├── custom_test_flags.h │ ├── request_serialization_test.h │ ├── count_ticker_tests.h │ ├── timestamp_ticker_tests.h │ ├── gamekit_account_test.h │ ├── custom_test_flags.cpp │ ├── testable_deployment_orchestrator.h │ ├── test_stack.h │ ├── gamekit_core_tests.cpp │ ├── gamekit_core_exports_tests.h │ ├── aws_region_mappings_test.cpp │ ├── test_log.h │ ├── test_stack.cpp │ ├── ticker_tests.cpp │ └── simple_integration_test.cpp ├── validation_utils_tests.cpp ├── identity │ ├── credentials_utils_tests.cpp │ ├── credentials_utils_tests.h │ └── gamekit_identity_exports_tests.h ├── authentication │ ├── gamekit_authentication_exports_tests.h │ ├── gamekit_session_manager_tests.h │ └── gamekit_session_manager_tests.cpp ├── encoding_utils_tests.h ├── validation_utils_tests.h ├── file_utils_tests.h ├── zipper_tests.h ├── user-gameplay-data │ ├── user_gameplay_data_models_tests.h │ ├── user_gameplay_exports_tests.h │ ├── user_gameplay_data_client_tests.h │ └── user_gameplay_data_models_tests.cpp ├── README.md ├── achievements │ ├── gamekit_achievements_exports_tests.h │ └── gamekit_admin_achievements_exports_tests.h ├── main.cpp └── encoding_utils_tests.cpp ├── aws_gamekit_py ├── requirements.txt ├── pytest.ini ├── conftest.py └── README.md ├── scripts ├── IOS │ ├── __init__.py │ ├── build.py │ ├── regenerate_projects_ios.sh │ ├── refresh_unity.py │ └── refresh_unreal.py ├── Mac │ ├── __init__.py │ ├── refresh_unity.py │ └── refresh_unreal.py ├── __init__.py ├── Android │ ├── __init__.py │ ├── refresh_unreal.py │ ├── sample-android-user-config.jam │ ├── build.py │ └── refresh_unity.py ├── Win64 │ ├── __init__.py │ ├── refresh_unreal.py │ └── refresh_unity.py └── aws_gamekit_cpp_build.py ├── CODE_OF_CONDUCT.md ├── publish └── CMakeLists.txt ├── aws-gamekit-core ├── include │ └── aws │ │ └── gamekit │ │ └── core │ │ ├── model │ │ ├── config_consts.h │ │ ├── account_info.h │ │ ├── account_credentials.h │ │ ├── template_consts.h │ │ └── resource_environment.h │ │ ├── feature_resources_callback.h │ │ ├── utils │ │ ├── gamekit_httpclient_callbacks.h │ │ ├── debug.h │ │ ├── sts_utils.h │ │ ├── count_ticker.h │ │ ├── timestamp_ticker.h │ │ ├── current_time_provider.h │ │ ├── encoding_utils.h │ │ └── validation_utils.h │ │ ├── api.h │ │ ├── paramstore_keys.h │ │ ├── gamekit_feature.h │ │ ├── zipper.h │ │ ├── logging.h │ │ ├── internal │ │ ├── platform_string.h │ │ └── wrap_boost_filesystem.h │ │ ├── awsclients │ │ ├── api_initializer.h │ │ └── http_client_factory.h │ │ └── aws_region_mappings.h └── source │ └── aws │ └── gamekit │ └── core │ ├── utils │ ├── count_ticker.cpp │ ├── timestamp_ticker.cpp │ ├── encoding_utils.cpp │ ├── sts_utils.cpp │ └── validation_utils.cpp │ ├── logging.cpp │ ├── aws_region_mappings.cpp │ └── model │ └── account_info.cpp ├── NOTICE ├── aws-gamekit-identity ├── source │ └── aws │ │ └── gamekit │ │ └── identity │ │ └── utils │ │ └── credentials_utils.cpp └── include │ └── aws │ └── gamekit │ └── identity │ ├── utils │ └── credentials_utils.h │ ├── federated_identity_provider.h │ └── facebook_identity_provider.h ├── aws-gamekit-achievements ├── source │ └── aws │ │ └── gamekit │ │ └── achievements │ │ ├── gamekit_achievement_models.cpp │ │ ├── exports.cpp │ │ └── exports_admin.cpp └── include │ └── aws │ └── gamekit │ └── achievements │ └── gamekit_achievements_models.h ├── aws-gamekit-user-gameplay-data └── source │ └── aws │ └── gamekit │ └── user-gameplay-data │ └── gamekit_user_gameplay_data_models.cpp ├── .github └── ISSUE_TEMPLATE │ └── aws-gamekit-bug-report.md ├── CONTRIBUTING.md ├── aws-gamekit-authentication └── source │ └── aws │ └── gamekit │ └── authentication │ └── exports.cpp ├── CMakeLists.txt └── aws-gamekit-game-saving ├── include └── aws │ └── gamekit │ └── game-saving │ └── gamekit_game_saving_caller.h └── source └── aws └── gamekit └── game-saving └── exports.cpp /tests/core/test_data/testFiles/credentialsTests/test_credentials: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/fileUtilTests/TestReadEmptyFile.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/gameSavingTests/TestSaveEmpty.dat: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/gameSavingTests/testSlot.txt: -------------------------------------------------------------------------------- 1 | ABCDEFGH -------------------------------------------------------------------------------- /aws_gamekit_py/requirements.txt: -------------------------------------------------------------------------------- 1 | boto3 2 | pytest 3 | pytest-sugar 4 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/functions/gamesaving/save/index.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/gameSavingTests/TestSave.dat: -------------------------------------------------------------------------------- 1 | Test save data -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/functions/achievements/getall/index.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/functions/achievements/unlock/index.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/functions/gamesaving/delete/index.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/functions/gamesaving/getall/index.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/fileUtilTests/HashDirTest/TestReadEmptyFile.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/functions/achievements/geticons/index.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/fileUtilTests/HashDirTest/TestReadFile.txt: -------------------------------------------------------------------------------- 1 | TEST File -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/fileUtilTests/TestReadNonAsciiCharacters.txt: -------------------------------------------------------------------------------- 1 | 🙂测试 -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/functions/achievements/getall/testdir/testdir.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/cloudformation/identity/dashboard.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/cloudformation/main/dashboard.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/functions/gamesaving/delete/index.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/functions/gamesaving/getall/index.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/functions/gamesaving/save/index.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/fileUtilTests/HashDirTest/TestReadNonAsciiCharacters.txt: -------------------------------------------------------------------------------- 1 | 🙂测试 -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/zipperTests/testFiles/intoZip.txt: -------------------------------------------------------------------------------- 1 | TestingTesting 2 | Testing -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/cloudformation/achievements/dashboard.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/cloudformation/gamesaving/dashboard.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/functions/achievements/getall/index.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/functions/achievements/geticons/index.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/functions/achievements/unlock/index.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/fileUtilTests/TestReadFile.txt: -------------------------------------------------------------------------------- 1 | T 2 | E 3 | S 4 | T 5 | File 6 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/functions/identity/getuser/index.py: -------------------------------------------------------------------------------- 1 | def test(): 2 | pass 3 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/functions/achievements/getall/testdir/testdir.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/functions/achievements/getall/another.py: -------------------------------------------------------------------------------- 1 | def test(): 2 | pass 3 | 4 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/functions/identity/getuser/index.py: -------------------------------------------------------------------------------- 1 | def test(): 2 | pass 3 | -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/fileUtilTests/TestWriteExistingFile.txt: -------------------------------------------------------------------------------- 1 | T 2 | E 3 | S 4 | T 5 | WriteExistingFile 6 | -------------------------------------------------------------------------------- /tests/validation_utils_tests.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws/aws-gamekit/HEAD/tests/validation_utils_tests.cpp -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/functions/identity/getuser/index.py: -------------------------------------------------------------------------------- 1 | def test(): 2 | pass 3 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/functions/achievements/getall/another.py: -------------------------------------------------------------------------------- 1 | def test(): 2 | pass 3 | 4 | -------------------------------------------------------------------------------- /scripts/IOS/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | -------------------------------------------------------------------------------- /scripts/Mac/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | -------------------------------------------------------------------------------- /scripts/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | -------------------------------------------------------------------------------- /tests/identity/credentials_utils_tests.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws/aws-gamekit/HEAD/tests/identity/credentials_utils_tests.cpp -------------------------------------------------------------------------------- /scripts/Android/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | -------------------------------------------------------------------------------- /scripts/Win64/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/gameSavingTests/InvalidSavedSlotInformation.json: -------------------------------------------------------------------------------- 1 | { 2 | "comment": "this JSON is missing all of the required keys!" 3 | } -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/zipperTests/testFiles/intoZip2.txt: -------------------------------------------------------------------------------- 1 | TestingTestingTestingTesting 2 | TestingTestingTesting 3 | TestingTesting 4 | Testing 5 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/alternativeInstance/testgame/dev/awsGameKitClientConfig.yml: -------------------------------------------------------------------------------- 1 | user_pool_client_id: TestClientID 2 | identity_api_gateway_base_url: TestGatewayURL 3 | identity_region: us-west-3 -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/cloudformation/main/parameters.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION PARAMETERS FILE 3 | GameKitApiName: 4 | value: "gamekit_dev_testgame_main" 5 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/cloudformation/main/parameters.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION PARAMETERS FILE 3 | GameKitApiName: 4 | value: "gamekit_{{AWSGAMEKIT::SYS::ENV}}_{{AWSGAMEKIT::SYS::GAMENAME}}_main" 5 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/misc/awsGameKitAwsRegionMappings.yml: -------------------------------------------------------------------------------- 1 | # 2 | # TEST REGION CODES 3 | # 4 | { 5 | five_letter_region_codes: { 6 | us-east-1: usea1, 7 | us-west-2: uswe2, 8 | fake-region: fare1 9 | } 10 | } -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/regionMappingsTests/misc/awsGameKitAwsRegionMappings.yml: -------------------------------------------------------------------------------- 1 | # 2 | # TEST REGION CODES 3 | # 4 | { 5 | five_letter_region_codes: { 6 | us-east-1: usea1, 7 | us-west-2: uswe2, 8 | fake-region: fare1 9 | } 10 | } -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/cloudformation/identity/parameters.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION PARAMETERS FILE 3 | SomeParamName: 4 | value: "gamekit_dev_testgame_identity_SampleParam" 5 | 6 | SomeParamValue: 7 | value: "Testvalue" 8 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/cloudformation/gamesaving/parameters.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION PARAMETERS FILE 3 | SomeParamName: 4 | value: "gamekit_dev_testgame_gamesaving_SampleParam" 5 | 6 | SomeParamValue: 7 | value: "Testvalue" 8 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/cloudformation/achievements/parameters.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION PARAMETERS FILE 3 | SomeParamName: 4 | value: "gamekit_dev_testgame_achivements_SampleParam" 5 | 6 | SomeParamValue: 7 | value: "Testvalue" 8 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/cloudformation/gamesaving/parameters.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION PARAMETERS FILE 3 | SomeParamName: 4 | value: "gamekit_{{AWSGAMEKIT::SYS::ENV}}_{{AWSGAMEKIT::SYS::GAMENAME}}_gamesaving_SampleParam" 5 | 6 | SomeParamValue: 7 | value: "Testvalue" 8 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/cloudformation/achievements/parameters.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION PARAMETERS FILE 3 | SomeParamName: 4 | value: "gamekit_{{AWSGAMEKIT::SYS::ENV}}_{{AWSGAMEKIT::SYS::GAMENAME}}_achivements_SampleParam" 5 | 6 | SomeParamValue: 7 | value: "Testvalue" 8 | -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/gameSavingTests/ExpectedSavedSlotInformationLocalOnly.json: -------------------------------------------------------------------------------- 1 | {"slotName":"testSlot","metadataLocal":"{'description':'level 1 complete','percentcomplete':0}","metadataCloud":"","sizeLocal":42,"sizeCloud":0,"lastModifiedLocal":1619626703000,"lastModifiedCloud":0,"lastSync":1619626703000,"slotSyncStatus":0} -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/gameSavingTests/NullSavedSlotInformation.json: -------------------------------------------------------------------------------- 1 | { 2 | "slotName": null, 3 | "metadataLocal": null, 4 | "metadataCloud": null, 5 | "sizeLocal": null, 6 | "sizeCloud": null, 7 | "lastModifiedLocal": null, 8 | "lastModifiedCloud": null, 9 | "lastSync": null, 10 | "slotSyncStatus": null 11 | } -------------------------------------------------------------------------------- /aws_gamekit_py/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | markers = 3 | offline: mark tests as not needing internet 4 | identity: mark tests using identity feature 5 | achievements: mark tests using achievements feature 6 | gamesaving: mark tests using gamesaving feature 7 | userdata: mark tests using userdata feature 8 | account: mark tests using AWS account 9 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/awsGameKitClientConfig.yml: -------------------------------------------------------------------------------- 1 | user_pool_client_id: Test 2 | identity_api_gateway_base_url: TestUrl 3 | identity_region: TestRegion 4 | usergamedata_api_gateway_base_url: https://domain.tld/usergamedata 5 | achievements_api_gateway_base_url: https://domain.tld/achievements 6 | gamesaving_api_gateway_base_url: https://domain.tld/game_saving 7 | -------------------------------------------------------------------------------- /tests/core/test_data/testFiles/gameSavingTests/ExpectedSavedSlotInformation.json: -------------------------------------------------------------------------------- 1 | {"slotName":"testSlot","metadataLocal":"{'description':'level 1 complete','percentcomplete':0}","metadataCloud":"{'description':'level 3 complete','percentcomplete':35}","sizeLocal":42,"sizeCloud":73586489,"lastModifiedLocal":1619626703000,"lastModifiedCloud":1619626703000,"lastSync":1619626703000,"slotSyncStatus":0} -------------------------------------------------------------------------------- /publish/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | # Installation project. 5 | # Each project in GameKit should contain an install() command to copy its output 6 | # and dependencies to the instal directory. 7 | 8 | cmake_minimum_required(VERSION 3.20) 9 | 10 | project(aws-gamekit-cpp-install) 11 | -------------------------------------------------------------------------------- /tests/core/aws_region_mappings_test.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include 6 | #include 7 | 8 | namespace GameKit 9 | { 10 | namespace Tests 11 | { 12 | class GameKitAwsRegionMappingsTestFixture; 13 | } 14 | } -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/cloudformation/main/cloudFormation.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION TEMPLATE 3 | Parameters: 4 | GameKitApiName: 5 | Type: String 6 | Resources : 7 | RestApi : 8 | Type : AWS::ApiGateway::RestApi 9 | Properties : 10 | Name : !Ref GameKitApiName 11 | Parameters: 12 | endpointConfigurationTypes: REGIONAL 13 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/cloudformation/main/cloudFormation.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION TEMPLATE 3 | Parameters: 4 | GameKitApiName: 5 | Type: String 6 | Resources : 7 | RestApi : 8 | Type : AWS::ApiGateway::RestApi 9 | Properties : 10 | Name : !Ref GameKitApiName 11 | Parameters: 12 | endpointConfigurationTypes: REGIONAL 13 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/model/config_consts.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include 6 | 7 | namespace GameKit 8 | { 9 | namespace Configuration 10 | { 11 | static const std::string DO_NOT_EDIT = "#\n# DO NOT MANUALLY EDIT\n#\n# Autogenerated by AWS GameKit\n#\n"; 12 | } 13 | } -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/cloudformation/identity/parameters.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION PARAMETERS FILE 3 | SomeParamName: 4 | value: "gamekit_dev_testgame_identity_SampleParam" 5 | 6 | SomeParamValue: 7 | value: "Testvalue" 8 | 9 | FacebookClientId: 10 | value: "{{AWSGAMEKIT::VARS::facebook_client_id}}" 11 | 12 | FacebookEnabled: 13 | value: "{{AWSGAMEKIT::VARS::is_facebook_enabled}}" -------------------------------------------------------------------------------- /tests/authentication/gamekit_authentication_exports_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "aws/gamekit/authentication/exports.h" 5 | 6 | namespace GameKit 7 | { 8 | namespace Tests 9 | { 10 | namespace GameKitSessionManager 11 | { 12 | 13 | class GameKitAuthenticationExportsTestFixture; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/encoding_utils_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace GameKit 10 | { 11 | namespace Tests 12 | { 13 | namespace EncodingUtils 14 | { 15 | class GameKitUtilsEncodingTestFixture; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/cloudformation/identity/parameters.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION PARAMETERS FILE 3 | SomeParamName: 4 | value: "gamekit_{{AWSGAMEKIT::SYS::ENV}}_{{AWSGAMEKIT::SYS::GAMENAME}}_identity_SampleParam" 5 | 6 | SomeParamValue: 7 | value: "Testvalue" 8 | 9 | FacebookClientId: 10 | value: "{{AWSGAMEKIT::VARS::facebook_client_id}}" 11 | 12 | FacebookEnabled: 13 | value: "{{AWSGAMEKIT::VARS::is_facebook_enabled}}" -------------------------------------------------------------------------------- /tests/validation_utils_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace GameKit 10 | { 11 | namespace Tests 12 | { 13 | namespace ValidationUtils 14 | { 15 | class GameKitUtilsValidationTestFixture; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/feature_resources_callback.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | extern "C" 7 | { 8 | typedef void(*FuncResourceInfoCallback)(const char* logicalResourceId, const char* resourceType, const char* resourceStatus); 9 | typedef void(*DeployedParametersCallback)(const char* parameterKey, const char* parameterValue); 10 | } 11 | -------------------------------------------------------------------------------- /tests/file_utils_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include 6 | #include "aws/gamekit/core/utils/file_utils.h" 7 | 8 | #include 9 | namespace GameKit 10 | { 11 | namespace Tests 12 | { 13 | namespace FileUtils 14 | { 15 | class GameKitUtilsFileTestFixture; 16 | } 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /tests/identity/credentials_utils_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace GameKit 10 | { 11 | namespace Tests 12 | { 13 | namespace CredentialsUtils 14 | { 15 | class GameKitUtilsCredentialsTestFixture; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/configOutputs/identity/clientConfig.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Key/value pairs to be added to the game's awsGameKitClientConfig.yml file 3 | # These values will be replaced at the end of create/update of 4 | # the feature's CloudFormation stack. 5 | 6 | user_pool_client_id: "{{AWSGAMEKIT::CFNOUTPUT::GameKitUserPoolClientId}}" 7 | identity_api_gateway_base_url: "{{AWSGAMEKIT::CFNOUTPUT::IdentityApiGatewayBaseUrl}}" 8 | identity_region: "{{AWSGAMEKIT::CFNOUTPUT::IdentityRegion}}" 9 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/cloudformation/identity/cloudFormation.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION TEMPLATE 3 | Parameters: 4 | SomeParamName: 5 | Type: String 6 | SomeParamValue: 7 | Type: String 8 | Resources: 9 | BasicParameter: 10 | Type: AWS::SSM::Parameter 11 | Properties: 12 | Name: !Ref SomeParamName 13 | Type: String 14 | Value: !Ref SomeParamValue 15 | Description: SSM sample parameter for identity. 16 | Tags: 17 | Environment: dev 18 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/cloudformation/achievements/cloudFormation.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION TEMPLATE 3 | Parameters: 4 | SomeParamName: 5 | Type: String 6 | SomeParamValue: 7 | Type: String 8 | Resources: 9 | BasicParameter: 10 | Type: AWS::SSM::Parameter 11 | Properties: 12 | Name: !Ref SomeParamName 13 | Type: String 14 | Value: !Ref SomeParamValue 15 | Description: SSM sample parameter for achivements. 16 | Tags: 17 | Environment: dev 18 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/base/cloudformation/gamesaving/cloudFormation.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION TEMPLATE 3 | Parameters: 4 | SomeParamName: 5 | Type: String 6 | SomeParamValue: 7 | Type: String 8 | Resources: 9 | BasicParameter: 10 | Type: AWS::SSM::Parameter 11 | Properties: 12 | Name: !Ref SomeParamName 13 | Type: String 14 | Value: !Ref SomeParamValue 15 | Description: SSM sample parameter for game saving. 16 | Tags: 17 | Environment: dev 18 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/cloudformation/identity/cloudFormation.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION TEMPLATE 3 | Parameters: 4 | SomeParamName: 5 | Type: String 6 | SomeParamValue: 7 | Type: String 8 | Resources: 9 | BasicParameter: 10 | Type: AWS::SSM::Parameter 11 | Properties: 12 | Name: !Ref SomeParamName 13 | Type: String 14 | Value: !Ref SomeParamValue 15 | Description: SSM sample parameter for identity. 16 | Tags: 17 | Environment: dev 18 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/cloudformation/identity/cloudFormation.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION TEMPLATE 3 | Parameters: 4 | SomeParamName: 5 | Type: String 6 | SomeParamValue: 7 | Type: String 8 | Resources: 9 | BasicParameter: 10 | Type: AWS::SSM::Parameter 11 | Properties: 12 | Name: !Ref SomeParamName 13 | Type: String 14 | Value: !Ref SomeParamValue 15 | Description: SSM sample parameter for identity. 16 | Tags: 17 | Environment: dev 18 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/cloudformation/achievements/cloudFormation.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION TEMPLATE 3 | Parameters: 4 | SomeParamName: 5 | Type: String 6 | SomeParamValue: 7 | Type: String 8 | Resources: 9 | BasicParameter: 10 | Type: AWS::SSM::Parameter 11 | Properties: 12 | Name: !Ref SomeParamName 13 | Type: String 14 | Value: !Ref SomeParamValue 15 | Description: SSM sample parameter for achivements. 16 | Tags: 17 | Environment: dev 18 | -------------------------------------------------------------------------------- /tests/core/test_data/sampleplugin/instance/testgame/dev/cloudformation/gamesaving/cloudFormation.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # THIS IS A SAMPLE CLOUDFORMATION TEMPLATE 3 | Parameters: 4 | SomeParamName: 5 | Type: String 6 | SomeParamValue: 7 | Type: String 8 | Resources: 9 | BasicParameter: 10 | Type: AWS::SSM::Parameter 11 | Properties: 12 | Name: !Ref SomeParamName 13 | Type: String 14 | Value: !Ref SomeParamValue 15 | Description: SSM sample parameter for game saving. 16 | Tags: 17 | Environment: dev 18 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/utils/gamekit_httpclient_callbacks.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | typedef void* NETWORK_STATE_RECEIVER_HANDLE; 7 | typedef void(*NetworkStatusChangeCallback)(NETWORK_STATE_RECEIVER_HANDLE dispatchReceiver, bool isConnectionOk, const char* connectionClient); 8 | typedef void* CACHE_PROCESSED_RECEIVER_HANDLE; 9 | typedef void(*CacheProcessedCallback)(CACHE_PROCESSED_RECEIVER_HANDLE dispatchReceiver, bool isCacheProcessed); -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/api.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /** @file 5 | */ 6 | 7 | #pragma once 8 | 9 | #ifdef _WIN32 10 | #define GAMEKIT_API __declspec(dllexport) 11 | #else 12 | #define GAMEKIT_API __attribute__ ((visibility ("default"))) 13 | #endif 14 | 15 | #define GAMEKIT_SDK_OPTIONS_ALLOCATION_TAG "gamekit_sdk_options" 16 | #define GAMEKIT_HTTP_CLIENT_FACTORY_ALLOCATION_TAG "gamekit_http_client" 17 | #define AWS_LOGGING_ALLOCATION_TAG "aws_logging" 18 | -------------------------------------------------------------------------------- /tests/core/gamekit_settings_exports_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | 9 | namespace GameKit 10 | { 11 | namespace Tests 12 | { 13 | namespace GameKitSettingsExport 14 | { 15 | void* createSettingsInstance(); 16 | 17 | class GameKitSettingsExportTestFixture; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/utils/debug.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | /** 7 | * Define GameKitInternalAssert helper macro. This is a wrapper for C++ assert() that is only compiled in 8 | * debug builds. No-op in Release builds. 9 | */ 10 | 11 | #if defined(_DEBUG) || defined(GAMEKIT_DEBUG) 12 | #include 13 | 14 | #define GameKitInternalAssert(value) assert(value) 15 | 16 | #else 17 | 18 | #define GameKitInternalAssert(value) (void)(value) 19 | 20 | #endif -------------------------------------------------------------------------------- /tests/authentication/gamekit_session_manager_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma once 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | namespace GameKit 10 | { 11 | namespace Tests 12 | { 13 | namespace GameKitSessionManager 14 | { 15 | Aws::UniquePtr gamekitSessionManagerInstance = nullptr; 16 | 17 | class GameKitSessionManagerTestFixture; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/zipper_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // GameKit 7 | #include 8 | #include 9 | 10 | 11 | // GTest 12 | #include 13 | namespace GameKit 14 | { 15 | namespace Tests 16 | { 17 | namespace GameKitZipper 18 | { 19 | Aws::UniquePtr gamekitZipperInstance = nullptr; 20 | class GameKitZipperTestFixture; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/core/gamekit_settings_test.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include "test_common.h" 6 | #include "aws/gamekit/core/gamekit_settings.h" 7 | #include "aws/gamekit/core/model/config_consts.h" 8 | #include "aws/gamekit/core/utils/file_utils.h" 9 | 10 | namespace GameKit 11 | { 12 | namespace Tests 13 | { 14 | namespace GameKitSettings 15 | { 16 | std::unique_ptr gamekitSettingsInstance = nullptr; 17 | class GameKitSettingsTestFixture; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/core/mocks/mock_ssm_client.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | #pragma once 4 | #include "gmock/gmock.h" 5 | 6 | #include 7 | 8 | namespace GameKit 9 | { 10 | namespace Mocks 11 | { 12 | class MockSSMClient : public Aws::SSM::SSMClient 13 | { 14 | public: 15 | MockSSMClient() {} 16 | ~MockSSMClient() {} 17 | MOCK_METHOD(Aws::SSM::Model::PutParameterOutcome, PutParameter, (const Aws::SSM::Model::PutParameterRequest& request), (const, override)); 18 | }; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/paramstore_keys.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include 6 | namespace GameKit 7 | { 8 | static const std::string GAMEKIT_LAMBDA_LAYERS_REPLACEMENT_ID_PREFIX = "GAMEKIT_LAMBDA_LAYERS_REPLACEMENT_ID_"; 9 | static const std::string GAMEKIT_LAMBDA_LAYER_ARN_PREFIX = "GAMEKIT_LAMBDA_LAYER_ARN_"; 10 | static const std::string GAMEKIT_LAMBDA_LAYER_HASH_PREFIX = "GAMEKIT_LAMBDA_LAYER_HASH_"; 11 | static const std::string GAMEKIT_LAMBDA_FUNCTIONS_REPLACEMENT_ID_PREFIX = "GAMEKIT_LAMBDA_FUNCTIONS_REPLACEMENT_ID_"; 12 | } 13 | -------------------------------------------------------------------------------- /aws_gamekit_py/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | def pytest_addoption(parser): 4 | parser.addoption( 5 | "--runslow", action="store_true", default=False, help="run slow tests" 6 | ) 7 | 8 | def pytest_configure(config): 9 | config.addinivalue_line("markers", "slow: mark test as slow to run") 10 | 11 | def pytest_collection_modifyitems(config, items): 12 | if config.getoption("--runslow"): 13 | # --runslow given in cli: do not skip slow tests 14 | return 15 | skip_slow = pytest.mark.skip(reason="need --runslow option to run") 16 | for item in items: 17 | if "slow" in item.keywords: 18 | item.add_marker(skip_slow) 19 | -------------------------------------------------------------------------------- /tests/core/mocks/mock_gamekit_account.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // GTest 7 | #include 8 | 9 | // GameKit 10 | #include 11 | 12 | using namespace GameKit; 13 | 14 | class MockGameKitAccount : public GameKitAccount 15 | { 16 | public: 17 | MockGameKitAccount(const AccountInfo& accountInfo, const AccountCredentials& credentials, FuncLogCallback logCallback) 18 | : GameKitAccount(accountInfo, credentials, logCallback) {} 19 | ~MockGameKitAccount() {} 20 | 21 | MOCK_METHOD(unsigned int, DeployApiGatewayStage, (), (override)); 22 | }; -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/gamekit_feature.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | // Standard library 6 | #include 7 | #include 8 | #include 9 | 10 | // AWS SDK 11 | #include 12 | #include 13 | 14 | // GameKit 15 | #include "errors.h" 16 | #include "logging.h" 17 | 18 | namespace GameKit 19 | { 20 | class GameKitFeature 21 | { 22 | protected: 23 | const char* m_featureName = nullptr; 24 | FuncLogCallback m_logCb = nullptr; 25 | public: 26 | GameKitFeature() {}; 27 | virtual ~GameKitFeature() {}; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /aws-gamekit-core/source/aws/gamekit/core/utils/count_ticker.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include 5 | 6 | using namespace GameKit::Utils; 7 | 8 | CountTicker::~CountTicker() 9 | { 10 | OnDestroy(); 11 | } 12 | 13 | #pragma region Protected Methods 14 | void CountTicker::startNewInterval(int intervalSeconds) 15 | { 16 | m_intervalTimeLeft = std::chrono::seconds(intervalSeconds); 17 | } 18 | 19 | void CountTicker::countDownInterval(std::chrono::milliseconds sleepTime) 20 | { 21 | m_intervalTimeLeft -= sleepTime; 22 | } 23 | 24 | bool CountTicker::isIntervalOver() const 25 | { 26 | return m_intervalTimeLeft.count() <= 0; 27 | } 28 | #pragma endregion 29 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | AWS GameKit C++ Library 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | This product includes software developed by 5 | Amazon Technologies, Inc (http://www.amazon.com/). 6 | 7 | ********************** 8 | THIRD PARTY COMPONENTS 9 | ********************** 10 | This software includes the following third-party software/licensing: 11 | Google test - https://github.com/google/googletest/blob/master/LICENSE 12 | Boost - https://www.boost.org/LICENSE_1_0.txt 13 | AWS C++ SDK - https://github.com/aws/aws-sdk-cpp 14 | yaml-cpp - https://github.com/jbeder/yaml-cpp/blob/master/LICENSE 15 | miniz v1.14 - https://github.com/richgel999/miniz/blob/v114/miniz.c 16 | pybind11 - https://github.com/pybind/pybind11/blob/master/LICENSE 17 | pytest - https://github.com/pytest-dev/pytest/blob/main/LICENSE 18 | -------------------------------------------------------------------------------- /tests/user-gameplay-data/user_gameplay_data_models_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "../core/test_common.h" 7 | #include 8 | 9 | namespace GameKit 10 | { 11 | namespace Tests 12 | { 13 | namespace DataModels 14 | { 15 | class UserGameplayDataModelsTestFixture : public ::testing::Test 16 | { 17 | public: 18 | UserGameplayDataModelsTestFixture(); 19 | ~UserGameplayDataModelsTestFixture(); 20 | 21 | virtual void SetUp() override; 22 | virtual void TearDown() override; 23 | }; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /tests/core/mocks/mock_sts_client.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace GameKit 12 | { 13 | namespace Mocks 14 | { 15 | class MockSTSClient : public Aws::STS::STSClient 16 | { 17 | public: 18 | MOCK_METHOD(Aws::STS::Model::GetCallerIdentityOutcome, GetCallerIdentity, (const Aws::STS::Model::GetCallerIdentityRequest&), (const, override)); 19 | MOCK_METHOD(Aws::STS::Model::AssumeRoleOutcome, AssumeRole, (const Aws::STS::Model::AssumeRoleRequest&), (const, override)); 20 | }; 21 | } 22 | } -------------------------------------------------------------------------------- /tests/core/simple_integration_test.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include "test_common.h" 6 | 7 | namespace GameKit 8 | { 9 | namespace Tests 10 | { 11 | namespace SimpleIntegration 12 | { 13 | Aws::UniquePtr s3Mock; 14 | Aws::UniquePtr ssmMock; 15 | Aws::UniquePtr cfnMock; 16 | 17 | using namespace testing; 18 | namespace S3Model = Aws::S3::Model; 19 | namespace SSMModel = Aws::SSM::Model; 20 | namespace CfnModel = Aws::CloudFormation::Model; 21 | 22 | class SimpleIntegrationTestFixture; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aws-gamekit-core/source/aws/gamekit/core/utils/timestamp_ticker.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include 5 | 6 | using namespace GameKit::Utils; 7 | 8 | TimestampTicker::~TimestampTicker() 9 | { 10 | OnDestroy(); 11 | } 12 | 13 | #pragma region Protected Methods 14 | void TimestampTicker::startNewInterval(int intervalSeconds) 15 | { 16 | m_intervalEndTime = std::chrono::steady_clock::now() + std::chrono::seconds(intervalSeconds); 17 | } 18 | 19 | void TimestampTicker::countDownInterval(std::chrono::milliseconds sleepTime) 20 | { 21 | // no-op by design 22 | } 23 | 24 | bool TimestampTicker::isIntervalOver() const 25 | { 26 | return std::chrono::steady_clock::now() >= m_intervalEndTime; 27 | } 28 | #pragma endregion 29 | -------------------------------------------------------------------------------- /tests/core/feature_resources_test.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include "test_common.h" 6 | 7 | namespace GameKit 8 | { 9 | namespace Tests 10 | { 11 | namespace GameKitFeatureResources 12 | { 13 | std::unique_ptr s3Mock; 14 | std::unique_ptr ssmMock; 15 | std::unique_ptr cfnMock; 16 | 17 | using namespace testing; 18 | namespace S3Model = Aws::S3::Model; 19 | namespace SSMModel = Aws::SSM::Model; 20 | namespace CfnModel = Aws::CloudFormation::Model; 21 | 22 | class GameKitFeatureResourcesTestFixture; 23 | } 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /tests/core/test_common.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // GTest 7 | #include 8 | 9 | // GameKit 10 | #include 11 | #include 12 | #include 13 | 14 | // Mocks 15 | #include "mocks/mock_apigateway_client.h" 16 | #include "mocks/mock_cloudformation_client.h" 17 | #include "mocks/mock_cognito_client.h" 18 | #include "mocks/mock_feature_resources.h" 19 | #include "mocks/mock_gamekit_account.h" 20 | #include "mocks/fake_http_client.h" 21 | #include "mocks/mock_secretsmanager_client.h" 22 | #include "mocks/mock_ssm_client.h" 23 | #include "mocks/mock_sts_client.h" 24 | #include "mocks/mock_s3_client.h" 25 | 26 | // Test settings 27 | #include "custom_test_flags.h" -------------------------------------------------------------------------------- /tests/core/count_ticker_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // GameKit 5 | #include "count_ticker_tests.h" 6 | 7 | // GTest 8 | #include 9 | 10 | using namespace GameKit::Tests::Utils; 11 | 12 | TEST_F(GameKitUtilsCountTickerTestFixture, Ticker_Executecallback_Success) 13 | { 14 | Test_Ticker_ExecuteCallback_Success(); 15 | } 16 | 17 | TEST_F(GameKitUtilsCountTickerTestFixture, Ticker_Abort_Success) 18 | { 19 | Test_Ticker_Abort_Success(); 20 | } 21 | 22 | TEST_F(GameKitUtilsCountTickerTestFixture, SharedTicker_ThreadStopsAfterTickerDestroyed) 23 | { 24 | Test_SharedTicker_ThreadStopsAfterTickerDestroyed(); 25 | } 26 | 27 | TEST_F(GameKitUtilsCountTickerTestFixture, Ticker_StartCalledTwice_NewThreadNotStarted) 28 | { 29 | Test_Ticker_StartCalledTwice_NewThreadNotStarted(); 30 | } -------------------------------------------------------------------------------- /tests/core/mocks/mock_apigateway_client.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | #pragma once 4 | 5 | #include "gmock/gmock.h" 6 | 7 | #include 8 | 9 | namespace GameKit 10 | { 11 | namespace Mocks 12 | { 13 | class MockAPIGatewayClient : public Aws::APIGateway::APIGatewayClient 14 | { 15 | public: 16 | MockAPIGatewayClient() {} 17 | ~MockAPIGatewayClient() {} 18 | MOCK_METHOD(Aws::APIGateway::Model::CreateDeploymentOutcome, CreateDeployment, (const Aws::APIGateway::Model::CreateDeploymentRequest& request), (const, override)); 19 | MOCK_METHOD(Aws::APIGateway::Model::UpdateStageOutcome, UpdateStage, (const Aws::APIGateway::Model::UpdateStageRequest& request), (const, override)); 20 | }; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | # AWS GameKit Testing 2 | To run tests in Visual Studio: 3 | 1. Load the main solution in Visual Studio and build the **aws-gamekit-cpp-tests** project. This will build AWS GameKit projects as well as Gtest dependencies. 4 | 2. Right click on the **aws-gamekit-cpp-tests** project and click on 'Run tests'. This will run ALL the tests in the project. 5 | 3. To run a single test in VS open the Test Explorer window, right click on the test and click on Run. 6 | 7 | To run all the tests suites from the command line: 8 | 1. Navigate into the **tests** directory 9 | 2. Run `ctest --verbose` 10 | 11 | To run individual tests from the command line: 12 | 1. Navigate into the tests\Debug|Release directory 13 | 2. Run the executable that contains the test code and append a regular expression that matches the name of the test to run, for example `aws-gamekit-cpp-tests.exe --gtest_filter=*Null_TestCallback*` 14 | -------------------------------------------------------------------------------- /tests/core/timestamp_ticker_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // GameKit 5 | #include "timestamp_ticker_tests.h" 6 | 7 | // GTest 8 | #include 9 | 10 | using namespace GameKit::Tests::Utils; 11 | 12 | TEST_F(GameKitUtilsSystemClockTickerTestFixture, Ticker_Executecallback_Success) 13 | { 14 | Test_Ticker_ExecuteCallback_Success(); 15 | } 16 | 17 | TEST_F(GameKitUtilsSystemClockTickerTestFixture, Ticker_Abort_Success) 18 | { 19 | Test_Ticker_Abort_Success(); 20 | } 21 | 22 | TEST_F(GameKitUtilsSystemClockTickerTestFixture, SharedTicker_ThreadStopsAfterTickerDestroyed) 23 | { 24 | Test_SharedTicker_ThreadStopsAfterTickerDestroyed(); 25 | } 26 | 27 | TEST_F(GameKitUtilsSystemClockTickerTestFixture, Ticker_StartCalledTwice_NewThreadNotStarted) 28 | { 29 | Test_Ticker_StartCalledTwice_NewThreadNotStarted(); 30 | } -------------------------------------------------------------------------------- /tests/core/sts_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "test_common.h" 7 | #include 8 | #include "aws/gamekit/core/utils/sts_utils.h" 9 | #include "test_stack.h" 10 | #include "test_log.h" 11 | 12 | #include 13 | namespace GameKit 14 | { 15 | namespace Tests 16 | { 17 | namespace Utils 18 | { 19 | class STSUtilsTestFixture : public ::testing::Test 20 | { 21 | protected: 22 | TestStackInitializer testStack; 23 | typedef TestLog TestLogger; 24 | 25 | public: 26 | STSUtilsTestFixture() {} 27 | ~STSUtilsTestFixture() {} 28 | virtual void SetUp() override; 29 | virtual void TearDown() override; 30 | }; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/zipper.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // GameKit 7 | #include 8 | 9 | namespace GameKit 10 | { 11 | // Wrapper for public-domain miniz ZIP writer - see miniz.inc 12 | // NOTE: filenames and paths use UTF-8 encoding on all platforms 13 | class GAMEKIT_API Zipper 14 | { 15 | private: 16 | void* m_zipFile; 17 | std::string m_sourcePath; 18 | 19 | public: 20 | Zipper(const std::string& sourcePath, const std::string& zipFileName); 21 | ~Zipper(); 22 | 23 | bool AddDirectoryToZipFile(const std::string& directoryPath); 24 | bool AddFileToZipFile(const std::string& fileName); 25 | bool CloseZipFile(); 26 | static void NormalizePathInZip(std::string& inOutPathInZip, const std::string& relativeSoucePath); 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /tests/core/custom_test_flags.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // Standard Library 7 | #include 8 | #include 9 | #include 10 | 11 | namespace TestFileSystemUtils 12 | { 13 | std::ptrdiff_t CountFilesInDirectory(const std::string& path); 14 | std::map CountFilesInDirectories(const std::vector& directories); 15 | size_t DeleteDirectory(const std::string& path); 16 | }; 17 | 18 | namespace TestExecutionSettings 19 | { 20 | struct CustomTestExecutionSettings 21 | { 22 | bool AbortOnFailure = false; 23 | std::vector DirectoriesToWatch; 24 | std::map InitialFileCount; 25 | }; 26 | 27 | extern CustomTestExecutionSettings Settings; 28 | }; 29 | 30 | namespace TestExecutionUtils 31 | { 32 | void AbortOnFailureIfEnabled(); 33 | }; -------------------------------------------------------------------------------- /tests/core/request_serialization_test.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include 6 | #include "aws/gamekit/core/utils/gamekit_httpclient_types.h" 7 | #include "test_stack.h" 8 | #include "test_log.h" 9 | 10 | namespace GameKit 11 | { 12 | namespace Tests 13 | { 14 | namespace Utils 15 | { 16 | class GameKitRequestSerializationTestFixture : public ::testing::Test 17 | { 18 | protected: 19 | TestStackInitializer testStack; 20 | typedef TestLog TestLogger; 21 | 22 | public: 23 | GameKitRequestSerializationTestFixture(); 24 | ~GameKitRequestSerializationTestFixture(); 25 | 26 | void SetUp(); 27 | void TearDown(); 28 | }; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/logging.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // Standard Library 7 | #include 8 | #include 9 | #include 10 | 11 | // GameKit 12 | #include "api.h" 13 | 14 | extern "C" 15 | { 16 | typedef void(*FuncLogCallback)(unsigned int level, const char* message, int size); 17 | } 18 | 19 | namespace GameKit 20 | { 21 | namespace Logger 22 | { 23 | enum class Level 24 | { 25 | None = 0, 26 | Verbose = 1, 27 | Info = 2, 28 | Warning = 3, 29 | Error = 4 30 | }; 31 | 32 | class GAMEKIT_API Logging 33 | { 34 | public: 35 | static void Log(FuncLogCallback cb, Level level, const char* message); 36 | static void Log(FuncLogCallback cb, Level level, const char* message, const void* context); 37 | }; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /aws-gamekit-identity/source/aws/gamekit/identity/utils/credentials_utils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include 5 | 6 | using namespace GameKit::Utils; 7 | 8 | #pragma region Public Methods 9 | bool CredentialsUtils::IsValidUsername(const std::string& username) 10 | { 11 | // max length defined by cognito 12 | return (username.length() >= MIN_USERNAME_CHARS && username.length() < MAX_USERNAME_CHARS); 13 | } 14 | 15 | bool CredentialsUtils::IsValidPassword(const std::string& password) 16 | { 17 | // Password regex is based on min requirements of Cognito + GameKit user pool settings 18 | if (password.length() < MIN_PASSWORD_CHARS || password.length() > MAX_PASSWORD_CHARS) 19 | { 20 | return false; 21 | } 22 | std::regex passwordRegex{ PASSWORD_REGEX }; 23 | return ValidationUtils::IsValidString(password, passwordRegex); 24 | } 25 | #pragma endregion 26 | -------------------------------------------------------------------------------- /tests/core/mocks/mock_time_provider.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include "gmock/gmock.h" 6 | 7 | #include 8 | 9 | using testing::Return; 10 | 11 | namespace GameKit 12 | { 13 | namespace Mocks 14 | { 15 | class MockCurrentTimeProvider : public GameKit::Utils::ICurrentTimeProvider 16 | { 17 | public: 18 | MockCurrentTimeProvider() {} 19 | ~MockCurrentTimeProvider() override {} 20 | 21 | /** 22 | * Convenience constructor. Makes all mock methods return the provided timestamp. 23 | */ 24 | MockCurrentTimeProvider(int64_t millisecondsSinceEpoch) 25 | { 26 | ON_CALL(*this, GetCurrentTimeMilliseconds()).WillByDefault(Return(millisecondsSinceEpoch)); 27 | } 28 | 29 | MOCK_METHOD(int64_t, GetCurrentTimeMilliseconds, (), (const, override)); 30 | }; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /aws-gamekit-achievements/source/aws/gamekit/achievements/gamekit_achievement_models.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // AWS SDK 5 | #include 6 | 7 | // GameKit 8 | #include 9 | 10 | Aws::Utils::Json::JsonValue GameKit::Achievement::ToJson() const 11 | { 12 | Aws::Utils::Json::JsonValue json; 13 | 14 | json.WithString("achievement_id", achievementId); 15 | json.WithString("title", title); 16 | json.WithString("locked_description", lockedDescription); 17 | json.WithString("unlocked_description", unlockedDescription); 18 | 19 | json.WithString("locked_icon_url", lockedIcon); 20 | json.WithString("unlocked_icon_url", unlockedIcon); 21 | 22 | json.WithInteger("max_value", requiredAmount); 23 | json.WithInteger("points", points); 24 | json.WithInteger("order_number", orderNumber); 25 | 26 | json.WithBool("is_stateful", isStateful); 27 | json.WithBool("is_secret", isSecret); 28 | json.WithBool("is_hidden", isHidden); 29 | 30 | return json; 31 | } -------------------------------------------------------------------------------- /aws-gamekit-user-gameplay-data/source/aws/gamekit/user-gameplay-data/gamekit_user_gameplay_data_models.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // AWS SDK 5 | #include 6 | 7 | // GameKit 8 | #include 9 | 10 | void GameKit::UserGameplayDataBundle::ToJson(Aws::Utils::Json::JsonValue& json) const 11 | { 12 | for (size_t i = 0; i < numKeys; i++) 13 | { 14 | json.WithString(bundleItemKeys[i], bundleItemValues[i]); 15 | } 16 | } 17 | 18 | void GameKit::UserGameplayDataDeleteItemsRequest::ToJson(Aws::Utils::Json::JsonValue& json) const 19 | { 20 | Aws::Utils::Array bundleItemJsonList(numKeys); 21 | for (size_t i = 0; i < bundleItemJsonList.GetLength(); ++i) 22 | { 23 | bundleItemJsonList[i].AsString(bundleItemKeys[i]); 24 | } 25 | 26 | json.WithArray("bundle_item_keys", std::move(bundleItemJsonList)); 27 | } 28 | 29 | void GameKit::UserGameplayDataBundleItemValue::ToJson(Aws::Utils::Json::JsonValue& json) 30 | { 31 | json.WithString("bundle_item_value", bundleItemValue); 32 | } 33 | -------------------------------------------------------------------------------- /aws-gamekit-core/source/aws/gamekit/core/logging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include 5 | 6 | using namespace GameKit::Logger; 7 | 8 | #define CONTEXT_MARK_START "[" 9 | #define CONTEXT_MARK_END "]~ " 10 | 11 | #pragma region Public Methods 12 | void Logging::Log(FuncLogCallback cb, Level level, const char* message) 13 | { 14 | if (cb != nullptr) 15 | { 16 | std::thread::id threadId = std::this_thread::get_id(); 17 | std::stringstream buffer; 18 | buffer << CONTEXT_MARK_START << "@" << threadId << CONTEXT_MARK_END << message; 19 | cb((unsigned int) level, buffer.str().c_str(), buffer.str().size()); 20 | } 21 | } 22 | 23 | void Logging::Log(FuncLogCallback cb, Level level, const char* message, const void* context) 24 | { 25 | if (cb != nullptr) 26 | { 27 | std::thread::id threadId = std::this_thread::get_id(); 28 | std::stringstream buffer; 29 | buffer << CONTEXT_MARK_START << context << "@" << threadId << CONTEXT_MARK_END << message; 30 | cb((unsigned int) level, buffer.str().c_str(), buffer.str().size()); 31 | } 32 | } 33 | #pragma endregion 34 | -------------------------------------------------------------------------------- /scripts/Win64/refresh_unreal.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import argparse 5 | import os 6 | import pathlib 7 | 8 | import sys 9 | # add parent directory with common methods to python module search path 10 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 11 | from common import copy_libs, REPOSITORY_ROOT 12 | 13 | def refresh(type, plugin_path): 14 | destination = pathlib.Path(plugin_path) / "Libraries" / "Win64" / type 15 | libs = pathlib.Path(REPOSITORY_ROOT, "install", type, "bin") 16 | copy_libs(".dll", destination, binary_dir=libs) 17 | 18 | if type == "Debug": 19 | copy_libs(".pdb", destination, binary_dir=libs) 20 | 21 | if __name__ == '__main__': 22 | parser = argparse.ArgumentParser(description="Copies library files over to the target plugin.") 23 | parser.add_argument("type", choices=["Debug", "Release"], help="Compile type for libs being copied over.") 24 | parser.add_argument("--unreal_plugin_path", required=True, help="Path to AWS GameKit Plugin for Unreal e.g. [unreal_project_path]/Plugins/AwsGameKit") 25 | args = parser.parse_args() 26 | 27 | refresh(args.type, args.unreal_plugin_path) -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/model/account_info.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // Standard Library 7 | #include 8 | #include 9 | 10 | // GameKit 11 | #include 12 | #include 13 | 14 | namespace GameKit 15 | { 16 | // Marshallable struct to be used with P/Invoke 17 | struct AccountInfo 18 | { 19 | const char* environment; 20 | const char* accountId; 21 | const char* companyName; 22 | const char* gameName; 23 | }; 24 | 25 | struct AccountInfoCopy 26 | { 27 | ResourceEnvironment environment; 28 | std::string accountId; 29 | std::string companyName; 30 | std::string gameName; 31 | }; 32 | 33 | std::string TruncateAndLower(const std::string& str, const std::regex& pattern); 34 | 35 | AccountInfoCopy GAMEKIT_API CreateAccountInfoCopy(const AccountInfo accountInfo); 36 | 37 | // Method to compose bootstrap bucket name 38 | std::string GetBootstrapBucketName(const AccountInfoCopy& accountInfo, const std::string& shortRegionCode); 39 | } 40 | -------------------------------------------------------------------------------- /tests/core/mocks/mock_secretsmanager_client.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | #pragma once 4 | 5 | #include "gmock/gmock.h" 6 | 7 | #include 8 | 9 | namespace GameKit 10 | { 11 | namespace Mocks 12 | { 13 | class MockSecretsManagerClient : public Aws::SecretsManager::SecretsManagerClient 14 | { 15 | public: 16 | MockSecretsManagerClient() {} 17 | ~MockSecretsManagerClient() {} 18 | MOCK_METHOD(Aws::SecretsManager::Model::DescribeSecretOutcome, DescribeSecret, (const Aws::SecretsManager::Model::DescribeSecretRequest& request), (const, override)); 19 | MOCK_METHOD(Aws::SecretsManager::Model::CreateSecretOutcome, CreateSecret, (const Aws::SecretsManager::Model::CreateSecretRequest& request), (const, override)); 20 | MOCK_METHOD(Aws::SecretsManager::Model::UpdateSecretOutcome, UpdateSecret, (const Aws::SecretsManager::Model::UpdateSecretRequest& request), (const, override)); 21 | MOCK_METHOD(Aws::SecretsManager::Model::DeleteSecretOutcome, DeleteSecret, (const Aws::SecretsManager::Model::DeleteSecretRequest& request), (const, override)); 22 | }; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/core/count_ticker_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // AWS SDK 7 | #include 8 | 9 | // GameKit 10 | #include "ticker_tests.h" 11 | #include "aws/gamekit/core/utils/count_ticker.h" 12 | 13 | namespace GameKit 14 | { 15 | namespace Tests 16 | { 17 | namespace Utils 18 | { 19 | class GameKitUtilsCountTickerTestFixture : public GameKitUtilsTickerTestFixture 20 | { 21 | protected: 22 | std::unique_ptr CreateTicker(int interval, std::function tickFunc, FuncLogCallback logCb) override 23 | { 24 | return std::make_unique(interval, tickFunc, TestLogger::Log); 25 | } 26 | 27 | std::shared_ptr MakeSharedTicker(const char* allocationTag, int interval, std::function tickFunc, FuncLogCallback logCb) override 28 | { 29 | return Aws::MakeShared(allocationTag, interval, tickFunc, logCb); 30 | } 31 | }; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/core/timestamp_ticker_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // AWS SDK 7 | #include 8 | 9 | // GameKit 10 | #include "ticker_tests.h" 11 | #include "aws/gamekit/core/utils/timestamp_ticker.h" 12 | 13 | namespace GameKit 14 | { 15 | namespace Tests 16 | { 17 | namespace Utils 18 | { 19 | class GameKitUtilsSystemClockTickerTestFixture : public GameKitUtilsTickerTestFixture 20 | { 21 | protected: 22 | std::unique_ptr CreateTicker(int interval, std::function tickFunc, FuncLogCallback logCb) override 23 | { 24 | return std::make_unique(interval, tickFunc, TestLogger::Log); 25 | } 26 | 27 | std::shared_ptr MakeSharedTicker(const char* allocationTag, int interval, std::function tickFunc, FuncLogCallback logCb) override 28 | { 29 | return Aws::MakeShared(allocationTag, interval, tickFunc, logCb); 30 | } 31 | }; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/model/account_credentials.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // Standard Library 7 | #include 8 | 9 | namespace GameKit 10 | { 11 | // Marshalable struct to be used with P/Invoke 12 | struct AccountCredentials 13 | { 14 | const char* region; 15 | const char* accessKey; 16 | const char* accessSecret; 17 | const char* accountId; 18 | }; 19 | 20 | struct AccountCredentialsCopy 21 | { 22 | std::string region; 23 | std::string accessKey; 24 | std::string accessSecret; 25 | std::string shortRegionCode; 26 | std::string accountId; 27 | }; 28 | 29 | inline AccountCredentialsCopy CreateAccountCredentialsCopy(const AccountCredentials& credentials) 30 | { 31 | return AccountCredentialsCopy{ credentials.region, credentials.accessKey, credentials.accessSecret }; 32 | } 33 | 34 | inline AccountCredentialsCopy CreateAccountCredentialsCopy(const AccountCredentials& credentials, const std::string& shortRegionCode) 35 | { 36 | return AccountCredentialsCopy{ credentials.region, credentials.accessKey, credentials.accessSecret, shortRegionCode }; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/aws-gamekit-bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: AWS GameKit Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Logs** 24 | If possible, any output logs captured for when the problem occurred. 25 | 26 | **Screenshots** 27 | If applicable, add screenshots to help explain your problem. 28 | 29 | **Development Environment** 30 | - Version of the AWS GameKit [e.g. 1.1] 31 | - Game Editor and Version [e.g. Unreal Editor 4.27.2] 32 | - IDE and Version [e.g. Visual Studio 2019 16.11.7] 33 | 34 | **Desktop (please complete the following information):** 35 | - OS: [e.g. Windows or Mac] 36 | - Version [e.g. 22] 37 | 38 | **Smartphone (if applicable please complete the following information for each mobile device and mobile OS version you encountered this issue with):** 39 | - Device: [e.g. iPhone6] 40 | - OS: [e.g. iOS8.1] 41 | - Version [e.g. 22] 42 | 43 | **Additional context** 44 | Add any other context about the problem here. -------------------------------------------------------------------------------- /tests/core/gamekit_account_test.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include "test_common.h" 6 | 7 | namespace GameKit 8 | { 9 | namespace Tests 10 | { 11 | namespace GameKitAccount 12 | { 13 | static const std::string PLUGIN_ROOT = "../core/test_data/sampleplugin/base"; 14 | static const std::string GAMEKIT_ROOT = "../core/test_data/sampleplugin/instance"; 15 | 16 | Aws::UniquePtr accountS3Mock; 17 | Aws::UniquePtr accountSsmMock; 18 | Aws::UniquePtr accountCfnMock; 19 | Aws::UniquePtr accountSecretsMock; 20 | 21 | using namespace testing; 22 | namespace S3Model = Aws::S3::Model; 23 | namespace SSMModel = Aws::SSM::Model; 24 | namespace CfnModel = Aws::CloudFormation::Model; 25 | namespace SecretsModel = Aws::SecretsManager::Model; 26 | namespace STSModel = Aws::STS::Model; 27 | 28 | Aws::UniquePtr testGamekitAccountInstance = nullptr; 29 | class GameKitAccountTestFixture; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /aws-gamekit-identity/include/aws/gamekit/identity/utils/credentials_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace GameKit 9 | { 10 | namespace Utils 11 | { 12 | static const int MIN_USERNAME_CHARS = 2; 13 | static const int MAX_USERNAME_CHARS = 2048; 14 | static const int MIN_PASSWORD_CHARS = 8; 15 | static const int MAX_PASSWORD_CHARS = 98; 16 | static const std::string USERNAME_REQUIREMENTS_TEXT = "Username must contain between " + std::to_string(MIN_USERNAME_CHARS) + " and " + std::to_string(MAX_USERNAME_CHARS) + " characters"; 17 | static const std::string PASSWORD_REGEX = "[a-zA-Z0-9^$*.[\\]{}()?\"!@#%&/\\\\,><':;|_~`]+"; 18 | static const std::string PASSWORD_REQUIREMENTS_TEXT = "Password must contain between " 19 | + std::to_string(MIN_PASSWORD_CHARS) + " and " 20 | + std::to_string(MAX_PASSWORD_CHARS) 21 | + " characters, and may only contain the characters \"a - z\" and \"A - Z\", the numbers \"0 - 9\", and symbols ^$*.[]{}()?\"!@#%&/\\,><':;|_~`]+"; 22 | 23 | class GAMEKIT_API CredentialsUtils 24 | { 25 | public: 26 | static bool IsValidUsername(const std::string& username); 27 | static bool IsValidPassword(const std::string& password); 28 | }; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/utils/sts_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // AWS SDK 7 | #include 8 | #include 9 | 10 | // GameKit 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace GameKit 17 | { 18 | namespace Utils 19 | { 20 | class GAMEKIT_API STSUtils 21 | { 22 | private: 23 | bool m_deleteClients; 24 | std::shared_ptr m_stsClient; 25 | FuncLogCallback m_logCb; 26 | 27 | public: 28 | STSUtils(const std::string& accessKey, const std::string& secretKey, FuncLogCallback logCallback); 29 | virtual ~STSUtils(); 30 | void SetSTSClient(std::shared_ptr stsClient); 31 | 32 | std::string GetAwsAccountId() const; 33 | bool TryGetAssumeRoleCredentials(const std::string& roleArn, const std::string& roleSessionName, const std::string& sesionPolicy, Aws::STS::Model::Credentials& sessionCredentials) const; 34 | }; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /scripts/aws_gamekit_cpp_build.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import argparse 5 | 6 | import Win64.build as windows 7 | import Android.build as android 8 | import Mac.build as mac 9 | import IOS.build as ios 10 | 11 | def build_libs(): 12 | parser = argparse.ArgumentParser(description="Builds and tests AWS GameKit cpp sdk.") 13 | platform_subparser = parser.add_subparsers(help="Target platform type.", dest="platform", required=True) 14 | 15 | windows_parser = platform_subparser.add_parser("Windows") 16 | windows.add_subparser(windows_parser) 17 | 18 | android_parser = platform_subparser.add_parser("Android") 19 | android.add_subparser(android_parser) 20 | 21 | mac_parser = platform_subparser.add_parser("Mac") 22 | mac.add_subparser(mac_parser) 23 | 24 | ios_parser = platform_subparser.add_parser("iOS") 25 | ios.add_subparser(ios_parser) 26 | 27 | parser.add_argument("type", choices=["Debug", "Release"], help="Compile type for GKCpp, Debug or Release.") 28 | args = parser.parse_args() 29 | 30 | if args.platform == "Windows": 31 | windows.build(args) 32 | elif args.platform == "Android": 33 | android.build(args) 34 | elif args.platform == "Mac": 35 | mac.build(args) 36 | elif args.platform == "iOS": 37 | ios.build(args) 38 | 39 | if __name__ == "__main__": 40 | build_libs() 41 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/internal/platform_string.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | /** @file 7 | * @brief Helper macros to handle string conversions. Do not include this in public headers. 8 | * 9 | * @details Use these macros when you need to convert from std::string to Aws::String e.g. 10 | * if you have a foo std::string variable but you need to pass Aws::String to a function, do 11 | * func(ToAwsString(foo)); 12 | */ 13 | 14 | #if defined(ANDROID) || defined(__ANDROID__) 15 | 16 | // It is not possible to assign Aws::String <-> std::string in Android so it must be converted. 17 | 18 | // Helper macro to convert Aws::String to std::string. 19 | // Note: the value will go out of scope unless you assign it to a variable. 20 | #define ToStdString(AwsStringVar) (std::string(AwsStringVar.c_str())) 21 | 22 | // Helper macro to convert std::string to Aws::String. 23 | // Note: the value will go out of scope unless you assign it to a variable. 24 | #define ToAwsString(StdStringVar) (Aws::String(StdStringVar.c_str())) 25 | 26 | #else 27 | 28 | // Other platforms don't have that limitation so macros evaluate to the same source string. 29 | 30 | #define ToStdString(AwsStringVar) (AwsStringVar) 31 | #define ToAwsString(StdStringVar) (StdStringVar) 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /tests/user-gameplay-data/user_gameplay_exports_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "../core/test_common.h" 7 | #include "../core/test_log.h" 8 | #include "../core/test_stack.h" 9 | #include "aws/gamekit/user-gameplay-data/gamekit_user_gameplay_data.h" 10 | 11 | namespace GameKit 12 | { 13 | namespace Tests 14 | { 15 | class GameKitUserGameplayDataExportsTestFixture : public ::testing::Test 16 | { 17 | protected: 18 | typedef TestLog TestLogger; 19 | 20 | TestStackInitializer testStackInitializer; 21 | 22 | void* sessionManagerInstance; 23 | 24 | void* CreateDefault(); 25 | void SetMocks(void* handle, std::shared_ptr mockHttpClient); 26 | 27 | bool ValidateItemKeysProxy(const char* const* bundleItemKeys, int numKeys, std::stringstream& tempBuffer); 28 | 29 | public: 30 | GameKitUserGameplayDataExportsTestFixture() : sessionManagerInstance(nullptr) 31 | {} 32 | 33 | ~GameKitUserGameplayDataExportsTestFixture() override 34 | {} 35 | 36 | virtual void SetUp() override; 37 | virtual void TearDown() override; 38 | }; 39 | } 40 | } -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Need help? 2 | If you have questions, comments, or simply want to engage with the AWS GameKit developer community, please leverage our [issues list](https://github.com/aws/aws-gamekit/issues) where we actively monitor and respond to developer feedback and concerns. 3 | 4 | ## Report an issue 5 | If you find a bug in the source code or a mistake in the documentation, please submit an issue using the [issue tracker](https://github.com/aws/aws-gamekit/issues/new). 6 | 7 | Before opening a new issue, please look through the [open issues](https://github.com/aws/aws-gamekit/issues) to make sure it's not a duplicate. Avoiding duplicates allows our team to spend more time fixing bugs, adding new features, and making AWS GameKit awesome. If you find an existing issue and you have additional information, please add it to that issue. 8 | 9 | The following information will ensure a quick response: 10 | 11 | * **Overview** - provide a brief, but complete, overview of the issue you're encountering. 12 | * **OS and build** - tell us about your operating system and build. 13 | * **Game engine version and build** - tell us about your game engine version and build. 14 | * **Logs** - can you spot the issue in your logs? 15 | * **Related issues** - does a similar issue exist (open or closed)? 16 | 17 | ## Pull requests 18 | We are **not** accepting pull requests or community contributed bug fixes at this time. 19 | -------------------------------------------------------------------------------- /scripts/Win64/refresh_unity.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import argparse 5 | import os 6 | import pathlib 7 | 8 | import sys 9 | # add parent directory with common methods to python module search path 10 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 11 | from common import copy_libs, REPOSITORY_ROOT 12 | 13 | def refresh(type, plugin_path): 14 | # Unity only supports targeting one set of binaries, so refreshing with a different BuildType 15 | # will overwrite older BuildType binaries in the plugin. 16 | destination = pathlib.Path(plugin_path) / "Plugins" / "Windows" / "x64" 17 | libs = pathlib.Path(REPOSITORY_ROOT, "install", type, "bin") 18 | copy_libs(".dll", destination, binary_dir=libs) 19 | 20 | if type == "Debug": 21 | copy_libs(".pdb", destination, binary_dir=libs) 22 | 23 | if __name__ == '__main__': 24 | parser = argparse.ArgumentParser(description="Copies library files over to the target plugin.") 25 | parser.add_argument("type", choices=["Debug", "Release"], help="Compile type for libs being copied over.") 26 | parser.add_argument("--unity_plugin_path", required=True, help="Path to AWs GameKit Plugin for Unity e.g. [unity_package]/Packages/com.amazonaws.gamekit") 27 | args = parser.parse_args() 28 | 29 | refresh(args.type, args.unity_plugin_path) 30 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/awsclients/api_initializer.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | // Standard Library 6 | #include 7 | #include 8 | 9 | // GameKit 10 | #include 11 | #include 12 | #if ENABLE_CUSTOM_HTTP_CLIENT_FACTORY 13 | #include 14 | #endif 15 | 16 | // AWS SDK Forward declarations 17 | namespace Aws { 18 | struct SDKOptions; 19 | namespace Http { 20 | class CreateHttpClient; 21 | } 22 | } 23 | 24 | namespace GameKit 25 | { 26 | // This singleton class helps ensure that the AWS SDK InitAPI and ShutdownAPI methods are only called once 27 | class GAMEKIT_API AwsApiInitializer 28 | { 29 | private: 30 | static std::mutex m_mutex; 31 | static bool m_isAwsSdkInitialized; 32 | static std::unique_ptr m_awsSdkOptions; 33 | static int m_count; 34 | 35 | public: 36 | // Calls Aws::InitAPI() 37 | static void Initialize(FuncLogCallback log = nullptr, const void* caller = nullptr); 38 | 39 | // Calls Aws::ShutdownAPI() 40 | static void Shutdown(FuncLogCallback log = nullptr, const void* caller = nullptr, bool force = false); 41 | 42 | static bool IsInitialized(); 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/utils/count_ticker.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // Standard Library 7 | #include 8 | 9 | // GameKit 10 | #include 11 | #include 12 | 13 | namespace GameKit 14 | { 15 | namespace Utils 16 | { 17 | /** 18 | * @brief Utility class that calls a function in its own background thread at defined intervals. 19 | * 20 | * @details The interval countdown is paused when the device is put to sleep or hibernates, and resumes when the device wakes up. 21 | */ 22 | class GAMEKIT_API CountTicker : public Ticker 23 | { 24 | private: 25 | /** 26 | * @brief The number of milliseconds left in the current interval. The interval ends when this reaches zero. 27 | */ 28 | std::chrono::milliseconds m_intervalTimeLeft = std::chrono::milliseconds(0); 29 | 30 | protected: 31 | void startNewInterval(int intervalSeconds) override; 32 | void countDownInterval(std::chrono::milliseconds sleepTime) override; 33 | bool isIntervalOver() const override; 34 | 35 | public: 36 | CountTicker(int interval, std::function tickFunc, FuncLogCallback logCb) 37 | : Ticker(interval, tickFunc, logCb) {} 38 | 39 | ~CountTicker() override; 40 | }; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/utils/timestamp_ticker.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // Standard Library 7 | #include 8 | #include 9 | 10 | // GameKit 11 | #include 12 | #include 13 | 14 | namespace GameKit 15 | { 16 | namespace Utils 17 | { 18 | /** 19 | * @brief Utility class that calls a function in its own background thread at defined intervals. 20 | * 21 | * @details The interval continues to count down when the device is put to sleep or hibernates. The callback 22 | * tick function is invoked as soon as the device wakes up if the interval elapsed while the device was sleeping/hibernating. 23 | */ 24 | class GAMEKIT_API TimestampTicker : public Ticker 25 | { 26 | private: 27 | std::chrono::time_point m_intervalEndTime = std::chrono::time_point(); 28 | 29 | protected: 30 | void startNewInterval(int intervalSeconds) override; 31 | void countDownInterval(std::chrono::milliseconds sleepTime) override; 32 | bool isIntervalOver() const override; 33 | 34 | public: 35 | TimestampTicker(int interval, std::function tickFunc, FuncLogCallback logCb) 36 | : Ticker(interval, tickFunc, logCb) {} 37 | 38 | ~TimestampTicker() override; 39 | }; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/core/mocks/mock_s3_client.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | #pragma once 4 | 5 | #include "gmock/gmock.h" 6 | 7 | #include 8 | #include 9 | 10 | namespace GameKit 11 | { 12 | namespace Mocks 13 | { 14 | class MockS3Client : public Aws::S3::S3Client 15 | { 16 | private: 17 | bool m_callDieInDestructor = false; 18 | 19 | public: 20 | MockS3Client() {} 21 | ~MockS3Client() override 22 | { 23 | if (m_callDieInDestructor) 24 | { 25 | Die(); 26 | } 27 | } 28 | MOCK_METHOD(void, Die, ()); 29 | MOCK_METHOD(Aws::S3::Model::CreateBucketOutcome, CreateBucket, (const Aws::S3::Model::CreateBucketRequest& request), (const, override)); 30 | MOCK_METHOD(Aws::S3::Model::ListBucketsOutcome, ListBuckets, (), (const, override)); 31 | MOCK_METHOD(Aws::S3::Model::PutObjectOutcome, PutObject, (const Aws::S3::Model::PutObjectRequest& request), (const, override)); 32 | MOCK_METHOD(Aws::S3::Model::PutBucketLifecycleConfigurationOutcome, PutBucketLifecycleConfiguration, (const Aws::S3::Model::PutBucketLifecycleConfigurationRequest& request), (const, override)); 33 | 34 | void CallDieInDestructor(bool callDieInDestructor) 35 | { 36 | m_callDieInDestructor = callDieInDestructor; 37 | } 38 | }; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tests/core/custom_test_flags.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // GameKit 5 | #include "custom_test_flags.h" 6 | #include 7 | 8 | // GTest 9 | #include 10 | 11 | namespace TestExecutionSettings 12 | { 13 | CustomTestExecutionSettings Settings; 14 | } 15 | 16 | std::ptrdiff_t TestFileSystemUtils::CountFilesInDirectory(const std::string& path) 17 | { 18 | return std::count_if( 19 | boost::filesystem::recursive_directory_iterator(path), 20 | boost::filesystem::recursive_directory_iterator(), 21 | static_cast(boost::filesystem::is_regular_file)); 22 | } 23 | 24 | std::map TestFileSystemUtils::CountFilesInDirectories(const std::vector& directories) 25 | { 26 | std::map fileCountPerDir; 27 | for (const std::string& dir : directories) 28 | { 29 | fileCountPerDir[dir] = TestFileSystemUtils::CountFilesInDirectory(dir); 30 | } 31 | 32 | return fileCountPerDir; 33 | } 34 | 35 | size_t TestFileSystemUtils::DeleteDirectory(const std::string& path) 36 | { 37 | if (boost::filesystem::exists(path)) 38 | { 39 | return boost::filesystem::remove_all(path); 40 | } 41 | 42 | return 0; 43 | } 44 | 45 | void TestExecutionUtils::AbortOnFailureIfEnabled() 46 | { 47 | if (TestExecutionSettings::Settings.AbortOnFailure && ::testing::Test::HasFailure()) 48 | { 49 | abort(); 50 | } 51 | } -------------------------------------------------------------------------------- /scripts/Android/refresh_unreal.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import argparse 5 | import os 6 | import pathlib 7 | 8 | import sys 9 | # add parent directory with common methods to python module search path 10 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 11 | from common import copy_libs, REPOSITORY_ROOT 12 | 13 | def add_parser_arguments(parser): 14 | parser.add_argument("--android_architecture", choices=["armv7", "arm64"], default="armv7", help="Architecture of Android libraries. Defaults to armv7") 15 | 16 | def refresh(type, plugin_path, android_architecture): 17 | destination = pathlib.Path(plugin_path) / "Libraries" / "Android" / android_architecture / type 18 | bin = pathlib.Path(REPOSITORY_ROOT, "install", type, "bin") 19 | libs = pathlib.Path(REPOSITORY_ROOT, "install", type, "lib") 20 | 21 | copy_libs(".a", destination, binary_dir=bin) 22 | copy_libs(".a", destination, binary_dir=libs) 23 | 24 | if __name__ == '__main__': 25 | parser = argparse.ArgumentParser(description="Copies library files over to the target plugin.") 26 | parser.add_argument("type", choices=["Debug", "Release"], help="Compile type for libs being copied over.") 27 | parser.add_argument("--unreal_plugin_path", required=True, help="Path to AWS GameKit Plugin for Unreal e.g. [unreal_project_path]/Plugins/AwsGameKit") 28 | parser.add_argument("--android_architecture", choices=["armv7", "arm64"], default="armv7", help="Architecture of Android libraries. Defaults to armv7") 29 | args = parser.parse_args() 30 | 31 | refresh(args.type, args.unreal_plugin_path, args.android_architecture) -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/utils/current_time_provider.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // AWS SDK 7 | #include 8 | 9 | // GameKit 10 | #include 11 | 12 | namespace GameKit 13 | { 14 | namespace Utils 15 | { 16 | /** 17 | * This class provides a wrapper over the static functions in Aws::Utils::DateTime to enable these functions to be mocked with GTest. 18 | * 19 | * See: https://sdk.amazonaws.com/cpp/api/LATEST/class_aws_1_1_utils_1_1_date_time.html 20 | * See: http://google.github.io/googletest/gmock_cook_book.html#mocking-free-functions 21 | */ 22 | class GAMEKIT_API ICurrentTimeProvider 23 | { 24 | public: 25 | ICurrentTimeProvider() {} 26 | virtual ~ICurrentTimeProvider() {} 27 | 28 | /** 29 | * Get the number of milliseconds since epoch representing this very instant. 30 | */ 31 | virtual int64_t GetCurrentTimeMilliseconds() const = 0; 32 | }; 33 | 34 | /** 35 | * Implementation that directly calls the corresponding static methods in Aws::Utils::DateTime: 36 | * https://sdk.amazonaws.com/cpp/api/LATEST/class_aws_1_1_utils_1_1_date_time.html 37 | */ 38 | class GAMEKIT_API AwsCurrentTimeProvider : public ICurrentTimeProvider 39 | { 40 | public: 41 | 42 | int64_t GetCurrentTimeMilliseconds() const override 43 | { 44 | return Aws::Utils::DateTime::CurrentTimeMillis(); 45 | } 46 | }; 47 | } 48 | } -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/awsclients/http_client_factory.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // AWS SDK 7 | #include 8 | #include 9 | 10 | // GameKit 11 | #include 12 | namespace GameKit 13 | { 14 | /** 15 | * @brief This factory is used as the HttpClient factory for both AWS SDK service clients 16 | * and GameKit API Gateway clients. 17 | * This currently only supports creating CurlHttpClient. It will be expanded later to support platform-specicic HTTP clients. 18 | * Do not override SDKOptions.httpOptions.httpClientFactory_create_fn to use the DefaultHttpClientFactory provided by AWS SDK. 19 | */ 20 | class GAMEKIT_API GameKitHttpClientFactory : public Aws::Http::HttpClientFactory 21 | { 22 | private: 23 | FuncLogCallback m_logCb = nullptr; 24 | public: 25 | GameKitHttpClientFactory(FuncLogCallback log = nullptr); 26 | virtual ~GameKitHttpClientFactory() {} 27 | 28 | void InitStaticState() override; 29 | void CleanupStaticState() override; 30 | std::shared_ptr CreateHttpClient(const Aws::Client::ClientConfiguration& clientConfiguration) const override; 31 | std::shared_ptr CreateHttpRequest(const Aws::String &uri, Aws::Http::HttpMethod method, const Aws::IOStreamFactory &streamFactory) const override; 32 | std::shared_ptr CreateHttpRequest(const Aws::Http::URI& uri, Aws::Http::HttpMethod method, const Aws::IOStreamFactory& streamFactory) const override; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /tests/user-gameplay-data/user_gameplay_data_client_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "../core/test_common.h" 7 | #include "../core/test_log.h" 8 | #include "../core/test_stack.h" 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | namespace GameKit 17 | { 18 | namespace Tests 19 | { 20 | class UserGameplayDataClientTestFixture : public ::testing::Test 21 | { 22 | protected: 23 | std::function)> authSetter; 24 | std::shared_ptr retryLogic; 25 | typedef TestLog TestLogger; 26 | TestStackInitializer testStackInitializer; 27 | 28 | public: 29 | UserGameplayDataClientTestFixture(); 30 | ~UserGameplayDataClientTestFixture(); 31 | 32 | virtual void SetUp() override; 33 | virtual void TearDown() override; 34 | 35 | void AuthSetter(std::shared_ptr request); 36 | 37 | void MockResponseCallback(GameKit::Utils::HttpClient::CallbackContext, std::shared_ptr); 38 | 39 | static void NetworkStateChangeCb(NETWORK_STATE_RECEIVER_HANDLE dispatchReceiver, bool isConnectionOk, const char* connectionClient); 40 | static void CacheProcessedCb(CACHE_PROCESSED_RECEIVER_HANDLE dispatchReceiver, bool cacheProcessed); 41 | }; 42 | } 43 | } -------------------------------------------------------------------------------- /aws_gamekit_py/README.md: -------------------------------------------------------------------------------- 1 | # aws_gamekit_py 2 | - Note: If having issues, use `python3` instead of `python` and use version `3.8.10` 3 | ## Test Setup 4 | 5 | This test suite requires a client config file (`awsGameKitClientConfig.yml`) to be placed in this folder so that the `GameKitSessionManager` can load the proper values (region, Cognito client ID, etc) and hit the proper API endpoints. It is expected that this config file is generated from a GameKit deploy through the Unreal game engine. All features should be deployed for complete testing, otherwise the corresponding tests below will fail. 6 | 7 | If you'd like to deploy and test a subset of features, see below. 8 | 9 | ### `test_deploy` 10 | 11 | `test_deploy` requires a copy of `AwsGameTechGameKitCloudResources` to be placed next to `AwsGameTechGdkCppSdk` in order to load the proper CloudFormation templates. 12 | 13 | ## Test Running 14 | 15 | After building in VisualStudio, run tests with: 16 | 17 | ```sh 18 | $ pip install -r requirements.txt 19 | $ python -m pytest 20 | ``` 21 | 22 | ### Running a Subset of Tests 23 | 24 | If you'd like to run a single test, you can specify it with the `-k` flag" 25 | 26 | ```sh 27 | $ python -m pytest -k identity 28 | ``` 29 | 30 | You can find more information in pytest's documentation about [specifying tests](https://docs.pytest.org/en/6.2.x/usage.html#specifying-tests-selecting-tests). 31 | 32 | _Note: You may have multiple python interpreters installed on your system. Make sure to use the same one that was used for building pybind, which can be found in pybind's cmakecache_ 33 | 34 | ### Slow Tests 35 | 36 | There are some slow tests (ex: `test_deploy`) that are skipped by default. If you want to run these as well, you need to pass a `--runslow` flag. This can be combined with other filters to still target specific tests. 37 | 38 | ```sh 39 | $ python -m pytest -k test_deploy --runslow 40 | ``` 41 | -------------------------------------------------------------------------------- /scripts/Mac/refresh_unity.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import argparse 5 | import os 6 | import pathlib 7 | 8 | import sys 9 | # add parent directory with common methods to python module search path 10 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 11 | from common import run_and_log, copy_libs, FEATURES, REPOSITORY_ROOT 12 | 13 | def refresh(type, plugin_path, certificate_name=None): 14 | destination = pathlib.Path(plugin_path).expanduser() / "Plugins" / "Mac" 15 | 16 | for feature in FEATURES: 17 | copy_libs(".dylib", destination, binary_dir=pathlib.Path(REPOSITORY_ROOT, f"aws-gamekit-{feature}", type)) 18 | aws_sdk_libs = pathlib.Path(REPOSITORY_ROOT, "install", "x86_64", type, "bin") 19 | copy_libs(".dylib", destination, binary_dir=aws_sdk_libs) 20 | 21 | # Fix all rpaths and symlinks in the libs after they're consolidated in one directory in unity 22 | rpath_script = REPOSITORY_ROOT / "scripts" / "Mac" / "load_path_everything.py" 23 | cmd = ["python", str(rpath_script), type, "--binaries_dir", str(destination)] 24 | 25 | if certificate_name: 26 | cmd += ["--certificate_name", certificate_name] 27 | 28 | run_and_log(cmd) 29 | 30 | if __name__ == '__main__': 31 | parser = argparse.ArgumentParser(description="Copies library files over to the target plugin.") 32 | parser.add_argument("type", choices=["Debug", "Release"], help="Compile type for libs being copied over.") 33 | parser.add_argument("--unity_plugin_path", required=True, help="Path to AWs GameKit Plugin for Unity e.g. [unity_package]/Packages/com.amazonaws.gamekit") 34 | parser.add_argument("--certificate_name", help="Apple Developer ID Application certificate for code signing.") 35 | args = parser.parse_args() 36 | 37 | refresh(args.type, args.unity_plugin_path, args.certificate_name) 38 | -------------------------------------------------------------------------------- /scripts/Mac/refresh_unreal.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import argparse 5 | import os 6 | import pathlib 7 | 8 | import sys 9 | # add parent directory with common methods to python module search path 10 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 11 | from common import run_and_log, copy_libs, FEATURES, REPOSITORY_ROOT 12 | 13 | def refresh(type, plugin_path, certificate_name=None): 14 | destination = pathlib.Path(plugin_path).expanduser() / "Libraries" / "Mac" / type 15 | 16 | for feature in FEATURES: 17 | copy_libs(".dylib", destination, binary_dir=pathlib.Path(REPOSITORY_ROOT, f"aws-gamekit-{feature}", type)) 18 | 19 | aws_sdk_libs = pathlib.Path(REPOSITORY_ROOT, "install", "x86_64", type, "bin") 20 | copy_libs(".dylib", destination, binary_dir=aws_sdk_libs) 21 | 22 | # Fix all rpaths and symlinks in the libs after they're consolidated in one directory in unreal 23 | rpath_script = REPOSITORY_ROOT / "scripts" / "Mac" / "load_path_everything.py" 24 | 25 | cmd = ["python", str(rpath_script), type, "--binaries_dir", str(destination)] 26 | if certificate_name: 27 | cmd += ["--certificate_name", certificate_name] 28 | run_and_log(cmd) 29 | 30 | if __name__ == '__main__': 31 | parser = argparse.ArgumentParser(description="Copies library files over to the target plugin.") 32 | parser.add_argument("type", choices=["Debug", "Release"], help="Compile type for libs being copied over.") 33 | parser.add_argument("--unreal_plugin_path", required=True, help="Path to AWS GameKit Plugin for Unreal e.g. [unreal_project_path]/Plugins/AwsGameKit") 34 | parser.add_argument("--certificate_name", help="Apple Developer ID Application certificate for code signing.") 35 | args = parser.parse_args() 36 | 37 | refresh(args.type, args.unreal_plugin_path, args.certificate_name) -------------------------------------------------------------------------------- /tests/core/testable_deployment_orchestrator.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // GameKit 7 | #include 8 | 9 | namespace GameKit 10 | { 11 | namespace Tests 12 | { 13 | namespace DeploymentOrchestrator 14 | { 15 | class TestableGameKitDeploymentOrchestrator : public GameKitDeploymentOrchestrator 16 | { 17 | public: 18 | TestableGameKitDeploymentOrchestrator(const std::string& baseTemplatesFolder, const std::string& instanceFilesFolder, const std::string& sourceEngine, const std::string& pluginVersion, FuncLogCallback logCb) 19 | : GameKitDeploymentOrchestrator(baseTemplatesFolder, instanceFilesFolder, sourceEngine, pluginVersion, logCb) { } 20 | 21 | void SetFeatureStatus(FeatureType feature, FeatureStatus status) 22 | { 23 | setFeatureStatus(feature, status); 24 | } 25 | 26 | void SetDeploymentInProgress(FeatureType feature, bool inProgress) 27 | { 28 | setDeploymentInProgress(feature, inProgress); 29 | } 30 | 31 | bool IsFeatureOrUpstreamDeploymentInProgress(FeatureType feature) const 32 | { 33 | return isFeatureOrUpstreamDeploymentInProgress(feature); 34 | } 35 | 36 | void SetFeatureResources(FeatureType feature, std::shared_ptr featureResources) 37 | { 38 | setFeatureResources(feature, featureResources); 39 | } 40 | 41 | void SetAccount(std::shared_ptr account) 42 | { 43 | setAccount(account); 44 | } 45 | }; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /aws-gamekit-identity/include/aws/gamekit/identity/federated_identity_provider.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // Standard Library 7 | #include 8 | 9 | // AWS SDK 10 | #include 11 | 12 | // GameKit 13 | #include 14 | #include 15 | 16 | namespace GameKit 17 | { 18 | namespace Identity 19 | { 20 | struct LoginUrlResponseInternal 21 | { 22 | unsigned int gamekitStatus; 23 | std::string requestId; 24 | std::string loginUrl; 25 | }; 26 | 27 | class IFederatedIdentityProvider 28 | { 29 | public: 30 | IFederatedIdentityProvider() {} 31 | IFederatedIdentityProvider(std::map clientSettings, FuncLogCallback logCb) {}; 32 | virtual ~IFederatedIdentityProvider() {}; 33 | virtual LoginUrlResponseInternal GetLoginUrl() = 0; 34 | virtual unsigned int PollForCompletion(const std::string& requestId, int timeout, std::string& encryptedLocation) = 0; 35 | virtual unsigned int RetrieveTokens(const std::string& location, std::string& tokens) = 0; 36 | }; 37 | 38 | template 39 | class FederatedIdentityProviderFactory 40 | { 41 | public: 42 | inline static T CreateProvider(std::map clientSettings, FuncLogCallback logCb) 43 | { 44 | return T(clientSettings, logCb); 45 | } 46 | 47 | inline static T CreateProviderWithHttpClient(std::map clientSettings, const std::shared_ptr httpClient, FuncLogCallback logCb) 48 | { 49 | return T(clientSettings, httpClient, logCb); 50 | } 51 | }; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /tests/achievements/gamekit_achievements_exports_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../core/test_common.h" 4 | #include "../core/mocks/fake_http_client.h" 5 | #include "aws/gamekit/achievements/gamekit_achievements.h" 6 | #include "aws/gamekit/achievements/exports.h" 7 | #include "aws/gamekit/authentication/exports.h" 8 | #include "../core/test_stack.h" 9 | #include "../core/test_log.h" 10 | 11 | namespace GameKit 12 | { 13 | namespace Tests 14 | { 15 | namespace AchievementsExports 16 | { 17 | class Dispatcher 18 | { 19 | public: 20 | Dispatcher() = default; 21 | DISPATCH_RECEIVER_HANDLE get() 22 | { 23 | return this; 24 | } 25 | std::string message; 26 | void CallbackHandler(const char* message); 27 | }; 28 | 29 | class GameKitAchievementsExportsTestFixture : public ::testing::Test 30 | { 31 | public: 32 | GameKitAchievementsExportsTestFixture(); 33 | ~GameKitAchievementsExportsTestFixture(); 34 | virtual void SetUp() override; 35 | virtual void TearDown() override; 36 | 37 | protected: 38 | void* createAdminAchievementsInstance(bool setToken); 39 | GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE testSessionManager = nullptr; 40 | void setAchievementsMocks(void* instance); 41 | std::shared_ptr mockHttpClient; 42 | 43 | template 44 | Outcome SuccessOutcome() 45 | { 46 | Result result; 47 | Outcome outcome(result); 48 | return outcome; 49 | } 50 | 51 | TestStackInitializer testStackInitializer; 52 | typedef TestLog TestLogger; 53 | }; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/model/template_consts.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include 6 | 7 | namespace GameKit 8 | { 9 | // Template system variables. These variables are replaced when instance templates are saved. 10 | namespace TemplateVars 11 | { 12 | static const std::string BEGIN = "\\{\\{"; 13 | static const std::string BEGIN_NO_ESCAPE = "{{"; 14 | static const std::string END = "\\}\\}"; 15 | static const std::string END_NO_ESCAPE = "}}"; 16 | static const std::string AWS_GAMEKIT_ENVIRONMENT = "AWSGAMEKIT::SYS::ENV"; 17 | static const std::string AWS_GAMEKIT_GAMENAME = "AWSGAMEKIT::SYS::GAMENAME"; 18 | static const std::string AWS_GAMEKIT_USERVAR_PREFIX = "AWSGAMEKIT::VARS::"; 19 | static const std::string AWS_GAMEKIT_CLOUDFORMATION_OUTPUT_PREFIX = "AWSGAMEKIT::CFNOUTPUT::"; 20 | static const std::string AWS_GAMEKIT_BASE36_AWS_ACCOUNTID = "AWSGAMEKIT::SYS::BASE36AWSACCOUNTID"; 21 | static const std::string AWS_GAMEKIT_SHORT_REGION_CODE = "AWSGAMEKIT::SYS::SHORTREGIONCODE"; 22 | } 23 | 24 | namespace ResourceDirectories 25 | { 26 | static const std::string CLOUDFORMATION_DIRECTORY = "/cloudformation/"; 27 | static const std::string LAYERS_DIRECTORY = "/layers/"; 28 | static const std::string FUNCTIONS_DIRECTORY = "/functions/"; 29 | static const std::string CONFIG_OUTPUTS_DIRECTORY = "/configOutputs/"; 30 | } 31 | 32 | namespace TemplateFileNames 33 | { 34 | static const std::string FEATURE_DASHBOARD_FILE = "dashboard.yml"; 35 | static const std::string CLOUDFORMATION_FILE = "cloudFormation.yml"; 36 | static const std::string PARAMETERS_FILE = "parameters.yml"; 37 | static const std::string FEATURE_CLIENT_CONFIGURATION_FILE = "clientConfig.yml"; 38 | static const std::string GAMEKIT_CLIENT_CONFIGURATION_FILE = "awsGameKitClientConfig.yml"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /scripts/Android/sample-android-user-config.jam: -------------------------------------------------------------------------------- 1 | import os ; 2 | local NDKRoot = [ os.environ NDKROOT ] ; 3 | local ClangBin = [ os.environ CLANGPATH ] ; 4 | local AndroidApiLevel = [ os.environ ANDROID_API_LEVEL ] ; 5 | local AndroidSTL = [ os.environ STL_TYPE ] ; 6 | 7 | using clang : armeabiv7a 8 | : 9 | $(ClangBin)/clang++ 10 | : 11 | -fexceptions 12 | -frtti 13 | -mthumb 14 | -ffunction-sections 15 | -funwind-tables 16 | -fstack-protector-strong 17 | -Wno-invalid-command-line-argument 18 | -Wno-unused-command-line-argument 19 | -no-canonical-prefixes 20 | -I$(NDKRoot)/sources/cxx-stl/llvm-libc++/include 21 | -I$(NDKRoot)/sources/cxx-stl/llvm-libc++abi/include 22 | -I$(NDKRoot)/sources/android/support/include 23 | -DANDROID 24 | -Wa,--noexecstack 25 | -Wformat 26 | -Werror=format-security 27 | -DNDEBUG 28 | -D_REENTRANT 29 | -O2 30 | -gcc-toolchain 31 | $(NDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 32 | -target 33 | armv7-linux-androideabi21 34 | -march=armv7-a 35 | -mfloat-abi=softfp 36 | -mfpu=vfpv3-d16 37 | -fno-builtin-memmove 38 | -fpic 39 | -DHAVE_CONFIG_H 40 | -fno-integrated-as 41 | --sysroot 42 | $(NDKRoot)/sysroot 43 | -isystem 44 | $(NDKRoot)/sysroot/usr/include/arm-linux-androideabi 45 | -D__ANDROID_API__=$(AndroidApiLevel) 46 | -DANDROID_STL=$(AndroidSTL) 47 | -target 48 | armv7a-linux-androideabi21 49 | $(NDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/arm-linux-androideabi/bin/ar 50 | $(NDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/arm-linux-androideabi/bin/ranlib 51 | ; -------------------------------------------------------------------------------- /tests/user-gameplay-data/user_gameplay_data_models_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | 5 | #include 6 | #include "user_gameplay_data_models_tests.h" 7 | 8 | using namespace GameKit::Tests::DataModels; 9 | using namespace Aws::Utils::Json; 10 | 11 | UserGameplayDataModelsTestFixture::UserGameplayDataModelsTestFixture() 12 | {} 13 | 14 | UserGameplayDataModelsTestFixture::~UserGameplayDataModelsTestFixture() 15 | {} 16 | 17 | void UserGameplayDataModelsTestFixture::SetUp() 18 | {} 19 | 20 | void UserGameplayDataModelsTestFixture::TearDown() 21 | { 22 | TestExecutionUtils::AbortOnFailureIfEnabled(); 23 | } 24 | 25 | TEST_F(UserGameplayDataModelsTestFixture, Test_SerializeToJson_UserGameplayDataBundle) 26 | { 27 | GameKit::UserGameplayDataBundle bundle; 28 | 29 | const char* keys[3] = { "Coins", "Food", "Potions" }; 30 | const char* values[3] = { "0", "10", "Red" }; 31 | bundle.bundleName = "PlayerInventory"; 32 | bundle.bundleItemKeys = keys; 33 | bundle.bundleItemValues = values; 34 | bundle.numKeys = 3; 35 | 36 | JsonValue json; 37 | bundle.ToJson(json); 38 | std::string serialized = ToStdString(json.View().WriteCompact()); 39 | std::string expected = "{\"Coins\":\"0\",\"Food\":\"10\",\"Potions\":\"Red\"}"; 40 | 41 | ASSERT_STREQ(serialized.c_str(), expected.c_str()); 42 | }; 43 | 44 | 45 | TEST_F(UserGameplayDataModelsTestFixture, Test_SerializeToJson_UserGameplayDataBundleItemValue) 46 | { 47 | GameKit::UserGameplayDataBundleItemValue bundleItemValue; 48 | 49 | bundleItemValue.bundleName = "PlayerInventory"; 50 | bundleItemValue.bundleItemKey = "Coins"; 51 | bundleItemValue.bundleItemValue = "10"; 52 | 53 | JsonValue json; 54 | bundleItemValue.ToJson(json); 55 | std::string serialized = ToStdString(json.View().WriteCompact()); 56 | std::string expected = "{\"bundle_item_value\":\"10\"}"; 57 | 58 | ASSERT_STREQ(serialized.c_str(), expected.c_str()); 59 | }; -------------------------------------------------------------------------------- /tests/core/mocks/mock_cognito_client.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include 6 | 7 | #include 8 | 9 | namespace GameKit 10 | { 11 | namespace Mocks 12 | { 13 | class MockCognitoIdentityProviderClient : public Aws::CognitoIdentityProvider::CognitoIdentityProviderClient 14 | { 15 | public: 16 | MockCognitoIdentityProviderClient() {} 17 | ~MockCognitoIdentityProviderClient() {} 18 | 19 | MOCK_METHOD(Aws::CognitoIdentityProvider::Model::RevokeTokenOutcome, RevokeToken, (const Aws::CognitoIdentityProvider::Model::RevokeTokenRequest&), (const, override)); 20 | MOCK_METHOD(Aws::CognitoIdentityProvider::Model::SignUpOutcome, SignUp, (const Aws::CognitoIdentityProvider::Model::SignUpRequest&), (const, override)); 21 | MOCK_METHOD(Aws::CognitoIdentityProvider::Model::ConfirmSignUpOutcome, ConfirmSignUp, (const Aws::CognitoIdentityProvider::Model::ConfirmSignUpRequest&), (const, override)); 22 | MOCK_METHOD(Aws::CognitoIdentityProvider::Model::ResendConfirmationCodeOutcome, ResendConfirmationCode, (const Aws::CognitoIdentityProvider::Model::ResendConfirmationCodeRequest&), (const, override)); 23 | MOCK_METHOD(Aws::CognitoIdentityProvider::Model::InitiateAuthOutcome, InitiateAuth, (const Aws::CognitoIdentityProvider::Model::InitiateAuthRequest&), (const, override)); 24 | MOCK_METHOD(Aws::CognitoIdentityProvider::Model::ForgotPasswordOutcome, ForgotPassword, (const Aws::CognitoIdentityProvider::Model::ForgotPasswordRequest&), (const, override)); 25 | MOCK_METHOD(Aws::CognitoIdentityProvider::Model::ConfirmForgotPasswordOutcome, ConfirmForgotPassword, (const Aws::CognitoIdentityProvider::Model::ConfirmForgotPasswordRequest&), (const, override)); 26 | MOCK_METHOD(Aws::CognitoIdentityProvider::Model::GetUserOutcome, GetUser, (const Aws::CognitoIdentityProvider::Model::GetUserRequest&), (const, override)); 27 | }; 28 | } 29 | } -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/utils/encoding_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // Standard Library 7 | #include 8 | #include 9 | 10 | // GameKit 11 | #include 12 | 13 | namespace GameKit 14 | { 15 | namespace Utils 16 | { 17 | static const int BASE_2 = 2; 18 | static const int BASE_16 = 16; 19 | static const int BASE_36 = 36; 20 | 21 | class GAMEKIT_API EncodingUtils 22 | { 23 | public: 24 | /** 25 | * @brief Decimal to provided base encoding. 26 | * 27 | * @details Converts an input base10 string and returns the equivalent string encoded to provided base value. 28 | * 29 | * @param decimalStr Input base10 in string form. 30 | * @param base Base to convert to. 31 | * @returns String representation of 'base' encoded decimalStr, return empty string on error. 32 | */ 33 | static std::string DecimalToBase(const std::string& decimalStr, const int base); 34 | 35 | /** 36 | * @brief Encodes a string in Base64. 37 | * 38 | * @details Converts the input string to a Base64 byte array, then converts the byte array to an ASCII compliant string. 39 | * 40 | * @param str The input string to encode. 41 | * @returns Base64 encoded variant of the input string. 42 | */ 43 | static std::string EncodeBase64(const std::string& str); 44 | 45 | /** 46 | * @brief Decodes a Base64 encoded string. 47 | * 48 | * @details Decodes the input string into a byte array, then converts the byte array into a string. 49 | * 50 | * @param encodedStr The input string to decode. 51 | * @returns Decoded variant of the Base64 encoded input string. 52 | */ 53 | static std::string DecodeBase64(const std::string& encodedStr); 54 | }; 55 | } 56 | } -------------------------------------------------------------------------------- /aws-gamekit-identity/include/aws/gamekit/identity/facebook_identity_provider.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // Standard Library 7 | #include 8 | 9 | // AWS SDK 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | // GameKit 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | // Boost 25 | #include 26 | 27 | namespace GameKit 28 | { 29 | namespace Identity 30 | { 31 | class FacebookIdentityProvider : public IFederatedIdentityProvider 32 | { 33 | private: 34 | FuncLogCallback m_logCb; 35 | std::map m_clientSettings; 36 | std::shared_ptr m_httpClient; 37 | 38 | std::shared_ptr makeRequest(const std::string& path, Aws::Http::HttpMethod method, const std::string& payload); 39 | public: 40 | FacebookIdentityProvider() : m_logCb(nullptr) {} 41 | FacebookIdentityProvider(std::map& clientSettings, FuncLogCallback logCb); 42 | FacebookIdentityProvider(std::map& clientSettings, const std::shared_ptr httpClient, FuncLogCallback logCb); 43 | ~FacebookIdentityProvider(); 44 | LoginUrlResponseInternal GetLoginUrl() override; 45 | unsigned int PollForCompletion(const std::string& requestId, int timeout, std::string& encryptedLocation) override; 46 | unsigned int RetrieveTokens(const std::string& location, std::string& tokens) override; 47 | }; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/aws_region_mappings.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // Standard Lib 7 | #include 8 | #include 9 | 10 | // GameKit 11 | #include 12 | #include 13 | 14 | // yaml-cpp 15 | #include 16 | 17 | using namespace GameKit::Logger; 18 | 19 | namespace GameKit 20 | { 21 | static const std::string GAMEKIT_AWS_REGION_MAPPINGS_FILE_NAME = "awsGameKitAwsRegionMappings.yml"; 22 | static const std::string GAMEKIT_FIVE_LETTER_REGION_CODES_PREFIX = "five_letter_region_codes"; 23 | 24 | class GAMEKIT_API AwsRegionMappings 25 | { 26 | private: 27 | std::string m_baseTemplatesFolder; 28 | YAML::Node m_regionShortCodes; 29 | FuncLogCallback m_logCb; 30 | 31 | // Make the constructors and destructor private to prevent duplicate instances 32 | AwsRegionMappings() {}; 33 | AwsRegionMappings(const std::string& baseTemplatesFolder, FuncLogCallback logCallback); 34 | ~AwsRegionMappings(); 35 | 36 | std::string GetRegionMappingsFilePath() const; 37 | 38 | public: 39 | // Delete constructors and operator overloading that should not be used 40 | AwsRegionMappings(const AwsRegionMappings&) = delete; 41 | const AwsRegionMappings& operator=(const AwsRegionMappings&) = delete; 42 | 43 | static AwsRegionMappings& getInstance(const std::string& baseTemplatesFolder, FuncLogCallback logCallback); 44 | 45 | /** 46 | * @brief Get the 5-letter region code for AWS region. 47 | * 48 | * @details Converts an input AWS region code to it's 5-letter short code based on mapping in GAMEKIT_AWS_REGION_MAPPINGS_FILE_NAME in gamekit root directory. 49 | * 50 | * @param fullRegionCode Input aws region code. 51 | * @returns 5-letter short region code based on mapping in GAMEKIT_AWS_REGION_MAPPINGS_FILE_NAME in plugin, empty string if error or doesn't exist in map. 52 | */ 53 | std::string getFiveLetterRegionCode(const std::string& fullRegionCode) const; 54 | }; 55 | } -------------------------------------------------------------------------------- /aws-gamekit-core/source/aws/gamekit/core/aws_region_mappings.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include 5 | #include 6 | 7 | using namespace GameKit; 8 | 9 | AwsRegionMappings::AwsRegionMappings(const std::string& baseTemplatesFolder, FuncLogCallback logCallback) : m_baseTemplatesFolder(baseTemplatesFolder), m_logCb(logCallback) 10 | { 11 | Logging::Log(m_logCb, Level::Info, "AwsRegionMappings instantiated"); 12 | 13 | Utils::FileUtils::ReadFileAsYAML(GetRegionMappingsFilePath(), m_regionShortCodes, m_logCb, "AwsRegionMappings: "); 14 | } 15 | 16 | AwsRegionMappings::~AwsRegionMappings() 17 | { 18 | } 19 | 20 | std::string GameKit::AwsRegionMappings::GetRegionMappingsFilePath() const 21 | { 22 | return m_baseTemplatesFolder + "/misc/" + GAMEKIT_AWS_REGION_MAPPINGS_FILE_NAME; 23 | } 24 | 25 | #pragma region Public Methods 26 | AwsRegionMappings& AwsRegionMappings::getInstance(const std::string& baseTemplatesFolder, FuncLogCallback logCallback) 27 | { 28 | static AwsRegionMappings instance(baseTemplatesFolder, logCallback); 29 | return instance; 30 | } 31 | 32 | std::string GameKit::AwsRegionMappings::getFiveLetterRegionCode(const std::string& fullRegionCode) const 33 | { 34 | try 35 | { 36 | std::string fiveLetterCode = m_regionShortCodes[GAMEKIT_FIVE_LETTER_REGION_CODES_PREFIX][fullRegionCode].Scalar(); 37 | return fiveLetterCode; 38 | } 39 | catch (... /*static-linked YAML types can't be caught in a shared .so this is likely a YAML::InvalidNode exception*/) 40 | { 41 | std::string message = "AwsRegionMappings::getFiveLetterRegionCode() Could not find a 5 letter region code for: " 42 | + fullRegionCode 43 | + " in the " 44 | + GAMEKIT_AWS_REGION_MAPPINGS_FILE_NAME + 45 | " file. This most likely means you are trying to use a newly launched AWS Region and the AWS GameKit plugin hasn't been updated yet. Please add the new region to your " 46 | + GAMEKIT_AWS_REGION_MAPPINGS_FILE_NAME 47 | + " file."; 48 | Logging::Log(m_logCb, Level::Error, message.c_str()); 49 | return ""; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/internal/wrap_boost_filesystem.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // 7 | // In GameKit source code, we never include any boost::filesystem headers directly. 8 | // The default behavior of boost::filesystem::path is to treat std::string filenames 9 | // as ANSI, even though GameKit itself has standardized on "UTF-8 everywhere", and 10 | // this mismatch will cause file operations to fail when handed UTF-8 filenames. 11 | // 12 | // Instead of including boost::filesystem headers directly, GameKit source files 13 | // should include this wrapper, which registers a module-level startup function that 14 | // reconfigures boost::filesystem to always treat std::string filenames as UTF-8. 15 | // 16 | // Including this wrapper from a public GameKit header would be bad, though, as it 17 | // would cause any project which includes this wrapper to reconfigure boost's global 18 | // behavior. So don't! Only include this wrapper from GameKit C++ source files. 19 | // 20 | // GameKit headers should use std::string for paths, not boost::filesystem::path. 21 | // If you absolutely must refer to boost::filesystem::path from a GameKit header, 22 | // forward-declare it like so, and always pass it via const reference: 23 | // 24 | // namespace boost { namespace filesystem { class path; } } 25 | // 26 | 27 | #include 28 | 29 | #include 30 | 31 | namespace GameKitInternal 32 | { 33 | #ifdef _WIN32 34 | class BoostFilesystemUtf8Initializer 35 | { 36 | private: 37 | static GAMEKIT_API std::locale GetLocale(); 38 | public: 39 | BoostFilesystemUtf8Initializer() 40 | { 41 | // This call must remain in the header to ensure that it references 42 | // global boost state in the current module, not always aws-gamekit-core 43 | boost::filesystem::path::imbue(GetLocale()); 44 | } 45 | }; 46 | 47 | // This weak declaration can be safely included in every file within a project 48 | // and the linker will quietly discard duplicates instead of generating an error. 49 | __declspec(selectany) BoostFilesystemUtf8Initializer BoostFilesystemUtf8Init; 50 | #endif 51 | } 52 | -------------------------------------------------------------------------------- /aws-gamekit-authentication/source/aws/gamekit/authentication/exports.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include 5 | #include 6 | 7 | using namespace GameKit::Logger; 8 | 9 | GAMEKIT_API GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE GameKitSessionManagerInstanceCreate(const char* clientConfigFile, FuncLogCallback logCb) 10 | { 11 | Logging::Log(logCb, Level::Info, "GameKitSessionManagerInstanceCreate"); 12 | if (clientConfigFile == nullptr) 13 | { 14 | clientConfigFile = ""; 15 | } 16 | 17 | GameKit::Authentication::GameKitSessionManager* sessionManager = new GameKit::Authentication::GameKitSessionManager(clientConfigFile, logCb); 18 | return sessionManager; 19 | } 20 | 21 | GAMEKIT_API bool GameKitSessionManagerAreSettingsLoaded(GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, GameKit::FeatureType featureType) 22 | { 23 | return ((GameKit::Authentication::GameKitSessionManager*)sessionManagerInstance)->AreSettingsLoaded(featureType); 24 | } 25 | 26 | GAMEKIT_API void GameKitSessionManagerReloadConfigFile(GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, const char* clientConfigFile) 27 | { 28 | ((GameKit::Authentication::GameKitSessionManager*)sessionManagerInstance)->ReloadConfigFile(clientConfigFile); 29 | } 30 | 31 | GAMEKIT_API void GameKitSessionManagerReloadConfigContents(GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, const char* clientConfigFileContents) 32 | { 33 | std::string fileContents(clientConfigFileContents); 34 | ((GameKit::Authentication::GameKitSessionManager*)sessionManagerInstance)->ReloadConfigFromFileContents(fileContents); 35 | } 36 | 37 | GAMEKIT_API void GameKitSessionManagerSetToken(GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance, GameKit::TokenType tokenType, const char* value) 38 | { 39 | ((GameKit::Authentication::GameKitSessionManager*)sessionManagerInstance)->SetToken(tokenType, value); 40 | } 41 | 42 | GAMEKIT_API void GameKitSessionManagerInstanceRelease(GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE sessionManagerInstance) 43 | { 44 | delete((GameKit::Authentication::GameKitSessionManager*)sessionManagerInstance); 45 | } 46 | -------------------------------------------------------------------------------- /tests/core/mocks/mock_feature_resources.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // GTest 7 | #include 8 | 9 | // GameKit 10 | #include 11 | #include 12 | 13 | using namespace GameKit; 14 | 15 | class MockGameKitFeatureResources : public GameKitFeatureResources 16 | { 17 | public: 18 | MockGameKitFeatureResources(const AccountInfo accountInfo, const AccountCredentials credentials, FeatureType featureType, FuncLogCallback logCb) 19 | : GameKitFeatureResources(accountInfo, credentials, featureType, logCb) {} 20 | virtual ~MockGameKitFeatureResources() {} 21 | 22 | MOCK_METHOD(bool, IsCloudFormationInstanceTemplatePresent, (), (override, const)); 23 | MOCK_METHOD(bool, AreLayerInstancesPresent, (), (override, const)); 24 | MOCK_METHOD(bool, AreFunctionInstancesPresent, (), (override, const)); 25 | 26 | MOCK_METHOD(unsigned int, SaveDeployedCloudFormationTemplate, (), (override, const)); 27 | MOCK_METHOD(unsigned int, GetDeployedCloudFormationParameters, (DeployedParametersCallback callback), (override, const)); 28 | MOCK_METHOD(unsigned int, SaveCloudFormationInstance, (), (override)); 29 | MOCK_METHOD(unsigned int, SaveCloudFormationInstance, (std::string, std::string), (override)); 30 | MOCK_METHOD(unsigned int, UpdateCloudFormationParameters, (), (override)); 31 | MOCK_METHOD(unsigned int, SaveLayerInstances, (), (override, const)); 32 | MOCK_METHOD(unsigned int, SaveFunctionInstances, (), (override, const)); 33 | 34 | MOCK_METHOD(unsigned int, UploadDashboard, (const std::string& path), (override)); 35 | MOCK_METHOD(unsigned int, UploadFeatureLayers, (), (override)); 36 | MOCK_METHOD(unsigned int, UploadFeatureFunctions, (), (override)); 37 | 38 | MOCK_METHOD(unsigned int, DeployFeatureLayers, (), (override)); 39 | MOCK_METHOD(unsigned int, DeployFeatureFunctions, (), (override)); 40 | 41 | MOCK_METHOD(std::string, GetCurrentStackStatus, (), (override, const)); 42 | MOCK_METHOD(void, UpdateDashboardDeployStatus, (std::unordered_set), (override, const)); 43 | 44 | MOCK_METHOD(unsigned int, CreateOrUpdateFeatureStack, (), (override)); 45 | MOCK_METHOD(unsigned int, DeleteFeatureStack, (), (override)); 46 | }; -------------------------------------------------------------------------------- /aws-gamekit-core/source/aws/gamekit/core/utils/encoding_utils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // GameKit 5 | #include 6 | #include 7 | 8 | // AWS SDK 9 | #include 10 | 11 | using namespace GameKit::Utils; 12 | 13 | #pragma region Public Methods 14 | std::string EncodingUtils::DecimalToBase(const std::string& decimalStr, const int base) 15 | { 16 | // Base less than 2 or negative input will not work 17 | if (base < 2 || decimalStr.front() == '-') 18 | { 19 | return ""; 20 | } 21 | 22 | // Try...Catch in case the string to ULL conversion fails or any other conversion errors 23 | try 24 | { 25 | // Initialize index of result 26 | int index = 0; 27 | 28 | // The longest possible string is a 64-bit binary string, there can't be more than 64 output characters plus the terminating null 29 | char res[65]; 30 | 31 | // Convert input number is given base by repeatedly 32 | // dividing it by base and taking remainder 33 | unsigned long long inputNum = std::stoull(decimalStr); 34 | while (inputNum > 0) 35 | { 36 | res[index++] = "0123456789abcdefghijklmnopqrstuvwxyz"[inputNum % base]; 37 | inputNum /= base; 38 | } 39 | res[index] = '\0'; 40 | 41 | // Reverse the result 42 | std::string resStr(res); 43 | reverse(resStr.begin(), resStr.end()); 44 | 45 | return resStr; 46 | } 47 | catch (...) 48 | { 49 | return ""; 50 | } 51 | } 52 | 53 | std::string GameKit::Utils::EncodingUtils::EncodeBase64(const std::string& str) 54 | { 55 | const Aws::Utils::Base64::Base64 base64; 56 | const Aws::Utils::ByteBuffer metadataBuffer((unsigned char*)str.c_str(), str.length()); 57 | return ToStdString(base64.Encode(metadataBuffer)); 58 | } 59 | 60 | std::string GameKit::Utils::EncodingUtils::DecodeBase64(const std::string& encodedStr) 61 | { 62 | const Aws::Utils::Base64::Base64 base64; 63 | const Aws::Utils::ByteBuffer metadataBuffer = base64.Decode(ToAwsString(encodedStr)); 64 | return std::string((char*)metadataBuffer.GetUnderlyingData(), metadataBuffer.GetLength()); 65 | } 66 | 67 | #pragma endregion 68 | -------------------------------------------------------------------------------- /aws-gamekit-core/source/aws/gamekit/core/model/account_info.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // GameKit 5 | #include 6 | 7 | // Boost 8 | #include 9 | 10 | std::string GameKit::TruncateAndLower(const std::string& str, const std::regex& pattern) 11 | { 12 | auto rbegin = std::sregex_iterator(str.begin(), str.end(), pattern); 13 | auto rend = std::sregex_iterator(); 14 | std::string matchStr; 15 | for (std::sregex_iterator i = rbegin; i != rend; ++i) 16 | { 17 | std::smatch match = *i; 18 | matchStr = match.str(); 19 | } 20 | return boost::algorithm::to_lower_copy(matchStr); 21 | } 22 | 23 | GameKit::AccountInfoCopy GameKit::CreateAccountInfoCopy(const GameKit::AccountInfo accountInfo) 24 | { 25 | AccountInfoCopy acctCopy; 26 | acctCopy.environment = ResourceEnvironment(accountInfo.environment), 27 | acctCopy.accountId = accountInfo.accountId; 28 | acctCopy.companyName = accountInfo.companyName; 29 | acctCopy.gameName = accountInfo.gameName; 30 | 31 | // using the regex pattern for each field, truncate and convert them to lowercase 32 | acctCopy.accountId = TruncateAndLower(acctCopy.accountId, std::regex("\\d{12}")); 33 | acctCopy.gameName = TruncateAndLower(acctCopy.gameName, std::regex("[a-zA-Z0-9]{1,12}")); 34 | acctCopy.companyName = TruncateAndLower(acctCopy.companyName, std::regex("[a-zA-Z0-9]{3,12}")); 35 | return acctCopy; 36 | } 37 | 38 | // Method to compose bootstrap bucket name 39 | std::string GameKit::GetBootstrapBucketName(const GameKit::AccountInfoCopy& accountInfo, const std::string& shortRegionCode) 40 | { 41 | std::string bootstrapBucketName = "do-not-delete-gamekit-"; 42 | 43 | // Bootstrap bucket names have a maximum 63 characters and has the format: 44 | // do-not-delete-gamekit--<5_letter_aws_region_code>-- 45 | bootstrapBucketName.append(accountInfo.environment.GetEnvironmentString()) 46 | .append("-") 47 | .append(shortRegionCode) 48 | .append("-") 49 | .append(GameKit::Utils::EncodingUtils::DecimalToBase(accountInfo.accountId, GameKit::Utils::BASE_36)) 50 | .append("-") 51 | .append(accountInfo.gameName); 52 | 53 | return bootstrapBucketName; 54 | } 55 | -------------------------------------------------------------------------------- /scripts/IOS/build.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import argparse 5 | import logging 6 | import os 7 | import pathlib 8 | import shutil 9 | 10 | import sys 11 | # add parent directory with common methods to python module search path 12 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 13 | from common import run_and_log, set_env_path 14 | 15 | logging.basicConfig(level=logging.INFO) 16 | 17 | def add_subparser(parser): 18 | parser.add_argument("--clean", action="store_true", default=False, help="Whether it should clean build directory before compiling.") 19 | 20 | def build(args): 21 | aws_sdk = set_env_path("GAMEKIT_AWSSDK_PATH_ios", "Path to AWSSDK (ex: ~/development/AWSSDK_ios): ") 22 | boost = set_env_path("GAMEKIT_BOOST_PATH_mac", "Path to Boost (ex: ~/development/boost_1_76_0): ") 23 | yaml_cpp = set_env_path("GAMEKIT_YAMLCPP_PATH_ios", "Path to yaml-cpp (ex: ~/development/yaml-cpp): ") 24 | curl = set_env_path("GAMEKIT_CURL_PATH_ios", "Path to curl (ex: ~/development/Build-OpenSSL-cURL): ") 25 | 26 | # make sure we're in the root of the repository 27 | script_path = pathlib.Path(__file__).absolute() 28 | repository_root = script_path.parents[2] 29 | scripts = repository_root / "scripts" / "IOS" 30 | os.chdir(repository_root) 31 | 32 | cache_file = repository_root / "CMakeCache.txt" 33 | if cache_file.exists(): 34 | os.remove(repository_root / "CMakeCache.txt") 35 | 36 | build_dir = repository_root / "build_ios" 37 | if build_dir.exists() and args.clean: 38 | shutil.rmtree(build_dir) 39 | 40 | build_dir.mkdir(exist_ok=True) 41 | os.chdir(build_dir) 42 | 43 | dependencies = [aws_sdk, boost, yaml_cpp, curl, str(repository_root), args.type] 44 | 45 | run_and_log([str(scripts / "regenerate_projects_ios.sh")] + dependencies) 46 | run_and_log(["xcodebuild", "BITCODE_GENERATION_MODE=bitcode", "-parallelizeTargets", "-configuration", args.type, 'ENABLE_BITCODE=YES', "-target", "ALL_BUILD"]) 47 | 48 | if __name__ == "__main__": 49 | parser = argparse.ArgumentParser(description="Builds iOS binaries for AWS GameKit Cpp.") 50 | parser.add_argument("type", choices=["Debug", "Release"], help="Compile type for GKCpp, Debug or Release.") 51 | add_subparser(parser) 52 | args = parser.parse_args() 53 | 54 | build(args) -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/utils/validation_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // Standard Library 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | // GameKit 13 | #include 14 | 15 | // Boost 16 | #include 17 | 18 | namespace GameKit 19 | { 20 | namespace Utils 21 | { 22 | static const int MIN_URL_PARAM_CHARS = 1; 23 | static const int MAX_URL_PARAM_CHARS = 1023; 24 | static const int MIN_S3_PARAM_CHARS = 1; 25 | static const int MAX_S3_PARAM_CHARS = 1023; 26 | static const int MIN_PRIMARY_IDENTIFIER_CHARS = 1; 27 | static const int MAX_PRIMARY_IDENTIFIER_CHARS = 512; 28 | static const std::string PRIMARY_IDENTIFIER_REGEX = "[a-zA-Z0-9-_.]+"; 29 | static const std::string PRIMARY_IDENTIFIER_REQUIREMENTS_TEXT = " must contain between " 30 | + std::to_string(MIN_PRIMARY_IDENTIFIER_CHARS) + " and " 31 | + std::to_string(MAX_PRIMARY_IDENTIFIER_CHARS) 32 | + " characters, and may only contain the characters \"a - z\" and \"A - Z\", the numbers \"0 - 9\", and symbols -_.]+"; 33 | 34 | class GAMEKIT_API ValidationUtils 35 | { 36 | public: 37 | static std::string UrlEncode(const std::string& urlParameter); 38 | static std::string TruncateString(const std::string& str, const std::regex& pattern); 39 | static std::string TruncateAndLower(const std::string& str, const std::regex& pattern); 40 | static bool IsValidString(const std::string& str, const std::regex& pattern); 41 | static bool IsValidUrlParam(const std::string& urlParam); 42 | static bool IsValidS3KeyParam(const std::string& s3KeyParam); 43 | 44 | /** 45 | * @brief Validates the given string as a primary identifier. 46 | * 47 | * @details A primary identifier is a string between 1 and 512 characters long, using alphanumeric characters, dashes (-), 48 | * underscores (_), and periods (.). Primary identifiers are safe to use in path parameters without being encoded, 49 | * DynamoDB partition and sort keys, and S3 object keys. 50 | * 51 | * @param identifier The identifier to validate. 52 | * @returns True if the identifier is a valid primary identifier, false otherwise. 53 | */ 54 | static bool IsValidPrimaryIdentifier(const std::string& identifier); 55 | }; 56 | } 57 | } -------------------------------------------------------------------------------- /tests/achievements/gamekit_admin_achievements_exports_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../core/test_common.h" 4 | #include "../core/mocks/fake_http_client.h" 5 | #include "aws/gamekit/achievements/gamekit_admin_achievements.h" 6 | #include "aws/gamekit/achievements/exports_admin.h" 7 | #include "../core/test_stack.h" 8 | #include "../core/test_log.h" 9 | 10 | namespace GameKit 11 | { 12 | namespace Tests 13 | { 14 | namespace AdminAchievementsExports 15 | { 16 | class Dispatcher 17 | { 18 | public: 19 | Dispatcher() = default; 20 | DISPATCH_RECEIVER_HANDLE get() 21 | { 22 | return this; 23 | } 24 | std::string message; 25 | void CallbackHandler(const char* message); 26 | }; 27 | 28 | class GameKitAdminAchievementsExportsTestFixture : public ::testing::Test 29 | { 30 | public: 31 | GameKitAdminAchievementsExportsTestFixture(); 32 | ~GameKitAdminAchievementsExportsTestFixture(); 33 | virtual void SetUp() override; 34 | virtual void TearDown() override; 35 | 36 | protected: 37 | static const std::string MOCK_ACCESS_ID; 38 | static const std::string MOCK_ACCESS_SECRET; 39 | static const std::string MOCK_SESSION_TOKEN; 40 | 41 | void* createAdminAchievementsInstance(bool setToken); 42 | GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE testSessionManager = nullptr; 43 | void setAchievementsMocks(void* instance); 44 | void setAchievementsAdminCredentials(GameKit::Achievements::AdminAchievements* achievementsInstance); 45 | std::shared_ptr mockHttpClient; 46 | AccountCredentials mockAccountCredentials; 47 | AccountInfo mockAccountInfo; 48 | Aws::STS::Model::Credentials mockSessionCredentials; 49 | 50 | template 51 | Outcome SuccessOutcome() 52 | { 53 | Result result; 54 | Outcome outcome(result); 55 | return outcome; 56 | } 57 | 58 | TestStackInitializer testStackInitializer; 59 | typedef TestLog TestLogger; 60 | }; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /tests/identity/gamekit_identity_exports_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "../core/test_common.h" 7 | #include 8 | #include 9 | #include "aws/gamekit/identity/gamekit_identity.h" 10 | #include "aws/gamekit/identity/facebook_identity_provider.h" 11 | #include "../core/mocks/fake_http_client.h" 12 | #include "../core/test_stack.h" 13 | #include "../core/test_log.h" 14 | 15 | namespace GameKit 16 | { 17 | namespace Tests 18 | { 19 | namespace IdentityExports 20 | { 21 | class Dispatcher 22 | { 23 | public: 24 | Dispatcher() = default; 25 | DISPATCH_RECEIVER_HANDLE get() 26 | { 27 | return this; 28 | } 29 | std::string email; 30 | std::string userName; 31 | std::string userId; 32 | void CallbackHandler(const GameKit::GetUserResponse* res); 33 | }; 34 | 35 | class GameKitIdentityExportsTestFixture : public ::testing::Test 36 | { 37 | public: 38 | GameKitIdentityExportsTestFixture(); 39 | ~GameKitIdentityExportsTestFixture(); 40 | virtual void SetUp() override; 41 | virtual void TearDown() override; 42 | std::string GetCognitoGetUserApiResponse(); 43 | std::string GetIdentityLambdaGetUserApiResponse(); 44 | 45 | protected: 46 | typedef TestLog TestLogger; 47 | 48 | TestStackInitializer testStackInitializer; 49 | 50 | void* createIdentityInstance(); 51 | void* createIdentityInstanceWithNoSessionManagerTokens(); 52 | void setIdentityMocks(void* instance); 53 | Aws::UniquePtr cognitoMock; 54 | std::shared_ptr mockHttpClient; 55 | GAMEKIT_SESSIONMANAGER_INSTANCE_HANDLE testSessionManager = nullptr; 56 | 57 | template 58 | Outcome SuccessOutcome() 59 | { 60 | Result result; 61 | Outcome outcome(result); 62 | return outcome; 63 | } 64 | }; 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /aws-gamekit-achievements/include/aws/gamekit/achievements/gamekit_achievements_models.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // AWS SDK Forward Declaration 7 | namespace Aws { namespace Utils { namespace Json { class JsonValue; class JsonView; } } } 8 | 9 | namespace GameKit 10 | { 11 | 12 | struct Achievement 13 | { 14 | /** 15 | * @brief Unique identifier for the achievement 16 | */ 17 | const char* achievementId; 18 | 19 | /** 20 | * @brief Title for the achievement, can be used for display purposes. 21 | */ 22 | const char* title; 23 | 24 | /** 25 | * @brief Description that should show if the achievement is unearned and/or secret. 26 | */ 27 | const char* lockedDescription; 28 | 29 | /** 30 | * @brief Description that should show after an achievement is earned. 31 | */ 32 | const char* unlockedDescription; 33 | 34 | /** 35 | * @brief Icon path that should be concatenated onto base icon url, this icon should 36 | * show when the achievement is unearned or secret. 37 | */ 38 | const char* lockedIcon; 39 | 40 | /** 41 | * @brief Icon path that should be concatenated onto base icon url, this icon should 42 | * be shown after the achievement is earned. 43 | */ 44 | const char* unlockedIcon; 45 | 46 | /** 47 | * @brief The number of steps a player must make on the achievement before it is earned. 48 | */ 49 | unsigned int requiredAmount; 50 | 51 | /** 52 | * @brief How many points should be attributed to earning this achievement. 53 | */ 54 | unsigned int points; 55 | 56 | /** 57 | * @brief A Number you can use to sort which achievements should be displayed first. 58 | */ 59 | unsigned int orderNumber; 60 | 61 | /** 62 | * @brief Describes whether this achievement only requires one step to complete, or multiple. 63 | */ 64 | bool isStateful; 65 | 66 | /** 67 | * @brief A flag that can be used to filter out achievements from the player's view. 68 | */ 69 | bool isSecret; 70 | 71 | /** 72 | * @brief When hidden players cannot make progress on or earn the achievement, until set to false. 73 | */ 74 | bool isHidden; 75 | 76 | Aws::Utils::Json::JsonValue ToJson() const; 77 | }; 78 | } 79 | -------------------------------------------------------------------------------- /tests/core/test_stack.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // GameKit 7 | #include "mocks/fake_http_client.h" 8 | #include "custom_test_flags.h" 9 | 10 | // GTest 11 | #include 12 | 13 | /* 14 | Fake HTTP client that always responds 418 15 | */ 16 | class SameResponseClient : public FakeHttpClient 17 | { 18 | public: 19 | std::shared_ptr MakeRequest(const std::shared_ptr& request, 20 | Aws::Utils::RateLimits::RateLimiterInterface* readLimiter = nullptr, 21 | Aws::Utils::RateLimits::RateLimiterInterface* writeLimiter = nullptr) 22 | const override 23 | { 24 | std::shared_ptr dummyResponse = std::make_shared(); 25 | dummyResponse->SetResponseCode(Aws::Http::HttpResponseCode::IM_A_TEAPOT); 26 | 27 | return dummyResponse; 28 | } 29 | }; 30 | 31 | /* 32 | Helper class to initialize the AWS Stack. Initializes the HTTP stack with Mock HTTP Clients and the Crypto stack. 33 | */ 34 | class TestStackInitializer 35 | { 36 | private: 37 | std::shared_ptr testMockFactory; 38 | std::shared_ptr testFakeClient; 39 | 40 | public: 41 | 42 | // Initialize the HTTP stack with a mock http client (retrieve it with GetMockHttpClientFactory()) and the Crypto stack. 43 | void Initialize(); 44 | 45 | // Initialize the HTTP stack with the given mock http client (retrieve it with GetMockHttpClientFactory()) and the Crypto stack. 46 | // Use this method if you want to reuse the same client for ALL AWS calls. 47 | void Initialize(std::shared_ptr mockHttpClient); 48 | 49 | // Reset the HTTP and Crypto stacks 50 | void Cleanup(); 51 | 52 | // Reset the HTTP and Crypto stacks and write test log in case of test failures. 53 | template 54 | void CleanupAndLog() 55 | { 56 | Cleanup(); 57 | 58 | // Verify test is ends on a clean state. If the AwsApiInitializer is still in an 59 | // Initialized state verify that the test released all its GameKit handles 60 | EXPECT_FALSE(GameKit::AwsApiInitializer::IsInitialized()) 61 | << "GameKit::AwsApiInitializer must not be in an Initialized state after a test ends."; 62 | 63 | TestLogger_t::DumpToConsoleIfTestFailed(); 64 | TestLogger_t::Clear(); 65 | } 66 | 67 | // Get the Mock factory. 68 | std::shared_ptr GetMockHttpClientFactory() const; 69 | }; -------------------------------------------------------------------------------- /tests/core/gamekit_core_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // GameKit 5 | #include "aws/gamekit/core/logging.h" 6 | #include "custom_test_flags.h" 7 | #include "test_log.h" 8 | 9 | // Gtest 10 | #include 11 | 12 | // Standard Library 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace GameKit::Logger; 18 | 19 | class LoggingTestFixture; 20 | static LoggingTestFixture* instance = nullptr; 21 | typedef std::map> MessageMap; 22 | 23 | class LoggingTestFixture : public ::testing::Test 24 | { 25 | public: 26 | typedef TestLog TestLogger; 27 | 28 | LoggingTestFixture() 29 | {} 30 | 31 | void SetUp() 32 | { 33 | instance = this; 34 | TestLogger::Clear(); 35 | } 36 | 37 | void TearDown() 38 | { 39 | instance = nullptr; 40 | 41 | TestLogger::DumpToConsoleIfTestFailed(); 42 | TestLogger::Clear(); 43 | TestExecutionUtils::AbortOnFailureIfEnabled(); 44 | } 45 | 46 | ~LoggingTestFixture() 47 | {} 48 | 49 | static bool FindInLog(const std::string& str) 50 | { 51 | auto findHelper = [&](const std::string& line) 52 | { 53 | return line.find(str) != std::string::npos; 54 | }; 55 | 56 | return std::find_if( 57 | TestLogger::GetLogLines().begin(), 58 | TestLogger::GetLogLines().end(), findHelper) != TestLogger::GetLogLines().end(); 59 | } 60 | }; 61 | 62 | TEST_F(LoggingTestFixture, Null_TestCallback) 63 | { 64 | Logging::Log(nullptr, Level::Info, "hello"); 65 | 66 | EXPECT_EQ(TestLogger::GetLogLines().size(), 0); 67 | } 68 | 69 | TEST_F(LoggingTestFixture, ValidCallback_TestCallback) 70 | { 71 | Logging::Log(TestLogger::Log, Level::Verbose, "hello"); 72 | 73 | EXPECT_TRUE(FindInLog("hello")); 74 | EXPECT_EQ(TestLogger::GetLogLines().size(), 1); 75 | } 76 | 77 | TEST_F(LoggingTestFixture, AllLevels_TestCallback) 78 | { 79 | Logging::Log(TestLogger::Log, Level::None, "None"); 80 | Logging::Log(TestLogger::Log, Level::Verbose, "Verbose"); 81 | Logging::Log(TestLogger::Log, Level::Info, "Info"); 82 | Logging::Log(TestLogger::Log, Level::Warning, "Warning"); 83 | Logging::Log(TestLogger::Log, Level::Error, "Error"); 84 | 85 | EXPECT_TRUE(FindInLog("None")); 86 | EXPECT_TRUE(FindInLog("Verbose")); 87 | EXPECT_TRUE(FindInLog("Info")); 88 | EXPECT_TRUE(FindInLog("Warning")); 89 | EXPECT_TRUE(FindInLog("Error")); 90 | EXPECT_EQ(TestLogger::GetLogLines().size(), 5); 91 | } 92 | -------------------------------------------------------------------------------- /tests/core/gamekit_core_exports_tests.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include "test_common.h" 6 | #include 7 | #include 8 | 9 | namespace GameKit 10 | { 11 | namespace Tests 12 | { 13 | namespace CoreExports 14 | { 15 | static const char* DUMMY_INSTANCE_PATH = "tests/core/test_data/sampleplugin/dummyinstance"; 16 | std::unique_ptr coreS3Mock; 17 | std::unique_ptr coreSsmMock; 18 | std::unique_ptr coreCfnMock; 19 | std::unique_ptr coreSecretsMock; 20 | std::unique_ptr coreApigwMock; 21 | 22 | using namespace testing; 23 | namespace S3Model = Aws::S3::Model; 24 | namespace SSMModel = Aws::SSM::Model; 25 | namespace CfnModel = Aws::CloudFormation::Model; 26 | namespace SecretsModel = Aws::SecretsManager::Model; 27 | namespace ApigwModel = Aws::APIGateway::Model; 28 | 29 | class GameKitCoreExportsTestFixture; 30 | void* createAccountInstance(); 31 | void* createFeatureResourceInstance(GameKit::FeatureType featureType); 32 | void setAccountMocks(void*); 33 | void setResourceMocks(void*); 34 | 35 | // Templated structs that forward a callback to an object 36 | template struct CallbackHandler; 37 | template 38 | struct CallbackHandler 39 | { 40 | static RetType OnCallback(void* obj, Args... args) 41 | { 42 | Target* instance = static_cast(obj); 43 | return (instance->*CbFunc)(std::forward(args)...); 44 | } 45 | 46 | static RetType OnCallback(void* obj, Args&&... args) 47 | { 48 | Target* instance = static_cast(obj); 49 | return (instance->*CbFunc)(std::forward(args)...); 50 | } 51 | }; 52 | 53 | // Used as callback to handle c-strings 54 | class SimpleCaller 55 | { 56 | public: 57 | virtual void OnHandleResult(const char* result) = 0; 58 | }; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /tests/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Gtest 5 | #include 6 | 7 | // Test 8 | #include "core/custom_test_flags.h" 9 | 10 | // Main test entrypoint. Must be defined when gtest and gmock are linked. 11 | int main(int argc, char** argv) 12 | { 13 | // Disable EC2 metadata requests 14 | putenv("AWS_EC2_METADATA_DISABLED=true"); 15 | #ifdef _WIN32 16 | putenv("AWS_SHARED_CREDENTIALS_FILE=..\\core\\test_data\\testFiles\\credentialsTests\\test_credentials"); 17 | #else 18 | putenv("AWS_SHARED_CREDENTIALS_FILE=../core/test_data/testFiles/credentialsTests/test_credentials"); 19 | #endif 20 | 21 | // Parse command line and run all the tests 22 | ::testing::InitGoogleTest(&argc, argv); 23 | 24 | // InitGoogleTest removes Google test arguments, now parse our custom arguments 25 | // arg[0] is the executable name. Supported arguments: 26 | // --filesystem_check: Count number of files inside a set of directories before and after tests run. 27 | // Use this to verify that temporary test artifacts are removed. 28 | // --abort_on_failure: If a test fails, execute its TearDown() logic and then abort the process. 29 | // This is different from --gtest_break_on_failure because the latter will stop the test 30 | // as soon as it fails and won't execute TearDown(). We want TearDown() because GameKit tests 31 | // write logs on failure and we need as much diagnostic information as possible. 32 | 33 | if (argc > 1) 34 | { 35 | TestExecutionSettings::CustomTestExecutionSettings customSettings; 36 | 37 | for (size_t i = 1; i < argc; ++i) 38 | { 39 | std::string arg = argv[i]; 40 | if (arg == "--filesystem_check") 41 | { 42 | std::cout << "Recognized argument: " << arg << std::endl; 43 | customSettings.DirectoriesToWatch.push_back("../core/test_data"); 44 | customSettings.InitialFileCount = TestFileSystemUtils::CountFilesInDirectories(customSettings.DirectoriesToWatch); 45 | } 46 | else if (arg == "--abort_on_failure") 47 | { 48 | std::cout << "Recognized argument: " << arg << std::endl; 49 | customSettings.AbortOnFailure = true; 50 | } 51 | else 52 | { 53 | std::cout << "Argument not recognized: " << arg << std::endl; 54 | } 55 | } 56 | 57 | TestExecutionSettings::Settings = customSettings; 58 | } 59 | 60 | return RUN_ALL_TESTS(); 61 | } 62 | -------------------------------------------------------------------------------- /tests/core/aws_region_mappings_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "aws_region_mappings_test.h" 5 | #include "test_log.h" 6 | #include "custom_test_flags.h" 7 | 8 | class GameKit::Tests::GameKitAwsRegionMappingsTestFixture : public ::testing::Test 9 | { 10 | protected: 11 | typedef TestLog TestLogger; 12 | 13 | public: 14 | GameKitAwsRegionMappingsTestFixture() 15 | { 16 | } 17 | 18 | ~GameKitAwsRegionMappingsTestFixture() 19 | { 20 | } 21 | 22 | void SetUp() override 23 | { 24 | } 25 | 26 | void TearDown() override 27 | { 28 | TestLogger::DumpToConsoleIfTestFailed(); 29 | TestLogger::Clear(); 30 | TestExecutionUtils::AbortOnFailureIfEnabled(); 31 | } 32 | }; 33 | 34 | using namespace GameKit::Tests; 35 | 36 | TEST_F(GameKitAwsRegionMappingsTestFixture, TestGetFiveLetterRegionCode_ValidRegion_ValidShortCode) 37 | { 38 | // act 39 | GameKit::AwsRegionMappings& instance = GameKit::AwsRegionMappings::getInstance("../core/test_data/testFiles/regionMappingsTests", TestLogger::Log); 40 | std::string fiveLetterCode = instance.getFiveLetterRegionCode(std::string("us-east-1")); 41 | 42 | // assert 43 | ASSERT_EQ("usea1", fiveLetterCode); 44 | } 45 | 46 | TEST_F(GameKitAwsRegionMappingsTestFixture, TestGetFiveLetterRegionCode_InvalidRegion_EmptyShortCode) 47 | { 48 | // act 49 | GameKit::AwsRegionMappings& instance = GameKit::AwsRegionMappings::getInstance("../core/test_data/testFiles/regionMappingsTests", TestLogger::Log); 50 | std::string fiveLetterCode = instance.getFiveLetterRegionCode(std::string("wrong-region-1")); 51 | 52 | // assert 53 | ASSERT_EQ("", fiveLetterCode); 54 | } 55 | 56 | TEST_F(GameKitAwsRegionMappingsTestFixture, TestGetFiveLetterRegionCode_EmptyRegion_EmptyShortCode) 57 | { 58 | // act 59 | GameKit::AwsRegionMappings& instance = GameKit::AwsRegionMappings::getInstance("../core/test_data/testFiles/regionMappingsTests", TestLogger::Log); 60 | std::string fiveLetterCode = instance.getFiveLetterRegionCode(std::string("")); 61 | 62 | // assert 63 | ASSERT_EQ("", fiveLetterCode); 64 | } 65 | 66 | TEST_F(GameKitAwsRegionMappingsTestFixture, TestGetFiveLetterRegionCode_UnitializedRegionString_EmptyShortCode) 67 | { 68 | // act 69 | GameKit::AwsRegionMappings& instance = GameKit::AwsRegionMappings::getInstance("../core/test_data/testFiles/regionMappingsTests", TestLogger::Log); 70 | std::string region; 71 | std::string fiveLetterCode = instance.getFiveLetterRegionCode(region); 72 | 73 | // assert 74 | ASSERT_EQ("", fiveLetterCode); 75 | } -------------------------------------------------------------------------------- /tests/core/test_log.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // GameKit 7 | #include 8 | 9 | // GTest 10 | #include 11 | 12 | // Standard Library 13 | #include 14 | #include 15 | #include 16 | 17 | /* 18 | Helper class to capture GameKit logs during tests. 19 | */ 20 | template 21 | class TestLog 22 | { 23 | private: 24 | static std::vector logLines; 25 | 26 | public: 27 | static void Log(unsigned int level, const char* message, int size) 28 | { 29 | long long nowMilliseconds = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); 30 | 31 | std::string formattedMessage = 32 | std::to_string(nowMilliseconds) 33 | .append("|") 34 | .append(std::to_string(level)) 35 | .append("|") 36 | .append(message); 37 | 38 | TestLog::logLines.push_back(formattedMessage); 39 | } 40 | 41 | static const std::vector& GetLogLines() 42 | { 43 | return TestLog::logLines; 44 | } 45 | 46 | static void DumpToConsole(const std::string& header, bool isError) 47 | { 48 | std::ostream& os = isError ? std::cerr : std::cout; 49 | size_t prefix = std::hash{}(header); 50 | os << prefix << '|' << "TestLog::DumpToConsole() for " << header << " start" << std::endl; 51 | for (const std::string& line : TestLog::logLines) 52 | { 53 | os << prefix << '|' << line << std::endl; 54 | } 55 | os << prefix << '|' << "TestLog::DumpToConsole() for " << header << " end" << std::endl; 56 | } 57 | 58 | static void DumpToConsole(const testing::TestInfo* test_info, bool isError) 59 | { 60 | std::stringstream testName; 61 | testName << test_info->test_suite_name() << "." << test_info->name(); 62 | 63 | DumpToConsole(testName.str(), isError); 64 | } 65 | 66 | static void DumpToConsole(bool isError = false) 67 | { 68 | DumpToConsole("(unknown)", "", isError); 69 | } 70 | 71 | static void DumpToConsoleIfTestFailed() 72 | { 73 | if (::testing::Test::HasFailure()) 74 | { 75 | const testing::TestInfo* test_info = testing::UnitTest::GetInstance()->current_test_info(); 76 | DumpToConsole(test_info, true); 77 | } 78 | } 79 | 80 | static void Clear() 81 | { 82 | TestLog::logLines.clear(); 83 | } 84 | }; 85 | 86 | template 87 | std::vector TestLog::logLines; -------------------------------------------------------------------------------- /aws-gamekit-core/source/aws/gamekit/core/utils/sts_utils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include 5 | #include 6 | 7 | namespace STSModel = Aws::STS::Model; 8 | using STSClient = Aws::STS::STSClient; 9 | using AWSCredentials = Aws::Auth::AWSCredentials; 10 | 11 | using namespace GameKit::Utils; 12 | using namespace GameKit::Logger; 13 | 14 | #pragma region Constructors/Destructor 15 | STSUtils::STSUtils(const std::string& accessKey, const std::string& secretKey, FuncLogCallback logCallback) : 16 | m_deleteClients(true), m_logCb(logCallback) 17 | { 18 | GameKit::AwsApiInitializer::Initialize(m_logCb, this); 19 | AWSCredentials credentials(ToAwsString(accessKey), ToAwsString(secretKey)); 20 | 21 | m_stsClient = std::make_shared(credentials); 22 | } 23 | 24 | void STSUtils::SetSTSClient(std::shared_ptr client) 25 | { 26 | m_stsClient = client; 27 | } 28 | 29 | STSUtils::~STSUtils() 30 | { 31 | GameKit::AwsApiInitializer::Shutdown(m_logCb, this); 32 | } 33 | #pragma endregion 34 | 35 | #pragma region Public Methods 36 | std::string STSUtils::GetAwsAccountId() const 37 | { 38 | STSModel::GetCallerIdentityRequest request; 39 | STSModel::GetCallerIdentityOutcome outcome = m_stsClient->GetCallerIdentity(request); 40 | 41 | if (outcome.IsSuccess()) 42 | { 43 | Aws::STS::Model::GetCallerIdentityResult result = outcome.GetResult(); 44 | Aws::String account = result.GetAccount(); 45 | 46 | return ToStdString(account); 47 | } 48 | else 49 | { 50 | Logging::Log(m_logCb, Level::Error, outcome.GetError().GetMessage().c_str()); 51 | } 52 | 53 | return ""; 54 | } 55 | 56 | bool STSUtils::TryGetAssumeRoleCredentials(const std::string& roleArn, const std::string& roleSessionName, const std::string& sesionPolicy, 57 | Aws::STS::Model::Credentials& sessionCredentials) const 58 | { 59 | STSModel::AssumeRoleRequest request; 60 | request.SetRoleArn(ToAwsString(roleArn)); 61 | request.SetRoleSessionName(ToAwsString(roleSessionName)); 62 | request.SetPolicy(ToAwsString(sesionPolicy)); 63 | 64 | STSModel::AssumeRoleOutcome outcome = m_stsClient->AssumeRole(request); 65 | 66 | if (outcome.IsSuccess()) 67 | { 68 | STSModel::AssumeRoleResult result = outcome.GetResult(); 69 | sessionCredentials = result.GetCredentials(); 70 | return true; 71 | } 72 | else 73 | { 74 | Logging::Log(m_logCb, Level::Error, outcome.GetError().GetMessage().c_str()); 75 | } 76 | return false; 77 | } 78 | #pragma endregion 79 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | cmake_minimum_required(VERSION 3.20) 5 | 6 | message("Build Configuration=${CMAKE_BUILD_TYPE}") 7 | 8 | set(CMAKE_CXX_STANDARD 11) 9 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 10 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DGAMEKIT_DEBUG") 11 | 12 | if(MSVC) 13 | # Enable multi-processor compilation 14 | add_compile_options($<$:/MP>) 15 | add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE) 16 | endif() 17 | 18 | project(aws-gamekit-cpp) 19 | 20 | string(TOLOWER "${TARGET_ARCH}" TARGET_ARCH_LOWER) 21 | if ("${TARGET_ARCH_LOWER}" STREQUAL "android") 22 | # Android settings 23 | list(APPEND CMAKE_FIND_ROOT_PATH "${AWSSDK_ROOT_DIR}") 24 | list(APPEND CMAKE_FIND_ROOT_PATH "${BOOST_ROOT}") 25 | list(APPEND CMAKE_PREFIX_PATH "${CURL_LIB_DIR}") 26 | list(APPEND CMAKE_PREFIX_PATH "${OPENSSL_ROOT_DIR}") 27 | set(GAMEKIT_ANDROID True) 28 | 29 | # Boost 30 | find_package(Boost 1.76.0 COMPONENTS filesystem iostreams regex) 31 | 32 | # Curl and SSL libraries are auto included by AWS SDK, we want to set them explicitly from the 33 | # command line 34 | find_package(OpenSSL) 35 | find_package(CURL) 36 | 37 | set(ANDROID_LIBS_TO_REMOVE curl ssl crypto) 38 | set(ANDROID_CURL_SSL_LIBS OpenSSL::SSL OpenSSL::Crypto CURL::libcurl) 39 | 40 | string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) 41 | if ("${CMAKE_BUILD_TYPE_LOWER}" STREQUAL "release") 42 | set_target_properties(CURL::libcurl PROPERTIES IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY}") 43 | else() 44 | set_target_properties(CURL::libcurl PROPERTIES IMPORTED_LOCATION_DEBUG "${CURL_LIBRARY}") 45 | endif() 46 | 47 | # Help the linker to find libcrypto/crypto library 48 | cmake_path(APPEND OPENSSL_ROOT_DIR "lib" OUTPUT_VARIABLE OPENSSL_LIBS_DIR) 49 | link_directories(${OPENSSL_LIBS_DIR}) 50 | else() 51 | set(GAMEKIT_ANDROID False) 52 | set(ANDROID_CURL_SSL_LIBS "") 53 | endif() 54 | 55 | # AWS SDK and CRT dependencies 56 | find_package(AWSSDK REQUIRED COMPONENTS apigateway cloudformation cognito-idp lambda s3 ssm secretsmanager sts) 57 | 58 | find_package(yaml-cpp) 59 | 60 | if (DEFINED pybind11_DIR) 61 | add_subdirectory(aws_gamekit_py) 62 | endif() 63 | 64 | add_subdirectory(aws-gamekit-core) 65 | add_subdirectory(aws-gamekit-identity) 66 | add_subdirectory(aws-gamekit-achievements) 67 | add_subdirectory(aws-gamekit-authentication) 68 | add_subdirectory(aws-gamekit-user-gameplay-data) 69 | add_subdirectory(aws-gamekit-game-saving) 70 | 71 | if (DEFINED GTEST_SRC) 72 | add_subdirectory(tests) 73 | endif() 74 | 75 | add_subdirectory(publish) 76 | -------------------------------------------------------------------------------- /tests/core/test_stack.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // GameKit 7 | #include "test_stack.h" 8 | #include 9 | 10 | // AWS C++ SDK 11 | #include 12 | #include 13 | 14 | void TestStackInitializer::Initialize() 15 | { 16 | // Make the default mock client return 418 MakeRequest(), without this the response would be an 17 | // invalid object, causing tests to crash. 18 | // With this change, tests that don't set an explicit mock would fail. 19 | // Tests using http client should create their own mock and add expected requests and responses. 20 | std::shared_ptr fakeClient = std::make_shared(); 21 | 22 | // We don't need to verify that the expectation when the object is destructed, it is only 23 | // meant to prevent outgoing requests. 24 | Initialize(fakeClient); 25 | } 26 | 27 | void TestStackInitializer::Initialize(std::shared_ptr mock) 28 | { 29 | // Verify test is running on a clean state. If the AwsApiInitializer is already in an 30 | // Initialized state verify that previous tests released all their GameKit handles 31 | EXPECT_FALSE(GameKit::AwsApiInitializer::IsInitialized()) 32 | << "GameKit::AwsApiInitializer must not be in Initialized state before a test starts."; 33 | 34 | testMockFactory = std::make_shared(); 35 | testFakeClient = mock; 36 | testMockFactory->SetClient(testFakeClient); 37 | 38 | Aws::Http::SetHttpClientFactory(testMockFactory); 39 | Aws::Http::InitHttp(); 40 | Aws::Utils::Crypto::InitCrypto(); 41 | } 42 | 43 | void TestStackInitializer::Cleanup() 44 | { 45 | Aws::Http::CleanupHttp(); 46 | Aws::Utils::Crypto::CleanupCrypto(); 47 | testFakeClient.reset(); 48 | testMockFactory.reset(); 49 | 50 | if (!TestExecutionSettings::Settings.InitialFileCount.empty()) 51 | { 52 | std::map fileCountPerDir = TestFileSystemUtils::CountFilesInDirectories(TestExecutionSettings::Settings.DirectoriesToWatch); 53 | 54 | for (const std::string& dir : TestExecutionSettings::Settings.DirectoriesToWatch) 55 | { 56 | EXPECT_EQ(TestExecutionSettings::Settings.InitialFileCount[dir], fileCountPerDir[dir]) << 57 | "Test directory " << dir << " contains test artifacts! Make sure that all tests revert their changes to the filesystem."; 58 | } 59 | } 60 | } 61 | 62 | std::shared_ptr TestStackInitializer::GetMockHttpClientFactory() const 63 | { 64 | return testMockFactory; 65 | } -------------------------------------------------------------------------------- /scripts/IOS/regenerate_projects_ios.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | if [[ $# -eq 0 ]] ; then 6 | echo 'USAGE: ./regenerate_projects_ios.sh ' 7 | echo 'Example: ./regenerate_projects_ios.sh ~/development/AWSSDK_ios ~/development/boost_1_76_0 ~/development/yaml-cpp ~/development/Build-OpenSSL-cURL . Debug' 8 | exit 1 9 | fi 10 | 11 | cmake -G "Xcode" -DCMAKE_BUILD_TYPE=$6 -DBUILD_SHARED_LIBS=OFF \ 12 | -Daws-c-http_DIR=$1/install/arm64/ios/$6/lib/aws-c-http/cmake \ 13 | -Daws-c-io_DIR=$1/install/arm64/ios/$6/lib/aws-c-io/cmake \ 14 | -Daws-c-common_DIR=$1/install/arm64/ios/$6/lib/aws-c-common/cmake \ 15 | -Daws-c-cal_DIR=$1/install/arm64/ios/$6/lib/aws-c-cal/cmake \ 16 | -Daws-c-compression_DIR=$1/install/arm64/ios/$6/lib/aws-c-compression/cmake \ 17 | -Daws-c-mqtt_DIR=$1/install/arm64/ios/$6/lib/aws-c-mqtt/cmake \ 18 | -Daws-c-auth_DIR=$1/install/arm64/ios/$6/lib/aws-c-auth/cmake \ 19 | -Daws-c-event-stream_DIR=$1/install/arm64/ios/$6/lib/aws-c-event-stream/cmake \ 20 | -Daws-checksums_DIR=$1/install/arm64/ios/$6/lib/aws-checksums/cmake \ 21 | -Daws-c-s3_DIR=$1/install/arm64/ios/$6/lib/aws-c-s3/cmake \ 22 | -DAWSSDK_DIR=$1/install/arm64/ios/$6/lib/cmake/AWSSDK \ 23 | -Daws-cpp-sdk-core_DIR=$1/install/arm64/ios/$6/lib/cmake/aws-cpp-sdk-core \ 24 | -Daws-crt-cpp_DIR=$1/install/arm64/ios/$6/lib/aws-crt-cpp/cmake \ 25 | -Daws-cpp-sdk-cloudformation_DIR=$1/install/arm64/ios/$6/lib/cmake/aws-cpp-sdk-cloudformation \ 26 | -Daws-cpp-sdk-cognito-idp_DIR=$1/install/arm64/ios/$6/lib/cmake/aws-cpp-sdk-cognito-idp \ 27 | -Daws-cpp-sdk-sts_DIR=$1/install/arm64/ios/$6/lib/cmake/aws-cpp-sdk-sts \ 28 | -Daws-cpp-sdk-secretsmanager_DIR=$1/install/arm64/ios/$6/lib/cmake/aws-cpp-sdk-secretsmanager \ 29 | -Daws-cpp-sdk-ssm_DIR=$1/install/arm64/ios/$6/lib/cmake/aws-cpp-sdk-ssm \ 30 | -Daws-cpp-sdk-s3_DIR=$1/install/arm64/ios/$6/lib/cmake/aws-cpp-sdk-s3 \ 31 | -Daws-cpp-sdk-lambda_DIR=$1/install/arm64/ios/$6/lib/cmake/aws-cpp-sdk-lambda \ 32 | -Daws-cpp-sdk-apigateway_DIR=$1/install/arm64/ios/$6/lib/cmake/aws-cpp-sdk-apigateway \ 33 | -Daws-c-sdkutils_DIR=$1/install/arm64/ios/$6/lib/aws-c-sdkutils/cmake -DBOOST_ROOT=$2 \ 34 | -DBOOST_LIBRARYDIR=$2/stage/lib -Dyaml-cpp_DIR=$3/build_ios/install/arm64/$6/share/cmake/yaml-cpp \ 35 | -DCURL_INCLUDE_DIR=$4/curl/include -DOPENSSL_INCLUDE_DIR=$4/openssl/IOS/include \ 36 | -DNGHTTP2_INCLUDE_DIR=$4/nghttp2/iOS/arm64/include -DCMAKE_XCODE_ATTRIBUTE_ARCHS="arm64" \ 37 | -DCMAKE_INSTALL_PREFIX=$5/build_ios/install/arm64/$6 -DCMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET=14.0 \ 38 | -DCMAKE_XCODE_ATTRIBUTE_SDK_NAME=iOS -DCMAKE_XCODE_ATTRIBUTE_SDKROOT=iphoneos \ 39 | -DENABLE_CUSTOM_HTTP_CLIENT_FACTORY=ON -DENABLE_CURL_CLIENT=ON -DENABLE_CURL_LOGGING=OFF \ 40 | $5 41 | -------------------------------------------------------------------------------- /tests/core/ticker_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // GameKit 5 | #include "test_log.h" 6 | #include "ticker_tests.h" 7 | 8 | using namespace GameKit::Tests::Utils; 9 | 10 | #pragma region Base Class Tests 11 | void GameKitUtilsTickerTestFixture::Test_Ticker_ExecuteCallback_Success() 12 | { 13 | // arrange 14 | std::unique_ptr t = CreateTicker(1, std::bind(&GameKitUtilsTickerTestFixture::MockTickCallback1, this), TestLogger::Log); 15 | 16 | // act 17 | // the Ticker will execute every second for 4 seconds. At each tick, it will add an item 18 | // to the std::vector "callBacks". All ticks will be executed, Stop() will wait for thread completion. 19 | t->Start(); 20 | std::this_thread::sleep_for(std::chrono::seconds(4)); 21 | t->Stop(); 22 | 23 | // assert 24 | ASSERT_EQ(4, GetCallbacks1().size()); 25 | } 26 | 27 | void GameKitUtilsTickerTestFixture::Test_Ticker_Abort_Success() 28 | { 29 | // arrange 30 | std::unique_ptr t = CreateTicker(1, std::bind(&GameKitUtilsTickerTestFixture::MockTickCallbackAbort, this), TestLogger::Log); 31 | m_ticker = t.get(); 32 | 33 | // act 34 | t->Start(); 35 | std::this_thread::sleep_for(std::chrono::seconds(2)); 36 | t->Stop(); 37 | 38 | // assert 39 | ASSERT_EQ(1, GetCallbacks1().size()); 40 | } 41 | 42 | void GameKitUtilsTickerTestFixture::Test_SharedTicker_ThreadStopsAfterTickerDestroyed() 43 | { 44 | // arrange 45 | std::shared_ptr sharedTicker = MakeSharedTicker("ticker", 46 | 1, std::bind(&GameKitUtilsTickerTestFixture::MockTickCallback1, this), TestLogger::Log); 47 | 48 | // act 49 | sharedTicker->Start(); 50 | std::this_thread::sleep_for(std::chrono::seconds(2)); 51 | sharedTicker->Stop(); 52 | 53 | sharedTicker.reset(CreateTicker(1, std::bind(&GameKitUtilsTickerTestFixture::MockTickCallback2, this), TestLogger::Log).release()); 54 | sharedTicker->Start(); 55 | std::this_thread::sleep_for(std::chrono::seconds(3)); 56 | sharedTicker->Stop(); 57 | 58 | // assert 59 | ASSERT_EQ(2, GetCallbacks1().size()); 60 | ASSERT_EQ(3, GetCallbacks2().size()); 61 | } 62 | 63 | void GameKitUtilsTickerTestFixture::Test_Ticker_StartCalledTwice_NewThreadNotStarted() 64 | { 65 | // arrange 66 | std::unique_ptr t = CreateTicker(1, std::bind(&GameKitUtilsTickerTestFixture::MockTickCallback1, this), TestLogger::Log); 67 | 68 | // act 69 | t->Start(); 70 | std::this_thread::sleep_for(std::chrono::seconds(2)); 71 | t->Start(); 72 | std::this_thread::sleep_for(std::chrono::seconds(3)); 73 | t->Stop(); 74 | 75 | // assert 76 | ASSERT_EQ(5, GetCallbacks1().size()); 77 | } 78 | #pragma endregion 79 | -------------------------------------------------------------------------------- /aws-gamekit-core/include/aws/gamekit/core/model/resource_environment.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // Standard Library 7 | #include 8 | #include 9 | 10 | // GameKit 11 | #include 12 | 13 | namespace GameKit 14 | { 15 | struct ResourceEnvironment 16 | { 17 | private: 18 | EnvironmentType environmentType; 19 | std::string environmentCode; 20 | public: 21 | ResourceEnvironment() { 22 | environmentType = EnvironmentType::Development; 23 | } 24 | 25 | // Do not use EnvironmentType::Custom in this constructor. 26 | // It will be defaulted to EnvironmentType::Development if you do. 27 | inline ResourceEnvironment(EnvironmentType env) 28 | { 29 | this->environmentType = env; 30 | switch (env) 31 | { 32 | case EnvironmentType::Development: this->environmentCode = "dev"; 33 | case EnvironmentType::QA: this->environmentCode = "qa"; 34 | case EnvironmentType::Staging: this->environmentCode = "stg"; 35 | case EnvironmentType::Production: this->environmentCode = "prd"; 36 | default: 37 | this->environmentType = EnvironmentType::Development; 38 | this->environmentCode = "dev"; 39 | } 40 | } 41 | 42 | inline ResourceEnvironment(const std::string& envCode) 43 | { 44 | if (!std::regex_match(envCode, std::regex("[a-z0-9]{2,3}"))) 45 | { 46 | this->environmentCode = "dev"; 47 | this->environmentType = EnvironmentType::Development; 48 | return; 49 | } 50 | 51 | this->environmentCode = envCode; 52 | if (envCode == "dev") 53 | { 54 | this->environmentType = EnvironmentType::Development; 55 | } 56 | else if (envCode == "qa") 57 | { 58 | this->environmentType = EnvironmentType::QA; 59 | } 60 | else if (envCode == "stg") 61 | { 62 | this->environmentType = EnvironmentType::Staging; 63 | } 64 | else if (envCode == "prod") 65 | { 66 | this->environmentType = EnvironmentType::Production; 67 | } 68 | else 69 | { 70 | this->environmentType = EnvironmentType::Custom; 71 | } 72 | } 73 | 74 | inline EnvironmentType GetEnvironmentType() 75 | { 76 | return this->environmentType; 77 | } 78 | 79 | inline std::string GetEnvironmentString() const 80 | { 81 | return this->environmentCode; 82 | } 83 | }; 84 | } 85 | -------------------------------------------------------------------------------- /tests/authentication/gamekit_session_manager_tests.cpp: -------------------------------------------------------------------------------- 1 | #include "gamekit_session_manager_tests.h" 2 | #include "../core/mocks/mock_cognito_client.h" 3 | #include "../core/test_stack.h" 4 | #include "../core/test_log.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #define CLIENT_CONFIG_FILE "../core/test_data/sampleplugin/instance/testgame/dev/awsGameKitClientConfig.yml" 11 | 12 | class GameKit::Tests::GameKitSessionManager::GameKitSessionManagerTestFixture : public ::testing::Test 13 | { 14 | protected: 15 | TestStackInitializer testStackInitializer; 16 | typedef TestLog TestLogger; 17 | 18 | public: 19 | GameKitSessionManagerTestFixture() 20 | {} 21 | 22 | ~GameKitSessionManagerTestFixture() 23 | {} 24 | 25 | void SetUp() 26 | { 27 | testStackInitializer.Initialize(); 28 | 29 | gamekitSessionManagerInstance = Aws::MakeUnique("sessionManager", CLIENT_CONFIG_FILE, TestLogger::Log); 30 | } 31 | 32 | void TearDown() 33 | { 34 | gamekitSessionManagerInstance.reset(); 35 | testStackInitializer.CleanupAndLog(); 36 | TestExecutionUtils::AbortOnFailureIfEnabled(); 37 | } 38 | }; 39 | 40 | using namespace GameKit::Tests::GameKitSessionManager; 41 | using namespace Aws::CognitoIdentityProvider::Model; 42 | using namespace testing; 43 | TEST_F(GameKitSessionManagerTestFixture, KeyDoesNotExist_TestAddKey_Success) 44 | { 45 | // act 46 | gamekitSessionManagerInstance->SetToken(GameKit::TokenType::AccessToken, "abc"); 47 | auto token = gamekitSessionManagerInstance->GetToken(GameKit::TokenType::AccessToken); 48 | 49 | // assert 50 | ASSERT_EQ("abc", token); 51 | } 52 | 53 | TEST_F(GameKitSessionManagerTestFixture, KeyExists_TestAddKey_Success) 54 | { 55 | // act 56 | gamekitSessionManagerInstance->SetToken(GameKit::TokenType::AccessToken, "abc"); 57 | gamekitSessionManagerInstance->SetToken(GameKit::TokenType::AccessToken, "xyz"); 58 | 59 | auto token = gamekitSessionManagerInstance->GetToken(GameKit::TokenType::AccessToken); 60 | 61 | // assert 62 | ASSERT_EQ("xyz", token); 63 | } 64 | 65 | TEST_F(GameKitSessionManagerTestFixture, No_RefreshToken_Abort_Success) 66 | { 67 | // arrange 68 | gamekitSessionManagerInstance->SetToken(GameKit::TokenType::RefreshToken, ""); 69 | auto cognitoMock = Aws::MakeShared("cognitoMock"); 70 | gamekitSessionManagerInstance->SetCognitoClient(cognitoMock.get()); 71 | 72 | EXPECT_CALL(*cognitoMock.get(), InitiateAuth(_)) 73 | .Times(0); 74 | 75 | // act 76 | gamekitSessionManagerInstance->SetSessionExpiration(1); 77 | std::this_thread::sleep_for(std::chrono::milliseconds(1100)); 78 | 79 | ASSERT_TRUE(Mock::VerifyAndClearExpectations(cognitoMock.get())); 80 | } 81 | -------------------------------------------------------------------------------- /tests/core/simple_integration_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "custom_test_flags.h" 5 | #include "simple_integration_test.h" 6 | 7 | class GameKit::Tests::SimpleIntegration::SimpleIntegrationTestFixture : public ::testing::Test 8 | { 9 | protected: 10 | Aws::UniquePtr gamekitAccountInstance = nullptr; 11 | 12 | public: 13 | SimpleIntegrationTestFixture() 14 | {} 15 | 16 | ~SimpleIntegrationTestFixture() 17 | {} 18 | 19 | void SetUp() 20 | { 21 | // TODO:: Replace with real credentials when running integration test on build machine. 22 | // Read it from config. 23 | gamekitAccountInstance = Aws::MakeUnique( 24 | "gamekitAccountInstance", 25 | GameKit::AccountInfo{ "dev", "123456789012", "TestCompany", "testgame" }, 26 | GameKit::AccountCredentials{ "us-west-2", "AKIA4...", "naRg8..." }, 27 | nullptr); 28 | 29 | gamekitAccountInstance->InitializeDefaultAwsClients(); 30 | } 31 | 32 | void TearDown() 33 | { 34 | gamekitAccountInstance.reset(); 35 | TestExecutionUtils::AbortOnFailureIfEnabled(); 36 | } 37 | }; 38 | 39 | using namespace GameKit::Tests::SimpleIntegration; 40 | TEST_F(SimpleIntegrationTestFixture, DISABLED_SimpleIntegrationTest) 41 | { 42 | gamekitAccountInstance->SetPluginRoot("../core/test_data/sampleplugin/base"); 43 | gamekitAccountInstance->SetGameKitRoot("../core/test_data/sampleplugin/instance"); 44 | 45 | auto result = gamekitAccountInstance->HasValidCredentials(); 46 | ASSERT_TRUE(result) << "Failed credentials check."; 47 | 48 | result = gamekitAccountInstance->Bootstrap(); 49 | ASSERT_EQ(GameKit::GAMEKIT_SUCCESS, result) << "Failed bootstrapped account."; 50 | 51 | result = gamekitAccountInstance->SaveSecret("facebook_client_secret", "abcdefghijklmnopqrstuvwxyz"); 52 | ASSERT_EQ(GameKit::GAMEKIT_SUCCESS, result) << "Failed to save secret to Secrets Manager."; 53 | 54 | result = gamekitAccountInstance->SaveFeatureInstanceTemplates(); 55 | ASSERT_EQ(GameKit::GAMEKIT_SUCCESS, result) << "Failed to save Instance CloudFormation templates and Lambda Functions"; 56 | 57 | result = gamekitAccountInstance->UploadFunctions(); 58 | ASSERT_EQ(GameKit::GAMEKIT_SUCCESS, result) << "Failed to upload Lambda Functions to S3 bootstrap bucket"; 59 | 60 | result = gamekitAccountInstance->CreateOrUpdateMainStack(); 61 | ASSERT_EQ(GameKit::GAMEKIT_SUCCESS, result) << "Failed to create/update Main Stack"; 62 | 63 | result = gamekitAccountInstance->CreateOrUpdateFeatureStacks(); 64 | ASSERT_EQ(GameKit::GAMEKIT_SUCCESS, result) << "Failed to create/update Feature Stacks"; 65 | 66 | result = gamekitAccountInstance->DeployApiGatewayStage(); 67 | ASSERT_EQ(GameKit::GAMEKIT_SUCCESS, result) << "Failed to deploy latest API Gateway changes"; 68 | } 69 | -------------------------------------------------------------------------------- /aws-gamekit-core/source/aws/gamekit/core/utils/validation_utils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include 5 | 6 | using namespace GameKit::Utils; 7 | 8 | #pragma region Public Methods 9 | std::string ValidationUtils::UrlEncode(const std::string& urlParameter) { 10 | std::ostringstream escaped; 11 | escaped.fill('0'); 12 | escaped << std::hex; 13 | 14 | for (std::string::const_iterator i = urlParameter.begin(), n = urlParameter.end(); i != n; ++i) { 15 | std::string::value_type c = (*i); 16 | 17 | // Keep alphanumeric and other accepted characters intact 18 | if (isalnum((unsigned char) c) || c == '-' || c == '_' || c == '.' || c == '~') { 19 | escaped << c; 20 | continue; 21 | } 22 | 23 | // Any other characters are percent-encoded 24 | escaped << std::uppercase; 25 | escaped << '%' << std::setw(2) << int((unsigned char)c); 26 | escaped << std::nouppercase; 27 | } 28 | 29 | return escaped.str(); 30 | } 31 | 32 | std::string ValidationUtils::TruncateString(const std::string& str, const std::regex& pattern) 33 | { 34 | auto rbegin = std::sregex_iterator(str.begin(), str.end(), pattern); 35 | auto rend = std::sregex_iterator(); 36 | std::string matchStr; 37 | for (std::sregex_iterator i = rbegin; i != rend; ++i) 38 | { 39 | std::smatch match = *i; 40 | matchStr = match.str(); 41 | } 42 | 43 | return matchStr; 44 | } 45 | 46 | std::string ValidationUtils::TruncateAndLower(const std::string& str, const std::regex& pattern) 47 | { 48 | return boost::algorithm::to_lower_copy(ValidationUtils::TruncateString(str, pattern)); 49 | } 50 | 51 | bool ValidationUtils::IsValidString(const std::string& str, const std::regex& pattern) 52 | { 53 | return std::regex_match(str, pattern); 54 | } 55 | 56 | bool ValidationUtils::IsValidUrlParam(const std::string& urlParam) 57 | { 58 | if (urlParam.length() < MIN_URL_PARAM_CHARS || urlParam.length() > MAX_URL_PARAM_CHARS) 59 | { 60 | return false; 61 | } 62 | return ValidationUtils::IsValidString(urlParam, std::regex("[a-zA-Z0-9-_.~]+")); 63 | } 64 | 65 | bool ValidationUtils::IsValidS3KeyParam(const std::string& s3KeyParam) 66 | { 67 | if (s3KeyParam.length() < MIN_S3_PARAM_CHARS || s3KeyParam.length() > MAX_S3_PARAM_CHARS) 68 | { 69 | return false; 70 | } 71 | return ValidationUtils::IsValidString(s3KeyParam, std::regex("[a-zA-Z0-9-_.*'()]+")); 72 | } 73 | 74 | bool ValidationUtils::IsValidPrimaryIdentifier(const std::string& identifier) 75 | { 76 | if (identifier.length() < MIN_PRIMARY_IDENTIFIER_CHARS || identifier.length() > MAX_PRIMARY_IDENTIFIER_CHARS) 77 | { 78 | return false; 79 | } 80 | 81 | return ValidationUtils::IsValidString(identifier, std::regex(PRIMARY_IDENTIFIER_REGEX)); 82 | } 83 | 84 | #pragma endregion 85 | -------------------------------------------------------------------------------- /scripts/Android/build.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import argparse 5 | from http.server import executable 6 | import logging 7 | import os 8 | import pathlib 9 | import shutil 10 | 11 | import sys 12 | # add parent directory with common methods to python module search path 13 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 14 | from common import run_and_log, set_env_path 15 | 16 | logging.basicConfig(level=logging.INFO) 17 | 18 | def add_subparser(parser): 19 | parser.add_argument('--shared', default=False, action='store_true', help="Build as shared library (for Unity on Android)") 20 | parser.add_argument('--no-shared', dest='shared', action='store_false', help="Build as static library (for Unreal on Android)") 21 | 22 | def build(args): 23 | # configure dependency paths 24 | aws_sdk = set_env_path("GAMEKIT_ANDROID_AWSSDK_PATH", 25 | "Path to AWSSDK compiled for android (ex: D:\development\AWSSDK_android): ") 26 | boost = set_env_path("GAMEKIT_ANDROID_BOOST_PATH", 27 | "Path to Boost compiled for android (ex: D:\development\\boost_1_76_0_android): ") 28 | yaml_cpp = set_env_path("GAMEKIT_ANDROID_YAMLCPP_PATH", 29 | "Path to yaml-cpp compiled for android (ex: D:\development\yaml-cpp\\build_android): ") 30 | gtest = set_env_path("GAMEKIT_ANDROID_GTEST_PATH", "Path to googletest (ex: D:\development\googletest\\build): ") 31 | 32 | # make sure we're in the root of the repository 33 | script_path = pathlib.Path(__file__).absolute() 34 | repository_root = script_path.parents[2] 35 | scripts = repository_root / "scripts" / "Android" 36 | os.chdir(repository_root) 37 | 38 | build_dir = repository_root / "build_android" 39 | shutil.rmtree(build_dir, ignore_errors=True) 40 | build_dir.mkdir() 41 | 42 | os.chdir(build_dir) 43 | cache_file = repository_root / "CMakeCache.txt" 44 | if cache_file.exists(): 45 | os.remove(repository_root / "CMakeCache.txt") 46 | 47 | dependencies = [aws_sdk, boost, yaml_cpp, gtest] 48 | shared_build = 'ON' if args.shared else 'OFF' 49 | stl_type = 'c++_shared' if args.shared else 'c++_static' 50 | regenerate_project = [str(scripts / "regenerate_android_projects.bat")] + dependencies + [str(repository_root), 51 | args.type] + [shared_build] + [stl_type] 52 | cmake_build = ["cmake", "--build", ".", "--target", "install"] 53 | run_and_log(regenerate_project) 54 | run_and_log(cmake_build) 55 | 56 | if __name__ == "__main__": 57 | parser = argparse.ArgumentParser(description="Builds Android binaries for AWS GameKit Cpp.") 58 | parser.add_argument("type", choices=["Debug", "Release"], help="Compile type for GKCpp, Debug or Release.") 59 | parser.add_argument('--shared', action=argparse.BooleanOptionalAction, help="Build as shared library (for Unity on Android)") 60 | args = parser.parse_args() 61 | 62 | build(args) 63 | -------------------------------------------------------------------------------- /scripts/Android/refresh_unity.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import argparse 5 | from fnmatch import fnmatch 6 | import logging 7 | import os 8 | import pathlib 9 | import re 10 | 11 | import sys 12 | # add parent directory with common methods to python module search path 13 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 14 | from common import copy_libs, REPOSITORY_ROOT 15 | 16 | REQUIRED_ANDROID_LIBS = [ 17 | r"libaws-cpp-sdk-apigateway\.so", 18 | r"libaws-cpp-sdk-cloudformation\.so", 19 | r"libaws-cpp-sdk-cognito-idp\.so", 20 | r"libaws-cpp-sdk-core\.so", 21 | r"libaws-cpp-sdk-lambda\.so", 22 | r"libaws-cpp-sdk-s3\.so", 23 | r"libaws-cpp-sdk-secretsmanager\.so", 24 | r"libaws-cpp-sdk-ssm\.so", 25 | r"libaws-cpp-sdk-sts\.so", 26 | r"libaws-gamekit-achievements\.so", 27 | r"libaws-gamekit-authentication\.so", 28 | r"libaws-gamekit-core\.so", 29 | r"libaws-gamekit-game-saving\.so", 30 | r"libaws-gamekit-identity\.so", 31 | r"libaws-gamekit-user-gameplay-data\.so", 32 | r"libboost_filesystem.*\.so", 33 | r"libboost_iostreams.*\.so", 34 | r"libboost_regex.*\.so", 35 | r"libc\+\+_shared\.so", 36 | r"libyaml-cpp\.so" 37 | ] 38 | 39 | def refresh(type, plugin_path): 40 | # Unity only supports targeting one set of binaries, so refreshing with a different BuildType 41 | # will overwrite older BuildType binaries in the plugin. 42 | destination = pathlib.Path(plugin_path) / "Plugins" / "Android" / "libs" / "armeabi-v7a" 43 | bin = pathlib.Path(REPOSITORY_ROOT, "install", type, "bin") 44 | libs = pathlib.Path(REPOSITORY_ROOT, "install", type, "lib") 45 | 46 | copy_libs(".so", destination, binary_dir=bin) 47 | copy_libs(".so", destination, binary_dir=libs) 48 | 49 | 50 | missing_libs = find_missing_libs(os.listdir(destination), ".so") 51 | 52 | if len(missing_libs) > 0: 53 | logging.warn("""\nMISSING libraries: [ {missing_libs} ], \n 54 | try calling the build script with the '--shared' option or the refresh script with '--build'. \n\n""".format(missing_libs=", ".join(missing_libs))) 55 | 56 | def find_missing_libs(present_libs, extension): 57 | present_libs = [ file for file in present_libs if file.endswith(extension)] 58 | present_libs_string = " ".join(present_libs) 59 | missing_libs = [] 60 | for lib_name in REQUIRED_ANDROID_LIBS: 61 | if re.search(lib_name, present_libs_string) == None: 62 | missing_libs.append(lib_name.replace('\\', '')) 63 | return missing_libs 64 | 65 | 66 | if __name__ == '__main__': 67 | parser = argparse.ArgumentParser(description="Copies library files over to the target plugin.") 68 | parser.add_argument("type", choices=["Debug", "Release"], help="Compile type for libs being copied over.") 69 | parser.add_argument("--unity_plugin_path", required=True, help="Path to AWS GameKit Plugin for Unity e.g. [unity_package]/Packages/com.amazonaws.gamekit") 70 | args = parser.parse_args() 71 | 72 | refresh(args.type, args.unity_plugin_path) -------------------------------------------------------------------------------- /scripts/IOS/refresh_unity.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import argparse 5 | import os 6 | import pathlib 7 | 8 | import sys 9 | # add parent directory with common methods to python module search path 10 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 11 | from common import set_env_path, copy_libs, copy_file, REPOSITORY_ROOT, FEATURES, code_sign 12 | 13 | def refresh(type, plugin_path, certificate_name=None): 14 | destination = pathlib.Path(plugin_path).expanduser() / "Plugins" / "IOS" 15 | 16 | aws_sdk = set_env_path("GAMEKIT_AWSSDK_PATH_ios", "Path to AWSSDK (ex: ~/development/AWSSDK_ios): ") 17 | boost = set_env_path("GAMEKIT_BOOST_PATH_ios", "Path to Boost (ex: ~/development/ios-boost): ") 18 | yaml_cpp = set_env_path("GAMEKIT_YAMLCPP_PATH_ios", "Path to yaml-cpp (ex: ~/development/yaml-cpp): ") 19 | curl = set_env_path("GAMEKIT_CURL_PATH_ios", "Path to curl (ex: ~/development/Build-OpenSSL-cURL): ") 20 | 21 | copy_libs(".a", destination, binary_dir=pathlib.Path(aws_sdk, "install", "arm64", "ios", type, "lib")) 22 | copy_libs(".a", destination / "boost", binary_dir=pathlib.Path(boost, "build", "boost", "1.76.0", "ios", "release", "build", "iphoneos", "arm64")) 23 | 24 | copy_file(pathlib.Path(yaml_cpp, "build_ios", "install", "arm64", type, "lib", "libyaml-cppd.a"), destination / "yaml-cpp") 25 | copy_file(pathlib.Path(curl, "nghttp2", "iOS", "arm64", "lib", "libnghttp2.a"), destination / "nghttp2") 26 | copy_file(pathlib.Path(curl, "curl", "lib", "libcurl_iOS.a"), destination / "curl") 27 | copy_file(pathlib.Path(curl, "openssl", "iOS", "lib", "libssl.a"), destination / "openssl") 28 | copy_file(pathlib.Path(curl, "openssl", "iOS", "lib", "libcrypto.a"), destination / "openssl") 29 | 30 | # Rename libcurl_ios to just libcurl since it is the only libcurl being used 31 | os.rename(str(pathlib.Path(destination, "curl", "libcurl_iOS.a")), str(pathlib.Path(destination, "curl", "libcurl.a"))) 32 | 33 | # Only curl and openssl libs need to be codesigned 34 | if certificate_name: 35 | code_sign(str(pathlib.Path(destination, "curl", "libcurl.a")), certificate_name) 36 | code_sign(str(destination / "openssl" / "libssl.a"), certificate_name) 37 | code_sign(str(destination / "openssl" / "libcrypto.a"), certificate_name) 38 | 39 | for f in FEATURES: 40 | copy_libs(".a", destination, binary_dir=pathlib.Path(REPOSITORY_ROOT, "build_ios", f"aws-gamekit-{f}", f"{type}-iphoneos")) 41 | 42 | if __name__ == '__main__': 43 | parser = argparse.ArgumentParser(description="Copies library files over to the target plugin.") 44 | parser.add_argument("type", choices=["Debug", "Release"], help="Compile type for libs being copied over.") 45 | parser.add_argument("--unity_plugin_path", required=True, help="Path to AWS GameKit Plugin for Unity e.g. [unity_package]/Packages/com.amazonaws.gamekit") 46 | parser.add_argument("--certificate_name", help="Apple Developer ID Application certificate for code signing.") 47 | args = parser.parse_args() 48 | 49 | refresh(args.type, args.unity_plugin_path, args.certificate_name) -------------------------------------------------------------------------------- /scripts/IOS/refresh_unreal.py: -------------------------------------------------------------------------------- 1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | import argparse 5 | import os 6 | import pathlib 7 | 8 | import sys 9 | # add parent directory with common methods to python module search path 10 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 11 | from common import set_env_path, copy_libs, copy_file, REPOSITORY_ROOT, FEATURES, code_sign 12 | 13 | def refresh(type, plugin_path, certificate_name=None): 14 | destination = pathlib.Path(plugin_path).expanduser() / "Libraries" / "IOS" / type 15 | 16 | aws_sdk = set_env_path("GAMEKIT_AWSSDK_PATH_ios", "Path to AWSSDK (ex: ~/development/AWSSDK_ios): ") 17 | boost = set_env_path("GAMEKIT_BOOST_PATH_ios", "Path to Boost (ex: ~/development/ios-boost): ") 18 | yaml_cpp = set_env_path("GAMEKIT_YAMLCPP_PATH_ios", "Path to yaml-cpp (ex: ~/development/yaml-cpp): ") 19 | curl = set_env_path("GAMEKIT_CURL_PATH_ios", "Path to curl (ex: ~/development/Build-OpenSSL-cURL): ") 20 | 21 | copy_libs(".a", destination, binary_dir=pathlib.Path(aws_sdk, "install", "arm64", "ios", type, "lib")) 22 | copy_libs(".a", destination / "boost", binary_dir=pathlib.Path(boost, "build", "boost", "1.76.0", "ios", "release", "build", "iphoneos", "arm64")) 23 | 24 | copy_file(pathlib.Path(yaml_cpp, "build_ios", "install", "arm64", type, "lib", "libyaml-cppd.a"), destination / "yaml-cpp") 25 | copy_file(pathlib.Path(curl, "nghttp2", "iOS", "arm64", "lib", "libnghttp2.a"), destination / "nghttp2") 26 | copy_file(pathlib.Path(curl, "curl", "lib", "libcurl_iOS.a"), destination / "curl") 27 | copy_file(pathlib.Path(curl, "openssl", "iOS", "lib", "libssl.a"), destination / "openssl") 28 | copy_file(pathlib.Path(curl, "openssl", "iOS", "lib", "libcrypto.a"), destination / "openssl") 29 | 30 | # Rename libcurl_ios to just libcurl since it is the only libcurl being used 31 | os.rename(str(pathlib.Path(destination, "curl", "libcurl_iOS.a")), str(pathlib.Path(destination, "curl", "libcurl.a"))) 32 | 33 | # Only curl and openssl libs need to be codesigned 34 | if certificate_name: 35 | code_sign(str(pathlib.Path(destination, "curl", "libcurl.a")), certificate_name) 36 | code_sign(str(destination / "openssl" / "libssl.a"), certificate_name) 37 | code_sign(str(destination / "openssl" / "libcrypto.a"), certificate_name) 38 | 39 | for f in FEATURES: 40 | copy_libs(".a", destination, binary_dir=pathlib.Path(REPOSITORY_ROOT, "build_ios", f"aws-gamekit-{f}", f"{type}-iphoneos")) 41 | 42 | if __name__ == '__main__': 43 | parser = argparse.ArgumentParser(description="Copies library files over to the target plugin.") 44 | parser.add_argument("type", choices=["Debug", "Release"], help="Compile type for libs being copied over.") 45 | parser.add_argument("--unreal_plugin_path", required=True, help="Path to AWS GameKit Plugin for Unreal e.g. [unreal_project_path]/Plugins/AwsGameKit") 46 | parser.add_argument("--certificate_name", help="Apple Developer ID Application certificate for code signing.") 47 | args = parser.parse_args() 48 | 49 | refresh(args.type, args.unreal_plugin_path, args.certificate_name) -------------------------------------------------------------------------------- /aws-gamekit-game-saving/include/aws/gamekit/game-saving/gamekit_game_saving_caller.h: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | // AWS SDK 7 | #include 8 | 9 | // GameKit 10 | #include 11 | #include 12 | #include 13 | 14 | namespace GameKit 15 | { 16 | namespace GameSaving 17 | { 18 | static const Aws::String RESPONSE_BODY_KEY_META = "meta"; 19 | static const Aws::String RESPONSE_BODY_KEY_META_MESSAGE = "message"; 20 | 21 | enum class ResponseStatus { 22 | MALFORMED_SLOT_NAME, 23 | MAX_METADATA_BYTES_EXCEEDED, 24 | MALFORMED_HASH_SIZE_MISMATCH, 25 | MAX_CLOUD_SAVE_SLOTS_EXCEEDED, 26 | GENERIC_STATUS 27 | }; 28 | 29 | inline std::string GetResponseStatusString(ResponseStatus status) 30 | { 31 | switch (status) 32 | { 33 | case ResponseStatus::MALFORMED_SLOT_NAME: return "Malformed Slot Name"; 34 | case ResponseStatus::MAX_METADATA_BYTES_EXCEEDED: return "Max Metadata Bytes Exceeded"; 35 | case ResponseStatus::MALFORMED_HASH_SIZE_MISMATCH: return "Malformed Hash Size Mismatch"; 36 | case ResponseStatus::MAX_CLOUD_SAVE_SLOTS_EXCEEDED: return "Max Cloud Save Slots Exceeded"; 37 | case ResponseStatus::GENERIC_STATUS: return "Unexpected Error"; 38 | default: return "Unexpected Error"; 39 | } 40 | } 41 | 42 | inline ResponseStatus GetResponseStatusFromString(const std::string& status) 43 | { 44 | if (status == "Malformed Slot Name") return ResponseStatus::MALFORMED_SLOT_NAME; 45 | if (status == "Max Metadata Bytes Exceeded") return ResponseStatus::MAX_METADATA_BYTES_EXCEEDED; 46 | if (status == "Malformed Hash Size Mismatch") return ResponseStatus::MALFORMED_HASH_SIZE_MISMATCH; 47 | if (status == "Max Cloud Save Slots Exceeded") return ResponseStatus::MAX_CLOUD_SAVE_SLOTS_EXCEEDED; 48 | if (status == "Unexpected Error") return ResponseStatus::GENERIC_STATUS; 49 | 50 | return ResponseStatus::GENERIC_STATUS; 51 | } 52 | 53 | class Caller 54 | { 55 | private: 56 | Authentication::GameKitSessionManager* m_sessionManager = nullptr; 57 | FuncLogCallback m_logCb = nullptr; 58 | std::shared_ptr* m_httpClient = nullptr; 59 | 60 | public: 61 | typedef std::unordered_map CallerParams; 62 | typedef std::chrono::milliseconds MillisecondDelay; 63 | 64 | void Initialize(Authentication::GameKitSessionManager* sessionManager, FuncLogCallback logCb, std::shared_ptr* httpClientPointer); 65 | 66 | unsigned int CallApiGateway( 67 | const std::string& uri, 68 | Aws::Http::HttpMethod method, 69 | const std::string& currentFunctionName, 70 | Aws::Utils::Json::JsonValue& returnedJsonValue, 71 | const CallerParams& queryStringParams = CallerParams(), 72 | const CallerParams& headerParams = CallerParams()) const; 73 | }; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /aws-gamekit-achievements/source/aws/gamekit/achievements/exports.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Standard library 5 | #include 6 | #include 7 | 8 | // GameKit 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace GameKit::Logger; 17 | using namespace GameKit::Achievements; 18 | 19 | GAMEKIT_ACHIEVEMENTS_INSTANCE_HANDLE GameKitAchievementsInstanceCreateWithSessionManager(void* sessionManager, FuncLogCallback logCb) 20 | { 21 | Logging::Log(logCb, Level::Info, "GameDevAchievementsCreate"); 22 | GameKit::Authentication::GameKitSessionManager* sessMgr = (GameKit::Authentication::GameKitSessionManager*)sessionManager; 23 | Achievements* achievements = new Achievements(logCb, sessMgr); 24 | 25 | Aws::Client::ClientConfiguration clientConfig; 26 | GameKit::DefaultClients::SetDefaultClientConfiguration(sessMgr->GetClientSettings(), clientConfig); 27 | clientConfig.region = sessMgr->GetClientSettings()[GameKit::ClientSettings::Authentication::SETTINGS_IDENTITY_REGION].c_str(); 28 | 29 | return (GameKit::GameKitFeature*)achievements; 30 | } 31 | 32 | unsigned int GameKitListAchievements(GAMEKIT_ACHIEVEMENTS_INSTANCE_HANDLE achievementsInstance, unsigned int pageSize, bool waitForAllPages, const DISPATCH_RECEIVER_HANDLE dispatchReceiver, const CharPtrCallback responseCallback) 33 | { 34 | return ((Achievements*)((GameKit::GameKitFeature*)achievementsInstance))->ListAchievementsForPlayer(pageSize, waitForAllPages, dispatchReceiver, responseCallback); 35 | } 36 | 37 | unsigned int GameKitUpdateAchievement(GAMEKIT_ACHIEVEMENTS_INSTANCE_HANDLE achievementsInstance, const char* achievementIdentifier, unsigned int incrementBy, const DISPATCH_RECEIVER_HANDLE dispatchReceiver, const CharPtrCallback responseCallback) 38 | { 39 | return ((Achievements*)((GameKit::GameKitFeature*)achievementsInstance))->UpdateAchievementForPlayer(achievementIdentifier, incrementBy, dispatchReceiver, responseCallback); 40 | } 41 | 42 | unsigned int GameKitGetAchievement(GAMEKIT_ACHIEVEMENTS_INSTANCE_HANDLE achievementsInstance, const char* achievementIdentifier, 43 | const DISPATCH_RECEIVER_HANDLE dispatchReceiver, const CharPtrCallback responseCallback) 44 | { 45 | return ((Achievements*)((GameKit::GameKitFeature*)achievementsInstance))->GetAchievementForPlayer(achievementIdentifier, dispatchReceiver, responseCallback); 46 | } 47 | 48 | GAMEKIT_API unsigned int GameKitGetAchievementIconsBaseUrl(GAMEKIT_ACHIEVEMENTS_INSTANCE_HANDLE achievementsInstance, const DISPATCH_RECEIVER_HANDLE dispatchReceiver, const CharPtrCallback responseCallback) 49 | { 50 | auto url = ((Achievements*)((GameKit::GameKitFeature*)achievementsInstance))->GetSessionManager()->GetClientSettings()[GameKit::ClientSettings::Achievements::SETTINGS_ACHIEVEMENTS_ICONS_BASE_URL]; 51 | responseCallback(dispatchReceiver, url.append("/").c_str()); 52 | return GameKit::GAMEKIT_SUCCESS; 53 | } 54 | 55 | void GameKitAchievementsInstanceRelease(GAMEKIT_ACHIEVEMENTS_INSTANCE_HANDLE achievementsInstance) 56 | { 57 | delete((Achievements*)((GameKit::GameKitFeature*)achievementsInstance)); 58 | } 59 | -------------------------------------------------------------------------------- /aws-gamekit-game-saving/source/aws/gamekit/game-saving/exports.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // GameKit 5 | #include 6 | #include 7 | 8 | using namespace GameKit::Logger; 9 | using namespace GameKit::GameSaving; 10 | 11 | GAMEKIT_GAME_SAVING_INSTANCE_HANDLE GameKitGameSavingInstanceCreateWithSessionManager(void* sessionManager, FuncLogCallback logCb, const char* const* localSlotInformationFilePaths, 12 | unsigned int arraySize, FileActions fileActions) 13 | { 14 | Logging::Log(logCb, Level::Info, "GameDevGameSavingCreate"); 15 | 16 | auto const sessMgr = static_cast(sessionManager); 17 | auto const gameSaving = new GameSaving(sessMgr, logCb, localSlotInformationFilePaths, arraySize, fileActions); 18 | 19 | return gameSaving; 20 | } 21 | 22 | void GameKitAddLocalSlots(GAMEKIT_GAME_SAVING_INSTANCE_HANDLE gameSavingInstance, const char* const* localSlotInformationFilePaths, unsigned int arraySize) 23 | { 24 | return static_cast(gameSavingInstance)->AddLocalSlots(localSlotInformationFilePaths, arraySize); 25 | } 26 | 27 | void GameKitClearSyncedSlots(GAMEKIT_GAME_SAVING_INSTANCE_HANDLE gameSavingInstance) 28 | { 29 | static_cast(gameSavingInstance)->ClearSyncedSlots(); 30 | } 31 | 32 | void GameKitSetFileActions(GAMEKIT_GAME_SAVING_INSTANCE_HANDLE gameSavingInstance, FileActions fileActions) 33 | { 34 | return static_cast(gameSavingInstance)->SetFileActions(fileActions); 35 | } 36 | 37 | unsigned int GameKitGetAllSlotSyncStatuses( 38 | GAMEKIT_GAME_SAVING_INSTANCE_HANDLE gameSavingInstance, 39 | DISPATCH_RECEIVER_HANDLE receiver, 40 | GameSavingResponseCallback resultCb, 41 | bool waitForAllPages, 42 | unsigned int pageSize) 43 | { 44 | return static_cast(gameSavingInstance)->GetAllSlotSyncStatuses(receiver, resultCb, waitForAllPages, pageSize); 45 | } 46 | 47 | unsigned int GameKitGetSlotSyncStatus(GAMEKIT_GAME_SAVING_INSTANCE_HANDLE gameSavingInstance, DISPATCH_RECEIVER_HANDLE receiver, GameSavingSlotActionResponseCallback resultCb, const char* slotName) 48 | { 49 | return static_cast(gameSavingInstance)->GetSlotSyncStatus(receiver, resultCb, slotName); 50 | } 51 | 52 | unsigned int GameKitDeleteSlot(GAMEKIT_GAME_SAVING_INSTANCE_HANDLE gameSavingInstance, DISPATCH_RECEIVER_HANDLE receiver, GameSavingSlotActionResponseCallback resultCb, const char* slotName) 53 | { 54 | return static_cast(gameSavingInstance)->DeleteSlot(receiver, resultCb, slotName); 55 | } 56 | 57 | unsigned int GameKitSaveSlot(GAMEKIT_GAME_SAVING_INSTANCE_HANDLE gameSavingInstance, DISPATCH_RECEIVER_HANDLE receiver, GameSavingSlotActionResponseCallback resultCb, GameSavingModel model) 58 | { 59 | return static_cast(gameSavingInstance)->SaveSlot(receiver, resultCb, model); 60 | } 61 | 62 | unsigned int GameKitLoadSlot(GAMEKIT_GAME_SAVING_INSTANCE_HANDLE gameSavingInstance, DISPATCH_RECEIVER_HANDLE receiver, GameSavingDataResponseCallback resultCb, GameSavingModel model) 63 | { 64 | return static_cast(gameSavingInstance)->LoadSlot(receiver, resultCb, model); 65 | } 66 | 67 | void GameKitGameSavingInstanceRelease(GAMEKIT_GAME_SAVING_INSTANCE_HANDLE gameSavingInstance) 68 | { 69 | delete static_cast(gameSavingInstance); 70 | } 71 | -------------------------------------------------------------------------------- /tests/encoding_utils_tests.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "encoding_utils_tests.h" 5 | 6 | class GameKit::Tests::EncodingUtils::GameKitUtilsEncodingTestFixture : public ::testing::Test 7 | { 8 | public: 9 | GameKitUtilsEncodingTestFixture() 10 | { 11 | } 12 | 13 | ~GameKitUtilsEncodingTestFixture() 14 | { 15 | } 16 | 17 | void SetUp() 18 | { 19 | } 20 | 21 | void TearDown() 22 | { 23 | TestExecutionUtils::AbortOnFailureIfEnabled(); 24 | } 25 | }; 26 | 27 | using namespace GameKit::Tests::EncodingUtils; 28 | 29 | TEST_F(GameKitUtilsEncodingTestFixture, DecimalToBase_ValidDecimalToBase36_ReturnsValidBase36) 30 | { 31 | // arrange 32 | std::string inputStr = "097036240017"; 33 | 34 | // act 35 | const std::string result = GameKit::Utils::EncodingUtils::DecimalToBase(inputStr, GameKit::Utils::BASE_36); 36 | 37 | // assert 38 | ASSERT_STRCASEEQ("18ksvdzl", result.c_str()); 39 | } 40 | 41 | TEST_F(GameKitUtilsEncodingTestFixture, DecimalToBase_ValidDecimalToBase16_ReturnsValidBase16) 42 | { 43 | // arrange 44 | std::string inputStr = "097036240017"; 45 | 46 | // act 47 | const std::string result = GameKit::Utils::EncodingUtils::DecimalToBase(inputStr, GameKit::Utils::BASE_16); 48 | 49 | // assert 50 | ASSERT_STRCASEEQ("1697cf8491", result.c_str()); 51 | } 52 | 53 | TEST_F(GameKitUtilsEncodingTestFixture, DecimalToBase_ValidDecimalToBase2_ReturnsValidBase2) 54 | { 55 | // arrange 56 | std::string inputStr = "097036240017"; 57 | 58 | // act 59 | const std::string result = GameKit::Utils::EncodingUtils::DecimalToBase(inputStr, GameKit::Utils::BASE_2); 60 | 61 | // assert 62 | ASSERT_STRCASEEQ("1011010010111110011111000010010010001", result.c_str()); 63 | } 64 | 65 | TEST_F(GameKitUtilsEncodingTestFixture, DecimalToBase_ValidDecimalToBase0_ReturnsEmptyString) 66 | { 67 | // arrange 68 | std::string inputStr = "097036240017"; 69 | 70 | // act 71 | const std::string result = GameKit::Utils::EncodingUtils::DecimalToBase(inputStr,0); 72 | 73 | // assert 74 | ASSERT_STRCASEEQ("", result.c_str()); 75 | } 76 | 77 | TEST_F(GameKitUtilsEncodingTestFixture, DecimalToBase_ValidDecimalToBase1_ReturnsEmptyString) 78 | { 79 | // arrange 80 | std::string inputStr = "097036240017"; 81 | 82 | // act 83 | const std::string result = GameKit::Utils::EncodingUtils::DecimalToBase(inputStr, 1); 84 | 85 | // assert 86 | ASSERT_STRCASEEQ("", result.c_str()); 87 | } 88 | 89 | TEST_F(GameKitUtilsEncodingTestFixture, DecimalToBase_InvalidDecimalInputToBase36_ReturnsEmptyString) 90 | { 91 | // arrange 92 | std::string inputStr = "ASKJHkjhsd6^&"; 93 | 94 | // act 95 | const std::string result = GameKit::Utils::EncodingUtils::DecimalToBase(inputStr, GameKit::Utils::BASE_36); 96 | 97 | // assert 98 | ASSERT_STRCASEEQ("", result.c_str()); 99 | } 100 | 101 | TEST_F(GameKitUtilsEncodingTestFixture, DecimalToBase_NegativeDecimalInputToBase36_ReturnsEmptyString) 102 | { 103 | // arrange 104 | std::string inputStr = "-097036240017"; 105 | 106 | // act 107 | const std::string result = GameKit::Utils::EncodingUtils::DecimalToBase(inputStr, GameKit::Utils::BASE_36); 108 | 109 | // assert 110 | ASSERT_STRCASEEQ("", result.c_str()); 111 | } -------------------------------------------------------------------------------- /aws-gamekit-achievements/source/aws/gamekit/achievements/exports_admin.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | // Standard library 5 | #include 6 | #include 7 | 8 | // GameKit 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace GameKit::Logger; 17 | using namespace GameKit::Achievements; 18 | 19 | GAMEKIT_ADMIN_ACHIEVEMENTS_INSTANCE_HANDLE GameKitAdminAchievementsInstanceCreateWithSessionManager(void* sessionManager, const char* cloudResourcesPath, const GameKit::AccountCredentials accountCredentials, GameKit::AccountInfo accountInfo, FuncLogCallback logCb) 20 | { 21 | Logging::Log(logCb, Level::Info, "GameDevAdminAchievementsCreate"); 22 | GameKit::Authentication::GameKitSessionManager* sessMgr = (GameKit::Authentication::GameKitSessionManager*)sessionManager; 23 | AdminAchievements* achievements = new AdminAchievements(logCb, sessMgr, std::string(cloudResourcesPath), accountInfo, accountCredentials); 24 | 25 | Aws::Client::ClientConfiguration clientConfig; 26 | GameKit::DefaultClients::SetDefaultClientConfiguration(sessMgr->GetClientSettings(), clientConfig); 27 | clientConfig.region = sessMgr->GetClientSettings()[GameKit::ClientSettings::Authentication::SETTINGS_IDENTITY_REGION].c_str(); 28 | 29 | return (GameKit::GameKitFeature*)achievements; 30 | } 31 | 32 | unsigned int GameKitAdminListAchievements(GAMEKIT_ADMIN_ACHIEVEMENTS_INSTANCE_HANDLE achievementsInstance, unsigned int pageSize, bool waitForAllPages, const DISPATCH_RECEIVER_HANDLE dispatchReceiver, const CharPtrCallback responseCallback) 33 | { 34 | return ((AdminAchievements*)((GameKit::GameKitFeature*)achievementsInstance))->ListAchievements(pageSize, waitForAllPages, dispatchReceiver, responseCallback); 35 | } 36 | 37 | unsigned int GameKitAdminAddAchievements(GAMEKIT_ADMIN_ACHIEVEMENTS_INSTANCE_HANDLE achievementsInstance, const GameKit::Achievement* achievements, unsigned int batchSize) 38 | { 39 | return ((AdminAchievements*)((GameKit::GameKitFeature*)achievementsInstance))->AddAchievements(achievements, batchSize); 40 | } 41 | 42 | unsigned int GameKitAdminDeleteAchievements(GAMEKIT_ADMIN_ACHIEVEMENTS_INSTANCE_HANDLE achievementsInstance, const char* const* achievementIdentifiers, unsigned int batchSize) 43 | { 44 | return ((AdminAchievements*)((GameKit::GameKitFeature*)achievementsInstance))->DeleteAchievements(achievementIdentifiers, batchSize); 45 | } 46 | 47 | unsigned int GameKitAdminCredentialsChanged(GAMEKIT_ADMIN_ACHIEVEMENTS_INSTANCE_HANDLE achievementsInstance, const GameKit::AccountCredentials accountCredentials, const GameKit::AccountInfo accountInfo) 48 | { 49 | return ((AdminAchievements*)((GameKit::GameKitFeature*)achievementsInstance))->ChangeCredentials(accountCredentials, accountInfo); 50 | } 51 | 52 | bool GameKitIsAchievementIdValid(const char* achievementId) 53 | { 54 | // Valid ID is any combination of alphanumeric characters and underscores that doesn't begin or end with an underscore, length >= 2 55 | return std::regex_match(achievementId, std::regex("^[a-zA-Z0-9][a-zA-Z0-9_]*[a-zA-Z0-9]$")); 56 | } 57 | 58 | void GameKitAdminAchievementsInstanceRelease(GAMEKIT_ADMIN_ACHIEVEMENTS_INSTANCE_HANDLE achievementsInstance) 59 | { 60 | delete((AdminAchievements*)((GameKit::GameKitFeature*)achievementsInstance)); 61 | } 62 | --------------------------------------------------------------------------------