AWSResourceMappingUtilsTest.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <ResourceMapping/AWSResourceMappingUtils.h>
  9. #include <TestFramework/AWSCoreFixture.h>
  10. using namespace AWSCore;
  11. static constexpr const char TEST_VALID_RESTAPI_ID[] = "1234567890";
  12. static constexpr const char TEST_VALID_RESTAPI_REGION[] = "us-west-2";
  13. static constexpr const char TEST_VALID_RESTAPI_CHINA_REGION[] = "cn-north-1";
  14. static constexpr const char TEST_VALID_RESTAPI_STAGE[] = "prod";
  15. using AWSResourceMappingUtilsTest = AWSCoreFixture;
  16. TEST_F(AWSResourceMappingUtilsTest, FormatRESTApiUrl_PassingValidArguments_ReturnExpectedResult)
  17. {
  18. AZStd::string expectedUrl = AZStd::string::format("https://%s.execute-api.%s.amazonaws.com/%s",
  19. TEST_VALID_RESTAPI_ID, TEST_VALID_RESTAPI_REGION, TEST_VALID_RESTAPI_STAGE);
  20. auto actualUrl =
  21. AWSResourceMappingUtils::FormatRESTApiUrl(TEST_VALID_RESTAPI_ID, TEST_VALID_RESTAPI_REGION, TEST_VALID_RESTAPI_STAGE);
  22. EXPECT_TRUE(actualUrl == expectedUrl);
  23. }
  24. TEST_F(AWSResourceMappingUtilsTest, FormatRESTApiUrl_PassingValidChinaRegion_ReturnExpectedResult)
  25. {
  26. AZStd::string expectedUrl = AZStd::string::format("https://%s.execute-api.%s.amazonaws.com.cn/%s",
  27. TEST_VALID_RESTAPI_ID, TEST_VALID_RESTAPI_CHINA_REGION, TEST_VALID_RESTAPI_STAGE);
  28. auto actualUrl =
  29. AWSResourceMappingUtils::FormatRESTApiUrl(TEST_VALID_RESTAPI_ID, TEST_VALID_RESTAPI_CHINA_REGION, TEST_VALID_RESTAPI_STAGE);
  30. EXPECT_TRUE(actualUrl == expectedUrl);
  31. }
  32. TEST_F(AWSResourceMappingUtilsTest, FormatRESTApiUrl_PassingInvalidRESTApiId_ReturnEmptyResult)
  33. {
  34. auto actualUrl = AWSResourceMappingUtils::FormatRESTApiUrl("", TEST_VALID_RESTAPI_REGION, TEST_VALID_RESTAPI_STAGE);
  35. EXPECT_TRUE(actualUrl.empty());
  36. }
  37. TEST_F(AWSResourceMappingUtilsTest, FormatRESTApiUrl_PassingInvalidRESTApiRegion_ReturnEmptyResult)
  38. {
  39. auto actualUrl = AWSResourceMappingUtils::FormatRESTApiUrl(TEST_VALID_RESTAPI_ID, "", TEST_VALID_RESTAPI_STAGE);
  40. EXPECT_TRUE(actualUrl.empty());
  41. }
  42. TEST_F(AWSResourceMappingUtilsTest, FormatRESTApiUrl_PassingInvalidRESTApiStage_ReturnEmptyResult)
  43. {
  44. auto actualUrl = AWSResourceMappingUtils::FormatRESTApiUrl(TEST_VALID_RESTAPI_ID, TEST_VALID_RESTAPI_REGION, "");
  45. EXPECT_TRUE(actualUrl.empty());
  46. }