Merge branch 'development' into Atom/santorac/OrderOnceDependencyForPassBuilder
This commit is contained in:
@@ -15,9 +15,9 @@ ly_add_target(
|
||||
awsclientauth_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PUBLIC
|
||||
Include/Public
|
||||
Include
|
||||
PRIVATE
|
||||
Include/Private
|
||||
Source
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzCore
|
||||
@@ -35,7 +35,7 @@ ly_add_target(
|
||||
awsclientauth_shared_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Include/Private
|
||||
Source
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzCore
|
||||
@@ -97,8 +97,8 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
awsclientauth_test_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
"Include/Private"
|
||||
"Include/Public"
|
||||
Source
|
||||
Include
|
||||
Tests
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Authorization/AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider.h>
|
||||
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
|
||||
#include <aws/cognito-identity/CognitoIdentityClient.h>
|
||||
#include <aws/cognito-identity/model/GetCredentialsForIdentityRequest.h>
|
||||
#include <aws/cognito-identity/model/GetIdRequest.h>
|
||||
#include <aws/core/utils/Outcome.h>
|
||||
#include <aws/core/utils/logging/LogMacros.h>
|
||||
#include <aws/identity-management/auth/CognitoCachingCredentialsProvider.h>
|
||||
#include <aws/identity-management/auth/PersistentCognitoIdentityProvider.h>
|
||||
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
static const char* AUTH_LOG_TAG = "AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider";
|
||||
static const char* ANON_LOG_TAG = "AWSClientAuthCachingAnonymousCredsProvider";
|
||||
|
||||
// Modification of https://github.com/aws/aws-sdk-cpp/blob/main/aws-cpp-sdk-identity-management/source/auth/CognitoCachingCredentialsProvider.cpp#L92
|
||||
// to work around account ID requirement. Account id is not required for call to succeed and is not set unless provided.
|
||||
// see: https://github.com/aws/aws-sdk-cpp/issues/1448
|
||||
Aws::CognitoIdentity::Model::GetCredentialsForIdentityOutcome FetchCredsFromCognito(
|
||||
const Aws::CognitoIdentity::CognitoIdentityClient& cognitoIdentityClient,
|
||||
Aws::Auth::PersistentCognitoIdentityProvider& identityRepository,
|
||||
const char* logTag,
|
||||
bool includeLogins)
|
||||
{
|
||||
auto logins = identityRepository.GetLogins();
|
||||
Aws::Map<Aws::String, Aws::String> cognitoLogins;
|
||||
for (auto& login : logins)
|
||||
{
|
||||
cognitoLogins[login.first] = login.second.accessToken;
|
||||
}
|
||||
|
||||
if (!identityRepository.HasIdentityId())
|
||||
{
|
||||
auto accountId = identityRepository.GetAccountId();
|
||||
auto identityPoolId = identityRepository.GetIdentityPoolId();
|
||||
|
||||
Aws::CognitoIdentity::Model::GetIdRequest getIdRequest;
|
||||
getIdRequest.SetIdentityPoolId(identityPoolId);
|
||||
|
||||
if (!accountId.empty()) // new check
|
||||
{
|
||||
getIdRequest.SetAccountId(accountId);
|
||||
AWS_LOGSTREAM_INFO(logTag, "Identity not found, requesting an id for accountId "
|
||||
<< accountId << " identity pool id "
|
||||
<< identityPoolId << " with logins.");
|
||||
}
|
||||
else
|
||||
{
|
||||
AWS_LOGSTREAM_INFO(
|
||||
logTag, "Identity not found, requesting an id for identity pool id %s" << identityPoolId << " with logins.");
|
||||
}
|
||||
if (includeLogins)
|
||||
{
|
||||
getIdRequest.SetLogins(cognitoLogins);
|
||||
}
|
||||
|
||||
auto getIdOutcome = cognitoIdentityClient.GetId(getIdRequest);
|
||||
if (getIdOutcome.IsSuccess())
|
||||
{
|
||||
auto identityId = getIdOutcome.GetResult().GetIdentityId();
|
||||
AWS_LOGSTREAM_INFO(logTag, "Successfully retrieved identity: " << identityId);
|
||||
identityRepository.PersistIdentityId(identityId);
|
||||
}
|
||||
else
|
||||
{
|
||||
AWS_LOGSTREAM_ERROR(
|
||||
logTag,
|
||||
"Failed to retrieve identity. Error: " << getIdOutcome.GetError().GetExceptionName() << " "
|
||||
<< getIdOutcome.GetError().GetMessage());
|
||||
return Aws::CognitoIdentity::Model::GetCredentialsForIdentityOutcome(getIdOutcome.GetError());
|
||||
}
|
||||
}
|
||||
|
||||
Aws::CognitoIdentity::Model::GetCredentialsForIdentityRequest getCredentialsForIdentityRequest;
|
||||
getCredentialsForIdentityRequest.SetIdentityId(identityRepository.GetIdentityId());
|
||||
if (includeLogins)
|
||||
{
|
||||
getCredentialsForIdentityRequest.SetLogins(cognitoLogins);
|
||||
}
|
||||
|
||||
return cognitoIdentityClient.GetCredentialsForIdentity(getCredentialsForIdentityRequest);
|
||||
}
|
||||
|
||||
AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider::AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider(
|
||||
const std::shared_ptr<Aws::Auth::PersistentCognitoIdentityProvider>& identityRepository,
|
||||
const std::shared_ptr<Aws::CognitoIdentity::CognitoIdentityClient>& cognitoIdentityClient)
|
||||
: CognitoCachingCredentialsProvider(identityRepository, cognitoIdentityClient)
|
||||
{
|
||||
}
|
||||
|
||||
Aws::CognitoIdentity::Model::GetCredentialsForIdentityOutcome
|
||||
AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider::GetCredentialsFromCognito() const
|
||||
{
|
||||
return FetchCredsFromCognito(*m_cognitoIdentityClient, *m_identityRepository, AUTH_LOG_TAG, true);
|
||||
}
|
||||
|
||||
AWSClientAuthCachingAnonymousCredsProvider::AWSClientAuthCachingAnonymousCredsProvider(
|
||||
const std::shared_ptr<Aws::Auth::PersistentCognitoIdentityProvider>& identityRepository,
|
||||
const std::shared_ptr<Aws::CognitoIdentity::CognitoIdentityClient>& cognitoIdentityClient)
|
||||
: AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider(identityRepository, cognitoIdentityClient)
|
||||
{
|
||||
}
|
||||
|
||||
Aws::CognitoIdentity::Model::GetCredentialsForIdentityOutcome AWSClientAuthCachingAnonymousCredsProvider::
|
||||
GetCredentialsFromCognito() const
|
||||
{
|
||||
return FetchCredsFromCognito(*m_cognitoIdentityClient, *m_identityRepository, ANON_LOG_TAG, false);
|
||||
}
|
||||
|
||||
|
||||
} // namespace AWSClientAuth
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aws/cognito-identity/CognitoIdentityClient.h>
|
||||
#include <aws/identity-management/auth/CognitoCachingCredentialsProvider.h>
|
||||
#include <aws/identity-management/auth/PersistentCognitoIdentityProvider.h>
|
||||
|
||||
namespace AWSClientAuth
|
||||
{
|
||||
//! Cognito Caching Credentials Provider implementation that is derived from AWS Native SDK.
|
||||
//! For use with authenticated credentials.
|
||||
class AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider
|
||||
: public Aws::Auth::CognitoCachingCredentialsProvider
|
||||
{
|
||||
public:
|
||||
AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider(
|
||||
const std::shared_ptr<Aws::Auth::PersistentCognitoIdentityProvider>& identityRepository,
|
||||
const std::shared_ptr<Aws::CognitoIdentity::CognitoIdentityClient>& cognitoIdentityClient = nullptr);
|
||||
|
||||
protected:
|
||||
Aws::CognitoIdentity::Model::GetCredentialsForIdentityOutcome GetCredentialsFromCognito() const override;
|
||||
};
|
||||
|
||||
//! Cognito Caching Credentials Provider implementation that is eventually derived from AWS Native SDK.
|
||||
//! For use with anonymous credentials.
|
||||
class AWSClientAuthCachingAnonymousCredsProvider : public AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider
|
||||
{
|
||||
public:
|
||||
AWSClientAuthCachingAnonymousCredsProvider(
|
||||
const std::shared_ptr<Aws::Auth::PersistentCognitoIdentityProvider>& identityRepository,
|
||||
const std::shared_ptr<Aws::CognitoIdentity::CognitoIdentityClient>& cognitoIdentityClient = nullptr);
|
||||
|
||||
protected:
|
||||
Aws::CognitoIdentity::Model::GetCredentialsForIdentityOutcome GetCredentialsFromCognito() const override;
|
||||
};
|
||||
|
||||
} // namespace AWSClientAuth
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <AWSClientAuthBus.h>
|
||||
#include <AWSCoreBus.h>
|
||||
#include <Authorization/AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider.h>
|
||||
#include <Authorization/AWSCognitoAuthorizationController.h>
|
||||
#include <ResourceMapping/AWSResourceMappingBus.h>
|
||||
#include <AWSClientAuthResourceMappingConstants.h>
|
||||
@@ -38,10 +39,12 @@ namespace AWSClientAuth
|
||||
auto identityClient = AZ::Interface<IAWSClientAuthRequests>::Get()->GetCognitoIdentityClient();
|
||||
|
||||
m_cognitoCachingCredentialsProvider =
|
||||
std::make_shared<Aws::Auth::CognitoCachingAuthenticatedCredentialsProvider>(m_persistentCognitoIdentityProvider, identityClient);
|
||||
std::make_shared<AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider>(
|
||||
m_persistentCognitoIdentityProvider, identityClient);
|
||||
|
||||
m_cognitoCachingAnonymousCredentialsProvider =
|
||||
std::make_shared<Aws::Auth::CognitoCachingAnonymousCredentialsProvider>(m_persistentAnonymousCognitoIdentityProvider, identityClient);
|
||||
std::make_shared<AWSClientAuthCachingAnonymousCredsProvider>(
|
||||
m_persistentAnonymousCognitoIdentityProvider, identityClient);
|
||||
}
|
||||
|
||||
AWSCognitoAuthorizationController::~AWSCognitoAuthorizationController()
|
||||
@@ -65,9 +68,13 @@ namespace AWSClientAuth
|
||||
AWSCore::AWSResourceMappingRequestBus::BroadcastResult(
|
||||
m_cognitoIdentityPoolId, &AWSCore::AWSResourceMappingRequests::GetResourceNameId, CognitoIdentityPoolIdResourceMappingKey);
|
||||
|
||||
if (m_awsAccountId.empty() || m_cognitoIdentityPoolId.empty())
|
||||
if (m_awsAccountId.empty())
|
||||
{
|
||||
AZ_TracePrintf("AWSCognitoAuthorizationController", "AWS account id not not configured. Proceeding without it.");
|
||||
}
|
||||
|
||||
if (m_cognitoIdentityPoolId.empty())
|
||||
{
|
||||
AZ_Warning("AWSCognitoAuthorizationController", !m_awsAccountId.empty(), "Missing AWS account id not configured.");
|
||||
AZ_Warning("AWSCognitoAuthorizationController", !m_cognitoIdentityPoolId.empty(), "Missing Cognito Identity pool id in resource mappings.");
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-2
@@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Authorization/AWSCognitoAuthorizationBus.h>
|
||||
#include <Authorization/AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider.h>
|
||||
#include <Authorization/AWSClientAuthPersistentCognitoIdentityProvider.h>
|
||||
#include <Authentication/AuthenticationProviderBus.h>
|
||||
#include <Credential/AWSCredentialBus.h>
|
||||
@@ -51,8 +52,8 @@ namespace AWSClientAuth
|
||||
|
||||
std::shared_ptr<AWSClientAuthPersistentCognitoIdentityProvider> m_persistentCognitoIdentityProvider;
|
||||
std::shared_ptr<AWSClientAuthPersistentCognitoIdentityProvider> m_persistentAnonymousCognitoIdentityProvider;
|
||||
std::shared_ptr<Aws::Auth::CognitoCachingAuthenticatedCredentialsProvider> m_cognitoCachingCredentialsProvider;
|
||||
std::shared_ptr<Aws::Auth::CognitoCachingAnonymousCredentialsProvider> m_cognitoCachingAnonymousCredentialsProvider;
|
||||
std::shared_ptr<AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider> m_cognitoCachingCredentialsProvider;
|
||||
std::shared_ptr<AWSClientAuthCachingAnonymousCredsProvider> m_cognitoCachingAnonymousCredentialsProvider;
|
||||
|
||||
AZStd::string m_cognitoIdentityPoolId;
|
||||
AZStd::string m_formattedCognitoUserPoolId;
|
||||
@@ -608,7 +608,6 @@ namespace AWSClientAuthUnitTest
|
||||
AZ::Entity* FindEntity(const AZ::EntityId&) override { return nullptr; }
|
||||
AZ::BehaviorContext* GetBehaviorContext() override { return nullptr; }
|
||||
const char* GetExecutableFolder() const override { return nullptr; }
|
||||
const char* GetAppRoot() const override { return nullptr; }
|
||||
const char* GetEngineRoot() const override { return nullptr; }
|
||||
void EnumerateEntities(const EntityCallback& /*callback*/) override {}
|
||||
void QueryApplicationType(AZ::ApplicationTypeQuery& /*appType*/) const override {}
|
||||
|
||||
+16
-10
@@ -62,6 +62,14 @@ TEST_F(AWSCognitoAuthorizationControllerTest, Initialize_Success)
|
||||
ASSERT_TRUE(m_mockController->m_cognitoIdentityPoolId == AWSClientAuthUnitTest::TEST_RESOURCE_NAME_ID);
|
||||
}
|
||||
|
||||
TEST_F(AWSCognitoAuthorizationControllerTest, Initialize_Success_GetAWSAccountEmpty)
|
||||
{
|
||||
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetResourceNameId(testing::_)).Times(2);
|
||||
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetDefaultAccountId()).Times(1).WillOnce(testing::Return(""));
|
||||
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetDefaultRegion()).Times(1);
|
||||
ASSERT_TRUE(m_mockController->Initialize());
|
||||
}
|
||||
|
||||
TEST_F(AWSCognitoAuthorizationControllerTest, RequestAWSCredentials_WithLogins_Success)
|
||||
{
|
||||
AWSClientAuth::AuthenticationTokens tokens(
|
||||
@@ -121,7 +129,7 @@ TEST_F(AWSCognitoAuthorizationControllerTest, MultipleCalls_UsesCacheCredentials
|
||||
m_mockController->RequestAWSCredentialsAsync();
|
||||
}
|
||||
|
||||
TEST_F(AWSCognitoAuthorizationControllerTest, RequestAWSCredentials_Fail_GetIdError)
|
||||
TEST_F(AWSCognitoAuthorizationControllerTest, RequestAWSCredentials_Fail_GetIdError) // fail
|
||||
{
|
||||
AWSClientAuth::AuthenticationTokens cognitoTokens(
|
||||
AWSClientAuthUnitTest::TEST_TOKEN, AWSClientAuthUnitTest::TEST_TOKEN, AWSClientAuthUnitTest::TEST_TOKEN,
|
||||
@@ -140,7 +148,9 @@ TEST_F(AWSCognitoAuthorizationControllerTest, RequestAWSCredentials_Fail_GetIdEr
|
||||
EXPECT_CALL(*m_cognitoIdentityClientMock, GetCredentialsForIdentity(testing::_)).Times(0);
|
||||
EXPECT_CALL(m_awsCognitoAuthorizationNotificationsBusMock, OnRequestAWSCredentialsSuccess(testing::_)).Times(0);
|
||||
EXPECT_CALL(m_awsCognitoAuthorizationNotificationsBusMock, OnRequestAWSCredentialsFail(testing::_)).Times(1);
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_mockController->RequestAWSCredentialsAsync();
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION_NO_COUNT;
|
||||
}
|
||||
|
||||
TEST_F(AWSCognitoAuthorizationControllerTest, RequestAWSCredentials_Fail_GetCredentialsForIdentityError)
|
||||
@@ -174,7 +184,9 @@ TEST_F(AWSCognitoAuthorizationControllerTest, RequestAWSCredentials_Fail_GetCred
|
||||
EXPECT_CALL(*m_cognitoIdentityClientMock, GetCredentialsForIdentity(testing::_)).Times(1).WillOnce(testing::Return(outcome));
|
||||
EXPECT_CALL(m_awsCognitoAuthorizationNotificationsBusMock, OnRequestAWSCredentialsSuccess(testing::_)).Times(0);
|
||||
EXPECT_CALL(m_awsCognitoAuthorizationNotificationsBusMock, OnRequestAWSCredentialsFail(testing::_)).Times(1);
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
m_mockController->RequestAWSCredentialsAsync();
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION_NO_COUNT;
|
||||
}
|
||||
|
||||
TEST_F(AWSCognitoAuthorizationControllerTest, AddRemoveLogins_Succuess)
|
||||
@@ -321,7 +333,7 @@ TEST_F(AWSCognitoAuthorizationControllerTest, GetCredentialsProvider_NoPersisted
|
||||
EXPECT_TRUE(actualCredentialsProvider == m_mockController->m_cognitoCachingAnonymousCredentialsProvider);
|
||||
}
|
||||
|
||||
TEST_F(AWSCognitoAuthorizationControllerTest, GetCredentialsProvider_NoPersistedLogins_NoAnonymousCredentials_ResultNullPtr)
|
||||
TEST_F(AWSCognitoAuthorizationControllerTest, GetCredentialsProvider_NoPersistedLogins_NoAnonymousCredentials_ResultNullPtr) // fails
|
||||
{
|
||||
Aws::Client::AWSError<Aws::CognitoIdentity::CognitoIdentityErrors> error;
|
||||
error.SetExceptionName(AWSClientAuthUnitTest::TEST_EXCEPTION);
|
||||
@@ -331,8 +343,10 @@ TEST_F(AWSCognitoAuthorizationControllerTest, GetCredentialsProvider_NoPersisted
|
||||
EXPECT_CALL(*m_cognitoIdentityClientMock, GetCredentialsForIdentity(testing::_)).Times(0);
|
||||
|
||||
std::shared_ptr<Aws::Auth::AWSCredentialsProvider> actualCredentialsProvider;
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
AWSCore::AWSCredentialRequestBus::BroadcastResult(
|
||||
actualCredentialsProvider, &AWSCore::AWSCredentialRequests::GetCredentialsProvider);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION_NO_COUNT;
|
||||
EXPECT_TRUE(actualCredentialsProvider == nullptr);
|
||||
}
|
||||
|
||||
@@ -431,11 +445,3 @@ TEST_F(AWSCognitoAuthorizationControllerTest, Initialize_Fail_GetResourceNameEmp
|
||||
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetDefaultAccountId()).Times(1);
|
||||
ASSERT_FALSE(m_mockController->Initialize());
|
||||
}
|
||||
|
||||
TEST_F(AWSCognitoAuthorizationControllerTest, Initialize_Fail_GetAWSAccountEmpty)
|
||||
{
|
||||
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetResourceNameId(testing::_)).Times(1);
|
||||
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetDefaultAccountId()).Times(1).WillOnce(testing::Return(""));
|
||||
EXPECT_CALL(m_awsResourceMappingRequestBusMock, GetDefaultRegion()).Times(0);
|
||||
ASSERT_FALSE(m_mockController->Initialize());
|
||||
}
|
||||
|
||||
@@ -7,44 +7,43 @@
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Include/Public/Authentication/AuthenticationProviderBus.h
|
||||
Include/Public/Authentication/AuthenticationTokens.h
|
||||
Include/Public/Authorization/AWSCognitoAuthorizationBus.h
|
||||
Include/Public/Authorization/ClientAuthAWSCredentials.h
|
||||
Include/Public/UserManagement/AWSCognitoUserManagementBus.h
|
||||
Include/Authentication/AuthenticationProviderBus.h
|
||||
Include/Authentication/AuthenticationTokens.h
|
||||
Include/Authorization/AWSCognitoAuthorizationBus.h
|
||||
Include/Authorization/ClientAuthAWSCredentials.h
|
||||
Include/UserManagement/AWSCognitoUserManagementBus.h
|
||||
|
||||
Include/Private/AWSClientAuthSystemComponent.h
|
||||
Include/Private/AWSClientAuthBus.h
|
||||
Include/Private/AWSClientAuthResourceMappingConstants.h
|
||||
Include/Private/Authentication/AuthenticationProviderTypes.h
|
||||
Include/Private/Authentication/AuthenticationProviderScriptCanvasBus.h
|
||||
Include/Private/Authentication/AuthenticationProviderManager.h
|
||||
Include/Private/Authentication/AuthenticationNotificationBusBehaviorHandler.h
|
||||
|
||||
Include/Private/Authorization/AWSCognitoAuthorizationController.h
|
||||
Include/Private/Authorization/AWSClientAuthPersistentCognitoIdentityProvider.h
|
||||
Include/Private/Authorization/AWSCognitoAuthorizationNotificationBusBehaviorHandler.h
|
||||
|
||||
Include/Private/UserManagement/AWSCognitoUserManagementController.h
|
||||
Include/Private/UserManagement/UserManagementNotificationBusBehaviorHandler.h
|
||||
|
||||
Include/Private/Authentication/AuthenticationProviderInterface.h
|
||||
Include/Private/Authentication/OAuthConstants.h
|
||||
Include/Private/Authentication/AWSCognitoAuthenticationProvider.h
|
||||
Include/Private/Authentication/LWAAuthenticationProvider.h
|
||||
Include/Private/Authentication/GoogleAuthenticationProvider.h
|
||||
|
||||
Source/AWSClientAuthSystemComponent.cpp
|
||||
Source/Authentication/AuthenticationTokens.cpp
|
||||
Source/Authentication/AuthenticationProviderInterface.cpp
|
||||
Source/Authentication/AuthenticationProviderManager.cpp
|
||||
Source/Authentication/AWSCognitoAuthenticationProvider.cpp
|
||||
Source/Authentication/LWAAuthenticationProvider.cpp
|
||||
Source/Authentication/GoogleAuthenticationProvider.cpp
|
||||
Source/AWSClientAuthSystemComponent.h
|
||||
Source/AWSClientAuthBus.h
|
||||
Source/AWSClientAuthResourceMappingConstants.h
|
||||
|
||||
Source/Authorization/ClientAuthAWSCredentials.cpp
|
||||
Source/Authorization/AWSCognitoAuthorizationController.cpp
|
||||
Source/Authentication/AuthenticationNotificationBusBehaviorHandler.h
|
||||
Source/Authentication/AuthenticationProviderInterface.cpp
|
||||
Source/Authentication/AuthenticationProviderInterface.h
|
||||
Source/Authentication/AuthenticationProviderManager.cpp
|
||||
Source/Authentication/AuthenticationProviderManager.h
|
||||
Source/Authentication/AuthenticationProviderScriptCanvasBus.h
|
||||
Source/Authentication/AuthenticationProviderTypes.h
|
||||
Source/Authentication/AuthenticationTokens.cpp
|
||||
Source/Authentication/AWSCognitoAuthenticationProvider.cpp
|
||||
Source/Authentication/AWSCognitoAuthenticationProvider.h
|
||||
Source/Authentication/LWAAuthenticationProvider.cpp
|
||||
Source/Authentication/LWAAuthenticationProvider.h
|
||||
Source/Authentication/GoogleAuthenticationProvider.cpp
|
||||
Source/Authentication/GoogleAuthenticationProvider.h
|
||||
Source/Authentication/OAuthConstants.h
|
||||
|
||||
Source/Authorization/AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider.cpp
|
||||
Source/Authorization/AWSClientAuthCognitoCachingAuthenticatedCredentialsProvider.h
|
||||
Source/Authorization/AWSClientAuthPersistentCognitoIdentityProvider.cpp
|
||||
Source/Authorization/AWSClientAuthPersistentCognitoIdentityProvider.h
|
||||
Source/Authorization/AWSCognitoAuthorizationController.cpp
|
||||
Source/Authorization/AWSCognitoAuthorizationController.h
|
||||
Source/Authorization/AWSCognitoAuthorizationNotificationBusBehaviorHandler.h
|
||||
Source/Authorization/ClientAuthAWSCredentials.cpp
|
||||
|
||||
Source/UserManagement/AWSCognitoUserManagementController.cpp
|
||||
Source/UserManagement/AWSCognitoUserManagementController.h
|
||||
Source/UserManagement/UserManagementNotificationBusBehaviorHandler.h
|
||||
)
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Include/Private/AWSClientAuthModule.h
|
||||
Source/AWSClientAuthModule.cpp
|
||||
Source/AWSClientAuthModule.h
|
||||
)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"gem_name": "AWSClientAuth",
|
||||
"display_name": "AWS Client Authorization",
|
||||
"license": "Apache-2.0 Or MIT",
|
||||
"license_url": "https://github.com/o3de/o3de/blob/development/LICENSE.txt",
|
||||
"origin": "Amazon Web Services, Inc.",
|
||||
"type": "Code",
|
||||
"summary": "AWS Client Auth provides client authentication and AWS authorization solution.",
|
||||
@@ -14,7 +15,6 @@
|
||||
"SDK"
|
||||
],
|
||||
"icon_path": "preview.png",
|
||||
"requirements": "",
|
||||
"documentation_url": "https://o3de.org/docs/user-guide/gems/reference/aws/aws-client-auth/",
|
||||
"dependencies": [
|
||||
"AWSCore",
|
||||
|
||||
@@ -16,10 +16,10 @@ ly_add_target(
|
||||
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PUBLIC
|
||||
Include/Public
|
||||
Include
|
||||
${pal_dir}
|
||||
PRIVATE
|
||||
Include/Private
|
||||
Source
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzCore
|
||||
@@ -36,7 +36,7 @@ ly_add_target(
|
||||
awscore_shared_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Include/Private
|
||||
Source
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzCore
|
||||
@@ -60,6 +60,9 @@ ly_create_alias(
|
||||
)
|
||||
|
||||
if (PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/Platform/${PAL_PLATFORM_NAME}/PAL_traits_editor_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
|
||||
|
||||
ly_add_target(
|
||||
NAME AWSCore.Editor.Static STATIC
|
||||
NAMESPACE Gem
|
||||
@@ -68,10 +71,10 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_editor_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Include/Private
|
||||
Source
|
||||
${pal_dir}
|
||||
PUBLIC
|
||||
Include/Public
|
||||
Include
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzQtComponents
|
||||
@@ -90,29 +93,38 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
awscore_editor_shared_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Include/Private
|
||||
Source
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzCore
|
||||
Gem::AWSCore.Editor.Static
|
||||
)
|
||||
|
||||
# This target is not a real gem module
|
||||
# It is not meant to be loaded by the ModuleManager in C++
|
||||
ly_add_target(
|
||||
NAME AWSCore.ResourceMappingTool MODULE
|
||||
NAMESPACE Gem
|
||||
OUTPUT_SUBDIRECTORY AWSCoreEditorQtBin
|
||||
FILES_CMAKE
|
||||
awscore_resourcemappingtool_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Include/Private
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
Gem::AWSCore.Editor.Static
|
||||
)
|
||||
ly_add_dependencies(AWSCore.Editor AWSCore.ResourceMappingTool)
|
||||
if (PAL_TRAIT_ENABLE_RESOURCE_MAPPING_TOOL)
|
||||
|
||||
# This target is not a real gem module
|
||||
# It is not meant to be loaded by the ModuleManager in C++
|
||||
ly_add_target(
|
||||
NAME AWSCore.ResourceMappingTool MODULE
|
||||
NAMESPACE Gem
|
||||
OUTPUT_SUBDIRECTORY AWSCoreEditorQtBin
|
||||
FILES_CMAKE
|
||||
awscore_resourcemappingtool_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Source
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
Gem::AWSCore.Editor.Static
|
||||
RUNTIME_DEPENDENCIES
|
||||
3rdParty::pyside2
|
||||
|
||||
)
|
||||
ly_add_dependencies(AWSCore.Editor AWSCore.ResourceMappingTool)
|
||||
|
||||
ly_install_directory(DIRECTORIES Tools/ResourceMappingTool)
|
||||
|
||||
endif()
|
||||
|
||||
# Builders and Tools (such as the Editor use AWSCore.Editor) use the .Editor module above.
|
||||
ly_create_alias(
|
||||
@@ -144,8 +156,8 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
awscore_tests_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Include/Private
|
||||
Include/Public
|
||||
Source
|
||||
Include
|
||||
Tests
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
@@ -154,10 +166,20 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
AZ::AWSNativeSDKInit
|
||||
Gem::AWSCore.Static
|
||||
)
|
||||
|
||||
ly_add_googletest(
|
||||
NAME Gem::AWSCore.Tests
|
||||
)
|
||||
|
||||
ly_add_target_files(
|
||||
TARGETS
|
||||
AWSCore.Tests
|
||||
FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Tools/ResourceMappingTool/resource_mapping_schema.json
|
||||
OUTPUT_SUBDIRECTORY
|
||||
Gems/AWSCore
|
||||
)
|
||||
|
||||
if (PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
ly_add_target(
|
||||
NAME AWSCore.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
|
||||
@@ -168,9 +190,9 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_editor_tests_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Include/Private
|
||||
Source
|
||||
${pal_dir}
|
||||
Include/Public
|
||||
Include
|
||||
Tests
|
||||
COMPILE_DEFINITIONS
|
||||
PRIVATE
|
||||
@@ -180,6 +202,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
3rdParty::Qt::Gui
|
||||
3rdParty::Qt::Widgets
|
||||
AZ::AzTest
|
||||
AZ::AWSNativeSDKInit
|
||||
Gem::AWSCore.Static
|
||||
Gem::AWSCore.Editor.Static
|
||||
)
|
||||
@@ -189,4 +212,13 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
ly_add_target_files(
|
||||
TARGETS
|
||||
AWSCore
|
||||
FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Tools/ResourceMappingTool/resource_mapping_schema.json
|
||||
OUTPUT_SUBDIRECTORY
|
||||
Gems/AWSCore
|
||||
)
|
||||
|
||||
ly_install_directory(DIRECTORIES Tools/ResourceMappingTool)
|
||||
|
||||
@@ -7,4 +7,6 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define AWSCORE_EDITOR_RESOURCE_MAPPING_TOOL_ENABLED 0
|
||||
#define AWSCORE_EDITOR_RESOURCE_MAPPING_TOOL_ENABLED 1
|
||||
#define AWSCORE_EDITOR_PYTHON_DEBUG_ARGUMENT ""
|
||||
#define AWSCORE_EDITOR_PYTHON_COMMAND "python/python.sh"
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE 0
|
||||
#define AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE 1
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set(PAL_TRAIT_ENABLE_RESOURCE_MAPPING_TOOL TRUE)
|
||||
@@ -8,3 +8,5 @@
|
||||
#pragma once
|
||||
|
||||
#define AWSCORE_EDITOR_RESOURCE_MAPPING_TOOL_ENABLED 0
|
||||
#define AWSCORE_EDITOR_PYTHON_DEBUG_ARGUMENT ""
|
||||
#define AWSCORE_EDITOR_PYTHON_COMMAND "python/python.sh"
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE 0
|
||||
#define AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE 1
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set(PAL_TRAIT_ENABLE_RESOURCE_MAPPING_TOOL FALSE)
|
||||
@@ -8,3 +8,5 @@
|
||||
#pragma once
|
||||
|
||||
#define AWSCORE_EDITOR_RESOURCE_MAPPING_TOOL_ENABLED 1
|
||||
#define AWSCORE_EDITOR_PYTHON_DEBUG_ARGUMENT "debug "
|
||||
#define AWSCORE_EDITOR_PYTHON_COMMAND "python/python.cmd"
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE 0
|
||||
#define AWSCORE_BACKWARD_INCOMPATIBLE_CHANGE 1
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set(PAL_TRAIT_ENABLE_RESOURCE_MAPPING_TOOL TRUE)
|
||||
@@ -160,6 +160,7 @@ namespace AWSCore
|
||||
// If m_firstThreadCPU isn't -1, then each thread will be
|
||||
// assigned to a specific CPU starting with the specified CPU.
|
||||
AZ::JobManagerDesc jobManagerDesc{};
|
||||
jobManagerDesc.m_jobManagerName = "AWSCore JobManager";
|
||||
AZ::JobManagerThreadDesc threadDesc(m_firstThreadCPU, m_threadPriority, m_threadStackSize);
|
||||
for (int i = 0; i < m_threadCount; ++i)
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace AWSCore
|
||||
if (m_isDebug)
|
||||
{
|
||||
return AZStd::string::format(
|
||||
"\"%s\" debug -B \"%s\" --binaries-path \"%s\" --debug --profile \"%s\" --config-path \"%s\" --log-path \"%s\"",
|
||||
"\"%s\" " AWSCORE_EDITOR_PYTHON_DEBUG_ARGUMENT "-B \"%s\" --binaries-path \"%s\" --debug --profile \"%s\" --config-path \"%s\" --log-path \"%s\"",
|
||||
m_enginePythonEntryPath.c_str(), m_toolScriptPath.c_str(), m_toolQtBinDirectoryPath.c_str(),
|
||||
profileName.c_str(), m_toolConfigDirectoryPath.c_str(), m_toolLogDirectoryPath.c_str());
|
||||
}
|
||||
|
||||
+3
-1
@@ -13,6 +13,8 @@
|
||||
#include <QAction>
|
||||
#include <QObject>
|
||||
|
||||
#include "AWSCoreEditor_Traits_Platform.h"
|
||||
|
||||
namespace AWSCore
|
||||
{
|
||||
class AWSCoreResourceMappingToolAction
|
||||
@@ -22,7 +24,7 @@ namespace AWSCore
|
||||
static constexpr const char AWSCoreResourceMappingToolActionName[] = "AWSCoreResourceMappingToolAction";
|
||||
static constexpr const char ResourceMappingToolDirectoryPath[] = "Gems/AWSCore/Code/Tools/ResourceMappingTool";
|
||||
static constexpr const char ResourceMappingToolLogDirectoryPath[] = "user/log/";
|
||||
static constexpr const char EngineWindowsPythonEntryScriptPath[] = "python/python.cmd";
|
||||
static constexpr const char EngineWindowsPythonEntryScriptPath[] = AWSCORE_EDITOR_PYTHON_COMMAND;
|
||||
|
||||
AWSCoreResourceMappingToolAction(const QString& text, QObject* parent = nullptr);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace AWSCore
|
||||
{
|
||||
static constexpr const char AWSChinaRegionPrefix[] = "cn-";
|
||||
|
||||
static constexpr const char AWSFeatureGemRESTApiIdKeyNameSuffix[] = ".RESTApiId";
|
||||
static constexpr const char AWSFeatureGemRESTApiStageKeyNameSuffix[] = ".RESTApiStage";
|
||||
|
||||
static constexpr const char ResourceMappingAccountIdKeyName[] = "AccountId";
|
||||
static constexpr const char ResourceMappingResourcesKeyName[] = "AWSResourceMappings";
|
||||
static constexpr const char ResourceMappingNameIdKeyName[] = "Name/ID";
|
||||
static constexpr const char ResourceMappingRegionKeyName[] = "Region";
|
||||
static constexpr const char ResourceMappingTypeKeyName[] = "Type";
|
||||
static constexpr const char ResourceMappingVersionKeyName[] = "Version";
|
||||
|
||||
static constexpr const char ResourceMapppingJsonSchemaFilePath[] =
|
||||
"Gems/AWSCore/resource_mapping_schema.json";
|
||||
} // namespace AWSCore
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <AzCore/Serialization/Json/JsonUtils.h>
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
#include <AzCore/Settings/SettingsRegistryImpl.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
|
||||
#include <AWSCoreInternalBus.h>
|
||||
@@ -244,14 +245,16 @@ namespace AWSCore
|
||||
|
||||
bool AWSResourceMappingManager::ValidateJsonDocumentAgainstSchema(const rapidjson::Document& jsonDocument)
|
||||
{
|
||||
rapidjson::Document jsonSchemaDocument;
|
||||
if (jsonSchemaDocument.Parse(ResourceMappingJsonSchema).HasParseError())
|
||||
AZ::IO::Path executablePath = AZ::IO::PathView(AZ::Utils::GetExecutableDirectory());
|
||||
AZ::IO::Path jsonSchemaPath = (executablePath / ResourceMapppingJsonSchemaFilePath).LexicallyNormal();
|
||||
AZ::Outcome<rapidjson::Document, AZStd::string> readJsonOutcome = AZ::JsonSerializationUtils::ReadJsonFile(jsonSchemaPath.c_str());
|
||||
if (!readJsonOutcome.IsSuccess() || readJsonOutcome.TakeValue().ObjectEmpty())
|
||||
{
|
||||
AZ_Error(AWSResourceMappingManagerName, false, ResourceMappingFileInvalidSchemaErrorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto jsonSchema = rapidjson::SchemaDocument(jsonSchemaDocument);
|
||||
auto jsonSchema = rapidjson::SchemaDocument(readJsonOutcome.TakeValue());
|
||||
rapidjson::SchemaValidator validator(jsonSchema);
|
||||
|
||||
if (!jsonDocument.Accept(validator))
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <AWSCoreSystemComponent.h>
|
||||
#include <AWSNativeSDKInit/AWSNativeSDKInit.h>
|
||||
#include <Configuration/AWSCoreConfiguration.h>
|
||||
#include <Credential/AWSCredentialManager.h>
|
||||
#include <Framework/AWSApiJob.h>
|
||||
@@ -103,6 +104,9 @@ public:
|
||||
|
||||
TEST_F(AWSCoreSystemComponentTest, ComponentActivateTest)
|
||||
{
|
||||
// Shutdown SDK which is init in fixture setup step
|
||||
AWSNativeSDKInit::InitializationManager::Shutdown();
|
||||
|
||||
EXPECT_FALSE(m_coreSystemsComponent->IsAWSApiInitialized());
|
||||
|
||||
// activate component
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzTest/AzTest.h>
|
||||
|
||||
#include <Configuration/AWSCoreConfiguration.h>
|
||||
#include <TestFramework/AWSCoreFixture.h>
|
||||
@@ -39,12 +38,11 @@ class AWSCoreConfigurationTest
|
||||
: public AWSCoreFixture
|
||||
{
|
||||
public:
|
||||
void CreateTestSetRegFile(const AZStd::string& setregContent)
|
||||
AWSCoreConfigurationTest()
|
||||
{
|
||||
m_normalizedSetRegFilePath = AZStd::string::format("%s/%s",
|
||||
m_normalizedSetRegFolderPath.c_str(), AWSCore::AWSCoreConfiguration::AWSCoreConfigurationFileName);
|
||||
AzFramework::StringFunc::Path::Normalize(m_normalizedSetRegFilePath);
|
||||
CreateTestFile(m_normalizedSetRegFilePath, setregContent);
|
||||
m_setRegFilePath = (GetTestTempDirectoryPath() /
|
||||
AZ::SettingsRegistryInterface::RegistryFolder /
|
||||
AWSCore::AWSCoreConfiguration::AWSCoreConfigurationFileName).LexicallyNormal();
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
@@ -53,22 +51,13 @@ public:
|
||||
|
||||
m_awsCoreConfiguration = AZStd::make_unique<AWSCore::AWSCoreConfiguration>();
|
||||
|
||||
m_normalizedSourceProjectFolder = AZStd::string::format("%s/%s%s/", AZ::Test::GetCurrentExecutablePath().c_str(),
|
||||
"AWSResourceMappingManager", AZ::Uuid::CreateRandom().ToString<AZStd::string>(false, false).c_str());
|
||||
AzFramework::StringFunc::Path::Normalize(m_normalizedSourceProjectFolder);
|
||||
m_normalizedSetRegFolderPath = AZStd::string::format("%s/%s/",
|
||||
m_normalizedSourceProjectFolder.c_str(), AZ::SettingsRegistryInterface::RegistryFolder);
|
||||
AzFramework::StringFunc::Path::Normalize(m_normalizedSetRegFolderPath);
|
||||
|
||||
m_localFileIO->SetAlias("@projectroot@", m_normalizedSourceProjectFolder.c_str());
|
||||
|
||||
CreateTestSetRegFile(TEST_VALID_RESOURCE_MAPPING_SETREG);
|
||||
CreateFile(m_setRegFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_SETREG);
|
||||
m_localFileIO->SetAlias("@projectroot@", GetTestTempDirectoryPath().Native().c_str());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
RemoveTestFile();
|
||||
RemoveTestDirectory();
|
||||
RemoveFile(m_setRegFilePath.Native());
|
||||
|
||||
m_awsCoreConfiguration.reset();
|
||||
|
||||
@@ -76,52 +65,12 @@ public:
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<AWSCore::AWSCoreConfiguration> m_awsCoreConfiguration;
|
||||
AZStd::string m_normalizedSetRegFilePath;
|
||||
|
||||
private:
|
||||
AZStd::string m_normalizedSourceProjectFolder;
|
||||
AZStd::string m_normalizedSetRegFolderPath;
|
||||
|
||||
void CreateTestFile(const AZStd::string& filePath, const AZStd::string& fileContent)
|
||||
{
|
||||
AZ::IO::SystemFile file;
|
||||
if (!file.Open(filePath.c_str(),
|
||||
AZ::IO::SystemFile::OpenMode::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY))
|
||||
{
|
||||
AZ_Assert(false, "Failed to open test file");
|
||||
}
|
||||
|
||||
if (file.Write(fileContent.c_str(), fileContent.size()) != fileContent.size())
|
||||
{
|
||||
AZ_Assert(false, "Failed to write test file");
|
||||
}
|
||||
file.Close();
|
||||
}
|
||||
|
||||
void RemoveTestFile()
|
||||
{
|
||||
if (!m_normalizedSetRegFilePath.empty())
|
||||
{
|
||||
AZ_Assert(AZ::IO::SystemFile::Delete(m_normalizedSetRegFilePath.c_str()),
|
||||
"Failed to delete test settings registry file at %s", m_normalizedSetRegFilePath.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveTestDirectory()
|
||||
{
|
||||
if (!m_normalizedSetRegFilePath.empty())
|
||||
{
|
||||
AZ_Assert(AZ::IO::SystemFile::DeleteDir(m_normalizedSetRegFolderPath.c_str()),
|
||||
"Failed to delete test settings registry folder at %s", m_normalizedSetRegFolderPath.c_str());
|
||||
AZ_Assert(AZ::IO::SystemFile::DeleteDir(m_normalizedSourceProjectFolder.c_str()),
|
||||
"Failed to delete test folder at %s", m_normalizedSourceProjectFolder.c_str());
|
||||
}
|
||||
}
|
||||
AZ::IO::Path m_setRegFilePath;
|
||||
};
|
||||
|
||||
TEST_F(AWSCoreConfigurationTest, InitConfig_NoSourceProjectFolderFound_ReturnEmptyConfigFilePath)
|
||||
{
|
||||
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_settingsRegistry->MergeSettingsFile(m_setRegFilePath.Native(), AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_localFileIO->ClearAlias("@projectroot@");
|
||||
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
@@ -134,8 +83,8 @@ TEST_F(AWSCoreConfigurationTest, InitConfig_NoSourceProjectFolderFound_ReturnEmp
|
||||
|
||||
TEST_F(AWSCoreConfigurationTest, InitConfig_SettingsRegistryIsEmpty_ReturnEmptyConfigFilePath)
|
||||
{
|
||||
CreateTestSetRegFile(TEST_INVALID_RESOURCE_MAPPING_SETREG);
|
||||
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
CreateFile(m_setRegFilePath.Native(), TEST_INVALID_RESOURCE_MAPPING_SETREG);
|
||||
m_settingsRegistry->MergeSettingsFile(m_setRegFilePath.Native(), AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_awsCoreConfiguration->InitConfig();
|
||||
|
||||
auto actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
|
||||
@@ -144,7 +93,7 @@ TEST_F(AWSCoreConfigurationTest, InitConfig_SettingsRegistryIsEmpty_ReturnEmptyC
|
||||
|
||||
TEST_F(AWSCoreConfigurationTest, InitConfig_LoadValidSettingsRegistry_ReturnNonEmptyConfigFilePath)
|
||||
{
|
||||
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_settingsRegistry->MergeSettingsFile(m_setRegFilePath.Native(), AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_awsCoreConfiguration->InitConfig();
|
||||
|
||||
auto actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
|
||||
@@ -153,7 +102,7 @@ TEST_F(AWSCoreConfigurationTest, InitConfig_LoadValidSettingsRegistry_ReturnNonE
|
||||
|
||||
TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_NoSourceProjectFolderFound_ReturnEmptyConfigFilePath)
|
||||
{
|
||||
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_settingsRegistry->MergeSettingsFile(m_setRegFilePath.Native(), AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_localFileIO->ClearAlias("@projectroot@");
|
||||
m_awsCoreConfiguration->ReloadConfiguration();
|
||||
|
||||
@@ -163,8 +112,8 @@ TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_NoSourceProjectFolderFound_
|
||||
|
||||
TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_LoadValidSettingsRegistryAfterInvalidOne_ReturnNonEmptyConfigFilePath)
|
||||
{
|
||||
CreateTestSetRegFile(TEST_INVALID_RESOURCE_MAPPING_SETREG);
|
||||
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
CreateFile(m_setRegFilePath.Native(), TEST_INVALID_RESOURCE_MAPPING_SETREG);
|
||||
m_settingsRegistry->MergeSettingsFile(m_setRegFilePath.Native(), AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_awsCoreConfiguration->InitConfig();
|
||||
|
||||
auto actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
|
||||
@@ -172,7 +121,7 @@ TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_LoadValidSettingsRegistryAf
|
||||
EXPECT_TRUE(actualConfigFilePath.empty());
|
||||
EXPECT_TRUE(actualProfileName == AWSCoreConfiguration::AWSCoreDefaultProfileName);
|
||||
|
||||
CreateTestSetRegFile(TEST_VALID_RESOURCE_MAPPING_SETREG);
|
||||
CreateFile(m_setRegFilePath.Native(), TEST_VALID_RESOURCE_MAPPING_SETREG);
|
||||
m_awsCoreConfiguration->ReloadConfiguration();
|
||||
|
||||
actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
|
||||
@@ -183,7 +132,7 @@ TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_LoadValidSettingsRegistryAf
|
||||
|
||||
TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_LoadInvalidSettingsRegistryAfterValidOne_ReturnEmptyConfigFilePath)
|
||||
{
|
||||
m_settingsRegistry->MergeSettingsFile(m_normalizedSetRegFilePath, AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_settingsRegistry->MergeSettingsFile(m_setRegFilePath.Native(), AZ::SettingsRegistryInterface::Format::JsonMergePatch, {});
|
||||
m_awsCoreConfiguration->InitConfig();
|
||||
|
||||
auto actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
|
||||
@@ -191,7 +140,7 @@ TEST_F(AWSCoreConfigurationTest, ReloadConfiguration_LoadInvalidSettingsRegistry
|
||||
EXPECT_FALSE(actualConfigFilePath.empty());
|
||||
EXPECT_TRUE(actualProfileName != AWSCoreConfiguration::AWSCoreDefaultProfileName);
|
||||
|
||||
CreateTestSetRegFile(TEST_INVALID_RESOURCE_MAPPING_SETREG);
|
||||
CreateFile(m_setRegFilePath.Native(), TEST_INVALID_RESOURCE_MAPPING_SETREG);
|
||||
m_awsCoreConfiguration->ReloadConfiguration();
|
||||
|
||||
actualConfigFilePath = m_awsCoreConfiguration->GetResourceMappingConfigFilePath();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user