1832 lines
87 KiB
C++
1832 lines
87 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// (c) Copyright, Ubisoft Entertainment Inc. || Created by Harbour //
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
#include "tests/config.h"
|
|
#include "tests/fixture/authenticationFixture.h"
|
|
#include "tests/fixture/loginMockFixture.h"
|
|
#include "tests/fixture/paramFixture.h"
|
|
#include "tests/mock/mockLogDevice.h"
|
|
#include "tests/mock/mockResultHelper.h"
|
|
#include "tests/mock/parametersMockHelper.h"
|
|
#include <../private/ubiservices/core/configs/platformName.h>
|
|
#include <ubiservices/core/helpers/assertionHelper.h>
|
|
#include <ubiservices/core/JSON/jsonWriter.h>
|
|
#include <ubiservices/core/tasks/asyncResult.h>
|
|
#include <ubiservices/core/types/containers.h>
|
|
#include <ubiservices/core/types/string.h>
|
|
#include <ubiservices/services/http/request/httpGet.h>
|
|
#include <ubiservices/services/http/request/httpPost.h>
|
|
#include <ubiservices/services/parameters/parametersClient.h>
|
|
#include <../private/ubiservices/services/parameters/parametersClientProxy.h>
|
|
#include <ubiservices/services/parameters/parametersGroupInfo.h>
|
|
#include <../private/ubiservices/services/parameters/parametersResources.h>
|
|
#if defined(US_PRIMARY_STORE_WITHOUT_API)
|
|
#include <ubiservices/services/primaryStore/primaryStoreParams.h>
|
|
#endif
|
|
#include <ubiservices/services/user/userClient.h>
|
|
|
|
namespace US_NS {;
|
|
US_DEFINE_TEST(TestParametersClient);
|
|
|
|
#if !defined(US_DLL)
|
|
typedef AuthenticationFixture<1> PARAMETERS;
|
|
typedef AuthenticationFixture<1, false> PARAMETERS_NOLOGIN;
|
|
typedef LeakCheckerNoInit PARAMETERS_NO_INIT;
|
|
typedef LoginMockFixture<true> PARAMETERS_MOCK;
|
|
typedef LoginMockFixture<false> PARAMETERS_MOCK_NO_LOGIN;
|
|
typedef LoginMockFixtureNoUbiAccount PARAMETERS_MOCK_LOGIN;
|
|
|
|
namespace TestUserClient_BF
|
|
{
|
|
String getBase64Encoding(String str);
|
|
}
|
|
|
|
namespace TestParametersClient_BF
|
|
{
|
|
const char* spaceCustomStringGroup = "space-custom-string";
|
|
const char* spaceCustomBoolGroup = "space-custom-bool";
|
|
const char* applicationCustomBoolGroup = "application-custom-bool";
|
|
const char* applicationCustomStringGroup = "application-custom-string";
|
|
|
|
const char* const APPLICATION_ID_US_SDK_SPECIAL_TESTS_PC = "bb875ed4-07a0-461e-bb33-882b4964dda1";
|
|
const char* const SPACE_ID_US_SDK_SPECIAL_TESTS_PC = "0ba591a6-eb3d-44f6-9cc2-3cc58967a96a";
|
|
|
|
class ParametersApplicationWithCustomGroups : public ParametersApplicationMockHelper
|
|
{
|
|
public:
|
|
ParametersApplicationWithCustomGroups()
|
|
: m_customGroups()
|
|
{
|
|
{
|
|
JsonWriter fields;
|
|
fields["dummyApplicationString"] = "applicationString";
|
|
m_customGroups[applicationCustomStringGroup] = fields.getJson();
|
|
}
|
|
|
|
{
|
|
JsonWriter fields;
|
|
fields["dummyApplicationBool"] = false;
|
|
m_customGroups[applicationCustomBoolGroup] = fields.getJson();
|
|
}
|
|
}
|
|
|
|
Json getParameters() const override
|
|
{
|
|
JsonWriter root;
|
|
if (!m_parametersDone)
|
|
{
|
|
// Filling only mandatory parameters group
|
|
root["us-staging"] = buildParameterGroupStaging();
|
|
#if !defined(US_SDK_S2S)
|
|
root["us-sdkClientFeaturesSwitches"] = buildFeatureSwitchesParameterGroup();
|
|
root["us-sdkClientUrls"] = buildParameterGroupUrls();
|
|
#endif
|
|
}
|
|
|
|
// custom part
|
|
|
|
for (const auto& customGroup : m_customGroups)
|
|
{
|
|
root[customGroup.first] = renderParameterGroup(customGroup.second);
|
|
}
|
|
|
|
m_parameters["parameters"] = root.getJson();
|
|
return m_parameters.getJson();
|
|
}
|
|
|
|
private:
|
|
Map<String, Json> m_customGroups;
|
|
};
|
|
|
|
class ParametersSpaceWithCustomGroups : public ParametersSpaceMockHelper
|
|
{
|
|
public:
|
|
ParametersSpaceWithCustomGroups()
|
|
:m_customGroups()
|
|
{
|
|
{
|
|
JsonWriter fields;
|
|
fields["dummySpaceString"] = "spaceString";
|
|
m_customGroups[spaceCustomStringGroup] = fields.getJson();
|
|
}
|
|
|
|
{
|
|
JsonWriter fields;
|
|
fields["dummySpaceBool"] = true;
|
|
m_customGroups[spaceCustomBoolGroup] = fields.getJson();
|
|
}
|
|
}
|
|
|
|
Json getParameters() const override
|
|
{
|
|
JsonWriter root;
|
|
if (!m_parametersDone)
|
|
{
|
|
// Filling only mandatory parameters group
|
|
#if defined(US_SDK_S2S)
|
|
root["us-sdkServerUrls"] = buildUrlsParameterGroup();
|
|
root["us-sdkServerFeaturesSwitches"] = buildFeatureSwitchesParameterGroup();
|
|
#else
|
|
root["us-sdkClientFeaturesSwitches"] = buildFeatureSwitchesParameterGroup();
|
|
root["us-sdkClientUrls"] = buildUrlsParameterGroup();
|
|
// not mandatory, but for good manners
|
|
root["us-sdkClientRemoteLogsInternal"] = buildRemoteLogsInternalParameterGroup();
|
|
#endif
|
|
}
|
|
|
|
// custom part
|
|
|
|
for (const auto& customGroup : m_customGroups)
|
|
{
|
|
root[customGroup.first] = renderParameterGroup(customGroup.second);
|
|
}
|
|
|
|
m_parameters["parameters"] = root.getJson();
|
|
return m_parameters.getJson();
|
|
}
|
|
|
|
private:
|
|
Map<String, Json> m_customGroups;
|
|
};
|
|
|
|
struct TestParamGroup
|
|
{
|
|
TestParamGroup(const char* groupName, const char* paramKey, const char* paramValue, bool inRequest, bool isApplicationGroup = true)
|
|
: m_groupName(groupName)
|
|
, m_paramKey(paramKey)
|
|
, m_paramValue(paramValue)
|
|
, m_inRequest(inRequest)
|
|
, m_isApplicationGroup(isApplicationGroup)
|
|
{
|
|
}
|
|
|
|
const char* m_groupName;
|
|
const char* m_paramKey;
|
|
const char* m_paramValue;
|
|
bool m_inRequest;
|
|
bool m_isApplicationGroup;
|
|
};
|
|
|
|
void validateRequestParametersResponse(const Map<String, ParametersGroupInfo>& groups, const String& paramName, uint32 startAt)
|
|
{
|
|
ASSERT_EQ(groups.size(), 1);
|
|
|
|
const auto& itGroup = groups.find("otherParameters");
|
|
ASSERT_TRUE(itGroup != groups.end());
|
|
|
|
EXPECT_EQ(String::formatText("%sValue%d", paramName.getUtf8(), startAt), itGroup->second.m_fields[String::formatText("%sParameter%d", paramName.getUtf8(), startAt)].getValueString());
|
|
EXPECT_EQ(String::formatText("%sValue%d", paramName.getUtf8(), startAt+1), itGroup->second.m_fields[String::formatText("%sParameter%d", paramName.getUtf8(), startAt+1)].getValueString());
|
|
}
|
|
}
|
|
|
|
namespace TestUrlsPlaceholders_BF
|
|
{
|
|
const Json getApplicationMockedParams(const Json& newUrls)
|
|
{
|
|
struct ParametersApplicationWithExtraUrls : public ParametersApplicationMockHelper
|
|
{
|
|
ParametersApplicationWithExtraUrls(const Json& newUrls)
|
|
: m_newUrls(newUrls)
|
|
{
|
|
}
|
|
|
|
private:
|
|
#if !defined(US_SDK_S2S)
|
|
Json buildParameterGroupUrls() const override
|
|
{
|
|
JsonWriter fields;
|
|
// mandatory
|
|
fields["populations"] = "/profiles/me/mock-populations";
|
|
// new Url with placeholders
|
|
for (const auto& baseUrl : m_newUrls.getItems())
|
|
{
|
|
fields[baseUrl.getKey()] = baseUrl.getValueString();
|
|
}
|
|
return renderParameterGroup(fields.getJson());
|
|
}
|
|
#endif
|
|
const Json m_newUrls;
|
|
};
|
|
|
|
return ParametersApplicationWithExtraUrls(newUrls).getParameters();
|
|
}
|
|
|
|
const Json getSpaceMockedParams(const Json& newUrls)
|
|
{
|
|
struct ParametersSpaceWithExtraUrls : public ParametersSpaceMockHelper
|
|
{
|
|
ParametersSpaceWithExtraUrls(const Json& newUrls)
|
|
: m_newUrls(newUrls)
|
|
{
|
|
}
|
|
|
|
private:
|
|
Json buildUrlsParameterGroup() const override
|
|
{
|
|
JsonWriter fields;
|
|
// mandatory
|
|
fields["configsEvents"] = "https://{env}MOCK-api-ubiservices.ubi.com/{version}/spaces/{spaceId}/mock-config-events";
|
|
// new Url with placeholders
|
|
for (const auto& baseUrl : m_newUrls.getItems())
|
|
{
|
|
fields[baseUrl.getKey()] = baseUrl.getValueString();
|
|
}
|
|
return renderParameterGroup(fields.getJson());
|
|
}
|
|
|
|
const Json m_newUrls;
|
|
};
|
|
|
|
return ParametersSpaceWithExtraUrls(newUrls).getParameters();
|
|
}
|
|
};
|
|
|
|
/// @test validates that none of the standard groups should be returned when calling ParametersClient::getParametersGroupApplication
|
|
TEST_F(PARAMETERS, US_GetParametersGroupApplication)
|
|
{
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
|
|
for (const auto& queryParamStandard : ParametersApplicationResources::MAP)
|
|
{
|
|
const ParametersGroupInfo& group = client.getParametersGroupApplication(queryParamStandard.second);
|
|
ASSERT_EQ("{}", group.m_fields.renderContent());
|
|
#if !defined(US_SDK_S2S)
|
|
ASSERT_TRUE(group.m_relatedPopulation.m_name.isEmpty());
|
|
ASSERT_TRUE(group.m_relatedPopulation.m_subject.isEmpty());
|
|
#endif
|
|
}
|
|
}
|
|
/// @test validates that none of the standard groups should be returned when calling ParametersClient::getParametersGroupSpace
|
|
TEST_F(PARAMETERS, US_GetParametersGroupSpaces)
|
|
{
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
|
|
for (const auto& queryParamStandard : ParametersSpaceResources::MAP)
|
|
{
|
|
const ParametersGroupInfo& group = client.getParametersGroupSpace(queryParamStandard.second);
|
|
ASSERT_EQ("{}", group.m_fields.renderContent());
|
|
#if !defined(US_SDK_S2S)
|
|
ASSERT_TRUE(group.m_relatedPopulation.m_name.isEmpty());
|
|
ASSERT_TRUE(group.m_relatedPopulation.m_subject.isEmpty());
|
|
#endif
|
|
}
|
|
}
|
|
|
|
/// @test validates that none of the standard groups should be returned when calling ParametersClient::getParametersGroupsApplication
|
|
TEST_F(PARAMETERS, US_GetParametersGroupsApplication)
|
|
{
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
|
|
Vector<String> groupNames;
|
|
groupNames.reserve(ParametersApplicationResources::MAP.size());
|
|
|
|
for (const auto& queryParamStandard : ParametersApplicationResources::MAP)
|
|
{
|
|
groupNames.push_back(queryParamStandard.second);
|
|
}
|
|
|
|
const auto& parametersGroups = client.getParametersGroupsApplication(groupNames);
|
|
ASSERT_EQ(0u, parametersGroups.size());
|
|
}
|
|
/// @test validates that none of the standard groups should be returned when calling ParametersClient::getParametersGroupsSpace
|
|
TEST_F(PARAMETERS, US_GetParametersGroupsSpaces)
|
|
{
|
|
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
|
|
Vector<String> groupNames;
|
|
groupNames.reserve(ParametersApplicationResources::MAP.size());
|
|
|
|
for (const auto& queryParamStandard : ParametersSpaceResources::MAP)
|
|
{
|
|
groupNames.push_back(queryParamStandard.second);
|
|
}
|
|
|
|
const auto& parametersGroups = client.getParametersGroupsSpace(groupNames);
|
|
ASSERT_EQ(0u, parametersGroups.size());
|
|
}
|
|
|
|
/// @test Checks that if no parameter was passed on the CreateSession, nothing should be returned from the client side.
|
|
TEST_F(PARAMETERS_MOCK, LOCAL_CreateSessionWithouPassingParamatersGroupsApplication)
|
|
{
|
|
{
|
|
const auto group = getFacade().getParametersClient().getParametersGroupApplication("dummyParameters");
|
|
ASSERT_EQ(String("{}"), group.m_fields.renderContent());
|
|
#if !defined(US_SDK_S2S)
|
|
ASSERT_EQ(String(), group.m_relatedPopulation.m_name);
|
|
ASSERT_EQ(String(), group.m_relatedPopulation.m_subject);
|
|
#endif
|
|
}
|
|
|
|
{
|
|
const auto groups = getFacade().getParametersClient().getParametersGroupsApplication({"groupParametersName1", "groupParametersName2"});
|
|
ASSERT_EQ(0u, groups.size());
|
|
}
|
|
}
|
|
|
|
/// @test Checks that if no parameter was passed on the CreateSession, nothing should be returned from the client side.
|
|
TEST_F(PARAMETERS_MOCK, LOCAL_CreateSessionWithouPassingParamatersGroupsSpace)
|
|
{
|
|
{
|
|
const auto group = getFacade().getParametersClient().getParametersGroupSpace("dummyParameters");
|
|
ASSERT_EQ(String("{}"), group.m_fields.renderContent());
|
|
#if !defined(US_SDK_S2S)
|
|
ASSERT_EQ(String(), group.m_relatedPopulation.m_name);
|
|
ASSERT_EQ(String(), group.m_relatedPopulation.m_subject);
|
|
#endif
|
|
}
|
|
|
|
{
|
|
const auto groups = getFacade().getParametersClient().getParametersGroupsSpace({ "groupParametersName1", "groupParametersName2" });
|
|
ASSERT_EQ(0u, groups.size());
|
|
}
|
|
}
|
|
|
|
/// @test Validates that the query parameter is sent in the parameter request even if no custom group is passed
|
|
/// in ParametersApplicationResources and ParametersSpaceResources.
|
|
/// When no custom group is passed, the query url will contain the internal parameter groups.
|
|
TEST_F(PARAMETERS_MOCK_NO_LOGIN, LOCAL_CheckNoQueryParameterSentAtCreateSessionWithEmptyCustomGroups)
|
|
{
|
|
HttpGet requestSpace(StringUrl(""));
|
|
HttpGet requestApplication(StringUrl(""));
|
|
{
|
|
#if defined(US_SDK_S2S)
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_POST, "/applications/sessions", getMockedLoginResponse());
|
|
#else
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_POST, "profiles/sessions", getMockedLoginResponse());
|
|
#endif
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/parameters")
|
|
.WillOnce(testing::DoAll(
|
|
testing::SaveArg<0>(static_cast<HttpRequest*>(&requestApplication)),
|
|
testing::Return(MockResultHelper::createSuccessResult(ParametersApplicationMockHelper().getParameters().renderContent()))))
|
|
.WillOnce(testing::DoAll(
|
|
testing::SaveArg<0>(static_cast<HttpRequest*>(&requestSpace)),
|
|
testing::Return(MockResultHelper::createSuccessResult(ParametersSpaceMockHelper().getParameters().renderContent()))));
|
|
|
|
#if !defined(US_SDK_S2S)
|
|
mockPopulationsCalls();
|
|
mockPrimaryStoreCalls();
|
|
#endif
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-config-events")
|
|
.Times(testing::AnyNumber())
|
|
.WillRepeatedly(testing::Return(getMockedLoginResponseEventConfig()));
|
|
setupWebsocketMock();
|
|
|
|
}
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(getFacade().createSession(GET_CREDENTIALS(), {}, {})));
|
|
|
|
waitForPostLoginCompletion();
|
|
|
|
// Application check
|
|
{
|
|
const auto& requestUrl = requestApplication.getUrl();
|
|
EXPECT_NE(String::npos, requestUrl.findSubstringNoCase("parameterGroups")); // name of the query parameter
|
|
for (const auto& queryParamStandard : ParametersApplicationResources::MAP)
|
|
{
|
|
EXPECT_NE(String::npos, requestUrl.findSubstringNoCase(queryParamStandard.second));
|
|
}
|
|
}
|
|
|
|
// Space check
|
|
{
|
|
const auto& requestUrl = requestSpace.getUrl();
|
|
EXPECT_NE(String::npos, requestUrl.findSubstringNoCase("parameterGroups")); // name of the query parameter
|
|
for (const auto& queryParamStandard : ParametersSpaceResources::MAP)
|
|
{
|
|
EXPECT_NE(String::npos, requestUrl.findSubstringNoCase(queryParamStandard.second));
|
|
}
|
|
}
|
|
}
|
|
|
|
/// @test Validates that the standard groups in ParametersApplicationResources and ParametersSpaceResources are sent in the query of the request.
|
|
/// TODO : Remove in 2019
|
|
TEST_F(PARAMETERS_MOCK_NO_LOGIN, LOCAL_CheckStandardParametersSentAtCreateSession)
|
|
{
|
|
HttpGet requestSpace(StringUrl(""));
|
|
HttpGet requestApplication(StringUrl(""));
|
|
{
|
|
#if defined(US_SDK_S2S)
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_POST, "/applications/sessions", getMockedLoginResponse());
|
|
#else
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_POST, "profiles/sessions", getMockedLoginResponse());
|
|
#endif
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/parameters")
|
|
.WillOnce(testing::DoAll(
|
|
testing::SaveArg<0>(static_cast<HttpRequest*>(&requestApplication)),
|
|
testing::Return(MockResultHelper::createSuccessResult(ParametersApplicationMockHelper().getParameters().renderContent()))))
|
|
.WillOnce(testing::DoAll(
|
|
testing::SaveArg<0>(static_cast<HttpRequest*>(&requestSpace)),
|
|
testing::Return(MockResultHelper::createSuccessResult(ParametersSpaceMockHelper().getParameters().renderContent()))));
|
|
|
|
#if !defined(US_SDK_S2S)
|
|
mockPopulationsCalls();
|
|
mockPrimaryStoreCalls();
|
|
#endif
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-config-events")
|
|
.Times(testing::AnyNumber())
|
|
.WillRepeatedly(testing::Return(getMockedLoginResponseEventConfig()));
|
|
setupWebsocketMock();
|
|
|
|
}
|
|
|
|
auto result = getFacade().createSession(GET_CREDENTIALS()
|
|
, { TestParametersClient_BF::applicationCustomStringGroup, TestParametersClient_BF::applicationCustomBoolGroup } // Trivial values, only need a non-empty list
|
|
, { TestParametersClient_BF::spaceCustomStringGroup, TestParametersClient_BF::spaceCustomBoolGroup } // Trivial values, only need a non-empty list
|
|
#if !defined(US_SDK_S2S)
|
|
, EventsParams()
|
|
, String()
|
|
, DynamicPopulationCustomParams()
|
|
#if defined(US_PRIMARY_STORE_WITHOUT_API)
|
|
, PrimaryStoreParams()
|
|
#endif
|
|
#endif
|
|
);
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
waitForPostLoginCompletion();
|
|
|
|
// Application check
|
|
{
|
|
const auto& requestUrl = requestApplication.getUrl();
|
|
EXPECT_NE(String::npos, requestUrl.findSubstringNoCase("parameterGroups")); // name of the query parameter
|
|
for (const auto& queryParamStandard : ParametersApplicationResources::MAP)
|
|
{
|
|
EXPECT_NE(String::npos, requestUrl.findSubstringNoCase(queryParamStandard.second));
|
|
}
|
|
}
|
|
|
|
// Space check
|
|
{
|
|
const auto& requestUrl = requestSpace.getUrl();
|
|
EXPECT_NE(String::npos, requestUrl.findSubstringNoCase("parameterGroups")); // name of the query parameter
|
|
for (const auto& queryParamStandard : ParametersSpaceResources::MAP)
|
|
{
|
|
EXPECT_NE(String::npos, requestUrl.findSubstringNoCase(queryParamStandard.second));
|
|
}
|
|
}
|
|
}
|
|
|
|
/// @test Checks that groups passed on CreateSession will be sent on the parameters request.
|
|
TEST_F(PARAMETERS_MOCK_NO_LOGIN, LOCAL_CheckRequestForCustomParametersPassedAtCreateSession)
|
|
{
|
|
HttpGet requestApplication(StringUrl(""));
|
|
HttpGet requestSpace(StringUrl(""));
|
|
{
|
|
#if defined(US_SDK_S2S)
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_POST, "/applications/sessions", getMockedLoginResponse());
|
|
#else
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_POST, "profiles/sessions", getMockedLoginResponse());
|
|
#endif
|
|
|
|
const MockAsyncResult applicationMockResult = MockResultHelper::createSuccessResult(
|
|
TestParametersClient_BF::ParametersApplicationWithCustomGroups().getParameters().renderContent());
|
|
|
|
const MockAsyncResult spaceMockResult = MockResultHelper::createSuccessResult(
|
|
TestParametersClient_BF::ParametersSpaceWithCustomGroups().getParameters().renderContent());
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/parameters")
|
|
.WillOnce(testing::DoAll(
|
|
testing::SaveArg<0>(static_cast<HttpRequest*>(&requestApplication)),
|
|
testing::Return(applicationMockResult)))
|
|
.WillOnce(testing::DoAll(
|
|
testing::SaveArg<0>(static_cast<HttpRequest*>(&requestSpace)),
|
|
testing::Return(spaceMockResult)));
|
|
#if !defined(US_SDK_S2S)
|
|
mockPopulationsCalls();
|
|
mockPrimaryStoreCalls();
|
|
#endif
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-config-events")
|
|
.Times(testing::AnyNumber())
|
|
.WillRepeatedly(testing::Return(getMockedLoginResponseEventConfig()));
|
|
setupWebsocketMock();
|
|
}
|
|
|
|
auto result = getFacade().createSession(GET_CREDENTIALS()
|
|
, { TestParametersClient_BF::applicationCustomStringGroup, TestParametersClient_BF::applicationCustomBoolGroup }
|
|
, { TestParametersClient_BF::spaceCustomStringGroup, TestParametersClient_BF::spaceCustomBoolGroup }
|
|
#if !defined(US_SDK_S2S)
|
|
, EventsParams()
|
|
, String()
|
|
, DynamicPopulationCustomParams()
|
|
#if defined(US_PRIMARY_STORE_WITHOUT_API)
|
|
, PrimaryStoreParams()
|
|
#endif
|
|
#endif
|
|
);
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
waitForPostLoginCompletion();
|
|
|
|
// Application check
|
|
{
|
|
const auto& requestUrl = requestApplication.getUrl();
|
|
ASSERT_NE(String::npos, requestUrl.findSubstringNoCase(TestParametersClient_BF::applicationCustomStringGroup));
|
|
ASSERT_NE(String::npos, requestUrl.findSubstringNoCase(TestParametersClient_BF::applicationCustomBoolGroup));
|
|
}
|
|
|
|
// Space check
|
|
{
|
|
const auto& requestUrl = requestSpace.getUrl();
|
|
ASSERT_NE(String::npos, requestUrl.findSubstringNoCase(TestParametersClient_BF::spaceCustomStringGroup));
|
|
ASSERT_NE(String::npos, requestUrl.findSubstringNoCase(TestParametersClient_BF::spaceCustomBoolGroup));
|
|
}
|
|
}
|
|
|
|
/// @test Checks that groups passed on CreateSession for application can be retrieved from the parameters client
|
|
TEST_F(PARAMETERS_MOCK_NO_LOGIN, LOCAL_CheckForCustomApplicationParametersPassedAtCreateSession)
|
|
{
|
|
{
|
|
|
|
const MockAsyncResult applicationMockResult = MockResultHelper::createSuccessResult(
|
|
TestParametersClient_BF::ParametersApplicationWithCustomGroups().getParameters().renderContent());
|
|
|
|
const MockAsyncResult spaceMockResult = MockResultHelper::createSuccessResult(
|
|
TestParametersClient_BF::ParametersSpaceWithCustomGroups().getParameters().renderContent());
|
|
|
|
{
|
|
|
|
mockFullLogin(nullptr, &applicationMockResult, &spaceMockResult);
|
|
}
|
|
}
|
|
|
|
auto result = getFacade().createSession(GET_CREDENTIALS()
|
|
, { TestParametersClient_BF::applicationCustomStringGroup, TestParametersClient_BF::applicationCustomBoolGroup }
|
|
, { TestParametersClient_BF::spaceCustomStringGroup, TestParametersClient_BF::spaceCustomBoolGroup }
|
|
#if !defined(US_SDK_S2S)
|
|
, EventsParams()
|
|
, String()
|
|
, DynamicPopulationCustomParams()
|
|
#if defined(US_PRIMARY_STORE_WITHOUT_API)
|
|
, PrimaryStoreParams()
|
|
#endif
|
|
#endif
|
|
);
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
waitForPostLoginCompletion();
|
|
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
|
|
// Application
|
|
{
|
|
// empty string as a group
|
|
{
|
|
const ParametersGroupInfo& groupInfo = client.getParametersGroupApplication("");
|
|
EXPECT_EQ("{}", groupInfo.m_fields.renderContent());
|
|
}
|
|
|
|
// empty strings as a group
|
|
{
|
|
const Map<String, ParametersGroupInfo>& groups = client.getParametersGroupsApplication({"", ""});
|
|
EXPECT_EQ(0u, groups.size());
|
|
}
|
|
|
|
// non existing group
|
|
{
|
|
const ParametersGroupInfo& groupInfo = client.getParametersGroupApplication("GroupNotFound");
|
|
EXPECT_EQ("{}", groupInfo.m_fields.renderContent());
|
|
}
|
|
|
|
// non existing groups
|
|
{
|
|
const Vector<String> groupNames = { "GroupNotFound1", "GroupNotFound2" };
|
|
const Map<String, ParametersGroupInfo>& groups = client.getParametersGroupsApplication(groupNames);
|
|
EXPECT_EQ(0u, groups.size());
|
|
}
|
|
|
|
// existing group
|
|
{
|
|
{
|
|
const ParametersGroupInfo& groupInfo = client.getParametersGroupApplication(TestParametersClient_BF::applicationCustomStringGroup);
|
|
EXPECT_EQ("applicationString", groupInfo.m_fields["dummyApplicationString"].getValueString());
|
|
}
|
|
{
|
|
const ParametersGroupInfo& groupInfo = client.getParametersGroupApplication(TestParametersClient_BF::applicationCustomBoolGroup);
|
|
EXPECT_FALSE(groupInfo.m_fields["dummyApplicationBool"].getValueBoolean());
|
|
}
|
|
}
|
|
|
|
// existing groups
|
|
{
|
|
const Vector<String> groupNames = { TestParametersClient_BF::applicationCustomStringGroup, TestParametersClient_BF::applicationCustomBoolGroup };
|
|
const Map<String, ParametersGroupInfo>& groups = client.getParametersGroupsApplication(groupNames);
|
|
|
|
EXPECT_EQ(2u, groups.size());
|
|
for (const auto& groupName : groupNames)
|
|
{
|
|
const auto& itGroup = groups.find(groupName);
|
|
EXPECT_TRUE(itGroup != groups.end());
|
|
if (itGroup->first == TestParametersClient_BF::applicationCustomStringGroup)
|
|
{
|
|
EXPECT_EQ("applicationString", itGroup->second.m_fields["dummyApplicationString"].getValueString());
|
|
}
|
|
else if (itGroup->first == TestParametersClient_BF::applicationCustomBoolGroup)
|
|
{
|
|
EXPECT_FALSE(itGroup->second.m_fields["dummyApplicationBool"].getValueBoolean());
|
|
}
|
|
}
|
|
}
|
|
|
|
// Validates that the no group passed as a space parameter is returned by the getParametersGroupApplication
|
|
{
|
|
{
|
|
const ParametersGroupInfo& groupInfo = client.getParametersGroupApplication(TestParametersClient_BF::spaceCustomStringGroup);
|
|
EXPECT_EQ("{}", groupInfo.m_fields.renderContent());
|
|
}
|
|
|
|
{
|
|
const ParametersGroupInfo& groupInfo = client.getParametersGroupApplication(TestParametersClient_BF::spaceCustomBoolGroup);
|
|
EXPECT_EQ("{}", groupInfo.m_fields.renderContent());
|
|
}
|
|
|
|
{
|
|
const Map<String, ParametersGroupInfo>& groups = client.getParametersGroupsApplication({ TestParametersClient_BF::spaceCustomStringGroup,
|
|
TestParametersClient_BF::spaceCustomBoolGroup });
|
|
EXPECT_EQ(0u, groups.size());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// @test Checks that groups passed on CreateSession for space can be retrieved from the parameters client
|
|
TEST_F(PARAMETERS_MOCK_NO_LOGIN, LOCAL_CheckForCustomSpaceParametersPassedAtCreateSession)
|
|
{
|
|
{
|
|
|
|
const MockAsyncResult applicationMockResult = MockResultHelper::createSuccessResult(
|
|
TestParametersClient_BF::ParametersApplicationWithCustomGroups().getParameters().renderContent());
|
|
|
|
const MockAsyncResult spaceMockResult = MockResultHelper::createSuccessResult(
|
|
TestParametersClient_BF::ParametersSpaceWithCustomGroups().getParameters().renderContent());
|
|
|
|
{
|
|
|
|
mockFullLogin(nullptr, &applicationMockResult, &spaceMockResult);
|
|
}
|
|
}
|
|
|
|
auto result = getFacade().createSession(GET_CREDENTIALS()
|
|
, { TestParametersClient_BF::applicationCustomStringGroup, TestParametersClient_BF::applicationCustomBoolGroup }
|
|
, { TestParametersClient_BF::spaceCustomStringGroup, TestParametersClient_BF::spaceCustomBoolGroup }
|
|
#if !defined(US_SDK_S2S)
|
|
, EventsParams()
|
|
, String()
|
|
, DynamicPopulationCustomParams()
|
|
#if defined(US_PRIMARY_STORE_WITHOUT_API)
|
|
, PrimaryStoreParams()
|
|
#endif
|
|
#endif
|
|
);
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
waitForPostLoginCompletion();
|
|
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
|
|
// Space
|
|
{
|
|
// empty string as a group
|
|
{
|
|
const ParametersGroupInfo& groupInfo = client.getParametersGroupSpace("");
|
|
EXPECT_EQ("{}", groupInfo.m_fields.renderContent());
|
|
}
|
|
|
|
// empty strings as a group
|
|
{
|
|
const Map<String, ParametersGroupInfo>& groups = client.getParametersGroupsSpace({ "", "" });
|
|
EXPECT_EQ(0u, groups.size());
|
|
}
|
|
|
|
// non existing group
|
|
{
|
|
const ParametersGroupInfo& groupInfo = client.getParametersGroupSpace("GroupNotFound");
|
|
EXPECT_EQ("{}", groupInfo.m_fields.renderContent());
|
|
}
|
|
|
|
// non existing groups
|
|
{
|
|
const Vector<String> groupNames = { "GroupNotFound1", "GroupNotFound2" };
|
|
const Map<String, ParametersGroupInfo>& groups = client.getParametersGroupsSpace(groupNames);
|
|
EXPECT_EQ(0u, groups.size());
|
|
}
|
|
|
|
// existing group
|
|
{
|
|
{
|
|
const ParametersGroupInfo& groupInfo = client.getParametersGroupSpace(TestParametersClient_BF::spaceCustomStringGroup);
|
|
EXPECT_EQ("spaceString", groupInfo.m_fields["dummySpaceString"].getValueString());
|
|
}
|
|
{
|
|
const ParametersGroupInfo& groupInfo = client.getParametersGroupSpace(TestParametersClient_BF::spaceCustomBoolGroup);
|
|
EXPECT_TRUE(groupInfo.m_fields["dummySpaceBool"].getValueBoolean());
|
|
}
|
|
}
|
|
|
|
// existing groups
|
|
{
|
|
const Vector<String> groupNames = { TestParametersClient_BF::spaceCustomStringGroup,
|
|
TestParametersClient_BF::spaceCustomBoolGroup };
|
|
const Map<String, ParametersGroupInfo>& groups = client.getParametersGroupsSpace(groupNames);
|
|
|
|
EXPECT_EQ(2u, groups.size());
|
|
for (const auto& groupName : groupNames)
|
|
{
|
|
const auto& itGroup = groups.find(groupName);
|
|
EXPECT_TRUE(itGroup != groups.end());
|
|
if (itGroup->first == TestParametersClient_BF::applicationCustomStringGroup)
|
|
{
|
|
EXPECT_EQ("spaceString", itGroup->second.m_fields["dummySpaceString"].getValueString());
|
|
}
|
|
else if (itGroup->first == TestParametersClient_BF::applicationCustomBoolGroup)
|
|
{
|
|
EXPECT_TRUE(itGroup->second.m_fields["dummySpaceBool"].getValueBoolean());
|
|
}
|
|
}
|
|
}
|
|
|
|
// Validates that the no group passed as a application parameter is returned by the getParametersGroupSpace
|
|
{
|
|
{
|
|
const ParametersGroupInfo& groupInfo = client.getParametersGroupSpace(TestParametersClient_BF::applicationCustomStringGroup);
|
|
EXPECT_EQ("{}", groupInfo.m_fields.renderContent());
|
|
}
|
|
|
|
{
|
|
const ParametersGroupInfo& groupInfo = client.getParametersGroupSpace(TestParametersClient_BF::applicationCustomBoolGroup);
|
|
EXPECT_EQ("{}", groupInfo.m_fields.renderContent());
|
|
}
|
|
|
|
{
|
|
const Map<String, ParametersGroupInfo>& groups = client.getParametersGroupsSpace({ TestParametersClient_BF::applicationCustomStringGroup,
|
|
TestParametersClient_BF::applicationCustomBoolGroup });
|
|
EXPECT_EQ(0u, groups.size());
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#define IN_REQUEST true
|
|
#define NOT_IN_REQUEST false
|
|
#define SPACE_PARAMETER false
|
|
|
|
typedef AuthenticationFixtureWithParam<std::vector<TestParametersClient_BF::TestParamGroup>, 1, false>::type PARAMETERS_NOLOGIN_FIXTURE;
|
|
INSTANTIATE_TEST_CASE_P(ParamestersGroupFilterTest, PARAMETERS_NOLOGIN_FIXTURE, ::testing::Values(
|
|
// Test Application Parameter Groups
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup1", "group1TestParamKey", "group1TestParamValue", NOT_IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup2", "group2TestParamKey", "group2TestParamValue", NOT_IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup3", "group3TestParamKey", "group3TestParamValue", NOT_IN_REQUEST)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup1", "group1TestParamKey", "group1TestParamValue", IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup2", "group2TestParamKey", "group2TestParamValue", NOT_IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup3", "group3TestParamKey", "group3TestParamValue", NOT_IN_REQUEST)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup1", "group1TestParamKey", "group1TestParamValue", NOT_IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup2", "group2TestParamKey", "group2TestParamValue", IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup3", "group3TestParamKey", "group3TestParamValue", IN_REQUEST)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup1", "group1TestParamKey", "group1TestParamValue", NOT_IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup2", "group2TestParamKey", "group2TestParamValue", NOT_IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup3", "group3TestParamKey", "group3TestParamValue", IN_REQUEST)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup1", "group1TestParamKey", "group1TestParamValue", IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup2", "group2TestParamKey", "group2TestParamValue", IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup3", "group3TestParamKey", "group3TestParamValue", NOT_IN_REQUEST)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup1", "group1TestParamKey", "group1TestParamValue", NOT_IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup2", "group2TestParamKey", "group2TestParamValue", IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup3", "group3TestParamKey", "group3TestParamValue", IN_REQUEST)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup1", "group1TestParamKey", "group1TestParamValue", IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup2", "group2TestParamKey", "group2TestParamValue", NOT_IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup3", "group3TestParamKey", "group3TestParamValue", IN_REQUEST)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup1", "group1TestParamKey", "group1TestParamValue", IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup2", "group2TestParamKey", "group2TestParamValue", IN_REQUEST),
|
|
TestParametersClient_BF::TestParamGroup("testCustomApplicationParamGroup3", "group3TestParamKey", "group3TestParamValue", IN_REQUEST)
|
|
},
|
|
|
|
// Test Space Parameter Groups
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup1", "group1TestParamKey", "group1TestParamValue", NOT_IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup2", "group2TestParamKey", "group2TestParamValue", NOT_IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup3", "group3TestParamKey", "group3TestParamValue", NOT_IN_REQUEST, SPACE_PARAMETER)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup1", "group1TestParamKey", "group1TestParamValue", IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup2", "group2TestParamKey", "group2TestParamValue", NOT_IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup3", "group3TestParamKey", "group3TestParamValue", NOT_IN_REQUEST, SPACE_PARAMETER)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup1", "group1TestParamKey", "group1TestParamValue", NOT_IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup2", "group2TestParamKey", "group2TestParamValue", IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup3", "group3TestParamKey", "group3TestParamValue", IN_REQUEST, SPACE_PARAMETER)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup1", "group1TestParamKey", "group1TestParamValue", NOT_IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup2", "group2TestParamKey", "group2TestParamValue", NOT_IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup3", "group3TestParamKey", "group3TestParamValue", IN_REQUEST, SPACE_PARAMETER)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup1", "group1TestParamKey", "group1TestParamValue", IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup2", "group2TestParamKey", "group2TestParamValue", IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup3", "group3TestParamKey", "group3TestParamValue", NOT_IN_REQUEST, SPACE_PARAMETER)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup1", "group1TestParamKey", "group1TestParamValue", NOT_IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup2", "group2TestParamKey", "group2TestParamValue", IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup3", "group3TestParamKey", "group3TestParamValue", IN_REQUEST, SPACE_PARAMETER)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup1", "group1TestParamKey", "group1TestParamValue", IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup2", "group2TestParamKey", "group2TestParamValue", NOT_IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup3", "group3TestParamKey", "group3TestParamValue", IN_REQUEST, SPACE_PARAMETER)
|
|
},
|
|
std::vector<TestParametersClient_BF::TestParamGroup> {
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup1", "group1TestParamKey", "group1TestParamValue", IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup2", "group2TestParamKey", "group2TestParamValue", IN_REQUEST, SPACE_PARAMETER),
|
|
TestParametersClient_BF::TestParamGroup("testCustomSpaceParamGroup3", "group3TestParamKey", "group3TestParamValue", IN_REQUEST, SPACE_PARAMETER)
|
|
}
|
|
));
|
|
|
|
// Test checks that the response returns the correct parameters based on the filters provided in the request.
|
|
TEST_P(PARAMETERS_NOLOGIN_FIXTURE, US_TestParametersGroupApplicationFilters)
|
|
{
|
|
struct Local
|
|
{
|
|
// checks request response when single filter is provided.
|
|
static void verifyContentParamGroupSingle(ParametersClient& client,
|
|
const std::vector<TestParametersClient_BF::TestParamGroup>& testParamGroups)
|
|
{
|
|
// loop through all parameter groups in test
|
|
for (const TestParametersClient_BF::TestParamGroup& testParamGroup : testParamGroups)
|
|
{
|
|
ParametersGroupInfo paramGroupResponse;
|
|
if (testParamGroup.m_isApplicationGroup) // case is application parameter group
|
|
{
|
|
paramGroupResponse = client.getParametersGroupApplication(testParamGroup.m_groupName);
|
|
}
|
|
else // case is space parameter group
|
|
{
|
|
paramGroupResponse = client.getParametersGroupSpace(testParamGroup.m_groupName);
|
|
}
|
|
|
|
if (testParamGroup.m_inRequest) // case parameter group passed as filter
|
|
{
|
|
// check response size
|
|
EXPECT_EQ(1, paramGroupResponse.m_fields.getItems().size());
|
|
|
|
// case validate json response
|
|
if (paramGroupResponse.m_fields[testParamGroup.m_paramKey].isValid() &&
|
|
paramGroupResponse.m_fields[testParamGroup.m_paramKey].isTypeString())
|
|
{
|
|
const String actualParamValue = paramGroupResponse.m_fields[testParamGroup.m_paramKey].getValueString();
|
|
EXPECT_EQ(testParamGroup.m_paramValue, actualParamValue); // check value in response
|
|
}
|
|
else
|
|
{
|
|
EXPECT_TRUE(false);
|
|
}
|
|
}
|
|
else // case parameter group not in request.
|
|
{
|
|
// the parameter group is not present in the custom groups returned
|
|
EXPECT_EQ(0, paramGroupResponse.m_fields.getItems().size());
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
// checks request response when a list of filters are provided.
|
|
static void verifyContentParamGroupMultiple(ParametersClient& client,
|
|
const std::vector<TestParametersClient_BF::TestParamGroup>& testParamGroups)
|
|
{
|
|
ASSERT_GT(testParamGroups.size(), 0u);
|
|
bool areApplicationGroups = testParamGroups.at(0).m_isApplicationGroup;
|
|
|
|
// make list string containing parameter group names
|
|
Vector<String> ubiTestParamGroups;
|
|
std::transform(testParamGroups.begin(), testParamGroups.end(), std::back_inserter(ubiTestParamGroups),
|
|
[&](const TestParametersClient_BF::TestParamGroup& paramGroup)
|
|
{
|
|
return paramGroup.m_groupName;
|
|
});
|
|
|
|
ASSERT_GT(ubiTestParamGroups.size(), 0u);
|
|
|
|
Map<String, ParametersGroupInfo> mapParamGroupResponse;
|
|
if (areApplicationGroups) // case application parameter groups
|
|
{
|
|
mapParamGroupResponse = client.getParametersGroupsApplication(ubiTestParamGroups);
|
|
}
|
|
else // case space parameter groups
|
|
{
|
|
mapParamGroupResponse = client.getParametersGroupsSpace(ubiTestParamGroups);
|
|
}
|
|
|
|
for (const auto& testParamGroup : testParamGroups) // loop through all parameter groups in test
|
|
{
|
|
Map<String, ParametersGroupInfo>::const_iterator itParamGroup = mapParamGroupResponse.find(testParamGroup.m_groupName);
|
|
ASSERT_FALSE(testParamGroup.m_inRequest && itParamGroup == mapParamGroupResponse.end()); // check response is not empty
|
|
|
|
if (testParamGroup.m_inRequest) // case param group in request
|
|
{
|
|
// check response size
|
|
EXPECT_EQ(1, itParamGroup->second.m_fields.getItems().size());
|
|
|
|
// case json response valid
|
|
if (itParamGroup->second.m_fields[testParamGroup.m_paramKey].isValid() &&
|
|
itParamGroup->second.m_fields[testParamGroup.m_paramKey].isTypeString())
|
|
{
|
|
const String actualParamValue = itParamGroup->second.m_fields[testParamGroup.m_paramKey].getValueString();
|
|
EXPECT_EQ(testParamGroup.m_paramValue, actualParamValue); // check value in response
|
|
}
|
|
else
|
|
{
|
|
EXPECT_TRUE(false);
|
|
}
|
|
}
|
|
else // case parameter group not in request.
|
|
{
|
|
// the parameter group is not present in the custom groups returned
|
|
EXPECT_TRUE(itParamGroup == mapParamGroupResponse.end());
|
|
}
|
|
}
|
|
}
|
|
|
|
// returns list of application parameter group names
|
|
static const Vector<String> getParametersGroupApplication(const std::vector<TestParametersClient_BF::TestParamGroup>& testParamGroups)
|
|
{
|
|
Vector<String> groups;
|
|
groups.reserve(testParamGroups.size());
|
|
for (const auto& testParamGroup : testParamGroups)
|
|
{
|
|
if (testParamGroup.m_isApplicationGroup && testParamGroup.m_inRequest)
|
|
{
|
|
groups.push_back(testParamGroup.m_groupName);
|
|
}
|
|
}
|
|
return groups;
|
|
}
|
|
|
|
// returns list of space parameter group names
|
|
static const Vector<String> getParametersGroupSpace(const std::vector<TestParametersClient_BF::TestParamGroup>& testParamGroups)
|
|
{
|
|
Vector<String> groups;
|
|
groups.reserve(testParamGroups.size());
|
|
for (const auto& testParamGroup : testParamGroups)
|
|
{
|
|
if (!testParamGroup.m_isApplicationGroup && testParamGroup.m_inRequest)
|
|
{
|
|
groups.push_back(testParamGroup.m_groupName);
|
|
}
|
|
}
|
|
return groups;
|
|
}
|
|
};
|
|
|
|
// get test parameter groups
|
|
const std::vector<TestParametersClient_BF::TestParamGroup>& testParamGroups = this->getParam();
|
|
|
|
// create session
|
|
AsyncResult<Empty> resultCreateSession = getFacade().createSession(GET_CREDENTIALS()
|
|
, Local::getParametersGroupApplication(testParamGroups) // pass application param groups to filter
|
|
, Local::getParametersGroupSpace(testParamGroups) // pass space param groups to filter
|
|
#if !defined(US_SDK_S2S)
|
|
, EventsParams()
|
|
, String()
|
|
, DynamicPopulationCustomParams()
|
|
#if defined(US_PRIMARY_STORE_WITHOUT_API)
|
|
, PrimaryStoreParams()
|
|
#endif
|
|
#endif
|
|
);
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(resultCreateSession));
|
|
|
|
// verify response content
|
|
Local::verifyContentParamGroupSingle(getFacade().getParametersClient(), testParamGroups);
|
|
Local::verifyContentParamGroupMultiple(getFacade().getParametersClient(), testParamGroups);
|
|
}
|
|
|
|
#undef IN_REQUEST
|
|
#undef NOT_IN_REQUEST
|
|
#undef SPACE_PARAMETER
|
|
|
|
// Test check that the url for the get parameters request is properly formated
|
|
TEST_F(PARAMETERS_MOCK_NO_LOGIN, USNOT_TestParametersGroupApplicationFiltersUrl)
|
|
{
|
|
{
|
|
// mock login call
|
|
#if defined(US_SDK_S2S)
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_POST, "/applications/sessions", getMockedLoginResponse());
|
|
#else
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_POST, "profiles/sessions", getMockedLoginResponse());
|
|
#endif
|
|
|
|
// mock application parameter call
|
|
#if defined(US_SDK_S2S)
|
|
String urlAppParams("/parameters?parameterGroups=us-staging,us-sdkServerUrlsPlaceholders,TestCustomAppParamGroup1,TestCustomAppParamGroup2");
|
|
#else
|
|
String urlAppParams("/parameters?parameterGroups=");
|
|
urlAppParams += "us-staging";
|
|
urlAppParams += ",us-sdkClientUrlsPlaceholders";
|
|
urlAppParams += ",us-sdkClientClub";
|
|
urlAppParams += ",us-sdkClientFeaturesSwitches";
|
|
urlAppParams += ",us-sdkClientLogin";
|
|
urlAppParams += ",us-sdkClientUrls";
|
|
urlAppParams += ",us-sdkClientChina";
|
|
urlAppParams += ",TestCustomAppParamGroup1";
|
|
urlAppParams += ",TestCustomAppParamGroup2";
|
|
#endif
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, urlAppParams)
|
|
.WillOnce(testing::Return(MockResultHelper::createSuccessResult(ParametersApplicationMockHelper().getParameters().renderContent())));
|
|
|
|
// mock space parameter call
|
|
#if defined(US_SDK_S2S)
|
|
String urlSpaceParams = "/parameters?parameterGroups=us-sdkServerFeaturesSwitches,us-sdkServerRemoteLogsGame,"
|
|
"us-sdkServerSettings,us-sdkServerSettingsHttpGame,us-sdkServerSettingsHttpInternal,"
|
|
"us-sdkServerUrls,TestCustomSpaceParamGroup1,TestCustomSpaceParamGroup2";
|
|
#else
|
|
String urlSpaceParams = "/parameters?parameterGroups=us-sdkClientFeaturesSwitches,us-sdkClientRemoteLogsGame,"
|
|
"us-sdkClientSettings,us-sdkClientSettingsHttpGame,us-sdkClientSettingsHttpInternal,us-sdkClientUrls,"
|
|
"us-sdkClientRemoteLogsInternal,us-sdkClientNotificationsGame,us-sdkClientNotificationsInternal,us-sdkClientNotificationsSpaceIds,us-override,us-sdkClientSettingsCacheTTL,us-sdkClientSettingsSecondaryStoreSync,"
|
|
"us-sdkClientStorm,us-sdkClientSettingsWebSocketGame,us-sdkClientSettingsWebSocketInternal,"
|
|
"TestCustomSpaceParamGroup1,TestCustomSpaceParamGroup2";
|
|
#endif
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, urlSpaceParams)
|
|
.WillOnce(testing::Return(MockResultHelper::createSuccessResult(ParametersSpaceMockHelper().getParameters().renderContent())));
|
|
|
|
#if !defined(US_SDK_S2S)
|
|
mockPopulationsCalls();
|
|
mockPrimaryStoreCalls();
|
|
#endif
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-config-events")
|
|
.Times(testing::AnyNumber())
|
|
.WillRepeatedly(testing::Return(getMockedLoginResponseEventConfig()));
|
|
setupWebsocketMock();
|
|
}
|
|
|
|
const Vector<String> appParamGroups{ "TestCustomAppParamGroup1", "TestCustomAppParamGroup2" };
|
|
const Vector<String> spaceParamGroups{ "TestCustomSpaceParamGroup1", "TestCustomSpaceParamGroup2" };
|
|
|
|
// create session
|
|
AsyncResult<Empty> resultCreateSession = getFacade().createSession(GET_CREDENTIALS()
|
|
, appParamGroups // pass application param groups to filter
|
|
, spaceParamGroups // pass space param groups to filter
|
|
#if !defined(US_SDK_S2S)
|
|
, EventsParams()
|
|
, String()
|
|
, DynamicPopulationCustomParams()
|
|
#if defined(US_PRIMARY_STORE_WITHOUT_API)
|
|
, PrimaryStoreParams()
|
|
#endif
|
|
#endif
|
|
);
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(resultCreateSession));
|
|
|
|
waitForPostLoginCompletion();
|
|
}
|
|
|
|
#if !defined(US_SDK_S2S)
|
|
/// @test Validate Parameters related populations
|
|
TEST_F(PARAMETERS_MOCK_LOGIN, USNOT_ValidateParametersRelatedPopulations)
|
|
{
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
|
|
const StringKeyMap<String> relatedPopulations(client.getUsRelatedPopulations());
|
|
ASSERT_EQ(1u, relatedPopulations.size());
|
|
{
|
|
StringKeyMap<String>::const_iterator it = relatedPopulations.find("Stage");
|
|
ASSERT_TRUE(it != relatedPopulations.end());
|
|
EXPECT_EQ("Dev", it->second);
|
|
}
|
|
}
|
|
|
|
/// @test Performs sanity test.
|
|
TEST_F(PARAMETERS, US_MINRUN_BasicParameters)
|
|
{
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
EXPECT_TRUE(client.getClubServicesUrl("MovieBaseUrl").isEmpty());
|
|
EXPECT_TRUE(client.getClubServicesUrl("baseUrl").isEmpty());
|
|
EXPECT_FALSE(client.getClubServicesUrl("dynamicPanelUrl").isEmpty());
|
|
EXPECT_FALSE(client.getStormUrl("detectUrl2").isEmpty());
|
|
}
|
|
|
|
/// @test Performs sanity test.
|
|
TEST_F(PARAMETERS_MOCK_LOGIN, USNOT_ParametersContent)
|
|
{
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
EXPECT_TRUE(client.getUsStagingSpaceId().isValid());
|
|
|
|
#if !defined(US_SDK_S2S)
|
|
EXPECT_TRUE(client.getClubServicesUrl("DownloadServiceUrl").isEmpty());
|
|
EXPECT_FALSE(client.getClubServicesUrl("dynamicPanelUrl").isEmpty());
|
|
EXPECT_TRUE(client.getClubServicesUrl("dummy").isEmpty());
|
|
#endif
|
|
}
|
|
#endif //!US_SDK_S2S
|
|
|
|
/// @test Validates that requestConfig correctly handles sandbox invalid configuration settings
|
|
TEST_F(PARAMETERS_MOCK_NO_LOGIN, USNOT_SandboxError)
|
|
{
|
|
// Performs a mocked login.
|
|
{
|
|
class InvalidParametersSpaceMockHelper : public ParametersSpaceMockHelper
|
|
{
|
|
private:
|
|
Json buildUrlsParameterGroup() const override
|
|
{
|
|
Vector<Json> groupJson = ParametersSpaceMockHelper::buildUrlsParameterGroup().getItems();
|
|
for (const auto& group : groupJson)
|
|
{
|
|
#if defined(US_SDK_S2S)
|
|
if (group.getKey() == "noPopulation")
|
|
#else
|
|
if (group.getKey() == "fields")
|
|
#endif
|
|
{
|
|
JsonWriter fields(group);
|
|
fields["SandboxWithoutUrl"] = "NotUrl";
|
|
fields["SandboxWithoutFriendlyName"] = "prudp:/address=lb-rdv-uat02.ubisoft.com;port=28200;serviceid=UP0001-NPUB90483_00";
|
|
return renderParameterGroup(fields.getJson());
|
|
}
|
|
}
|
|
return Json();
|
|
}
|
|
};
|
|
|
|
const MockAsyncResult parametersSpaceResult = MockResultHelper::createSuccessResult(
|
|
InvalidParametersSpaceMockHelper().getParameters().renderContent());
|
|
|
|
const MockAsyncResult parametersApplicationResult = getMockedParametersApplication();
|
|
|
|
::testing::Sequence s;
|
|
mockFullLogin(NULL, ¶metersApplicationResult, ¶metersSpaceResult);
|
|
}
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(getFacade().createSession(GET_CREDENTIALS(), {}, {})));
|
|
ASSERT_TRUE(US_TEST_NS::Helper::waitForWebsocketInit(getFacade()));
|
|
}
|
|
|
|
/// @test Validates that a extra config field does not result in an error
|
|
TEST_F(PARAMETERS_MOCK_NO_LOGIN, USNOT_ParametersExtraFieldJSON)
|
|
{
|
|
{
|
|
#if defined(US_SDK_S2S)
|
|
const String json = getMockedParametersApplication().getResult().getBodyAsString().replace(
|
|
"\"us-sdkServerUrls\":{\"revision\":0,\"noPopulation\":{\"populations\":\"/profiles/me/mock-populations\"}}",
|
|
"\"us-sdkServerUrls\":{\"revision\":0,\"noPopulation\":{\"populations\":\"/profiles/me/mock-populations\",\"ExtraField1\":\"toto\",\"ExtraField2\":\"blabla\"}}"
|
|
);
|
|
#else
|
|
const String json = getMockedParametersApplication().getResult().getBodyAsString().replace(
|
|
"\"us-sdkClientUrls\":{\"relatedPopulation\":{\"name\":\"Dev\",\"subject\":\"Stage\"},\"fields\":{\"populations\":\"/profiles/me/mock-populations\"}}",
|
|
"\"us-sdkClientUrls\":{\"relatedPopulation\":{\"name\":\"Dev\",\"subject\":\"Stage\"},\"fields\":{\"populations\":\"/profiles/me/mock-populations\",\"ExtraField1\":\"toto\",\"ExtraField2\":\"blabla\"}}"
|
|
);
|
|
#endif
|
|
const MockAsyncResult parametersApplicationExtraFields = MockResultHelper::createSuccessResult(json);
|
|
|
|
|
|
const MockAsyncResult loginResult = getMockedLoginResponseNoUbiAccount();
|
|
::testing::Sequence s;
|
|
mockFullLogin(&loginResult, ¶metersApplicationExtraFields);
|
|
}
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(getFacade().createSession(GET_CREDENTIALS(), {}, {})));
|
|
ASSERT_TRUE(US_TEST_NS::Helper::waitForWebsocketInit(getFacade()));
|
|
}
|
|
|
|
/// @test Validates that the UrlsPlaceholders from the Application Parameters are replaced in the URLs
|
|
/// @note Need to be in Uat to work
|
|
TEST_F(PARAMETERS_MOCK_NO_LOGIN, USNOT_ParametersUrlPlaceholdersMocked)
|
|
{
|
|
{
|
|
JsonWriter baseUrlsAppli;
|
|
baseUrlsAppli["msr"] = "{baseurl_msr}/{version}/profiles/applications";
|
|
baseUrlsAppli["aws"] = "{baseurl_aws}/{version}/profiles/{profileId}/inventory";
|
|
baseUrlsAppli["ws"] = "{baseurl_ws}/{version}/websocket";
|
|
const MockAsyncResult parametersApplication = MockResultHelper::createSuccessResult(
|
|
TestUrlsPlaceholders_BF::getApplicationMockedParams(baseUrlsAppli.getJson()).renderContent());
|
|
|
|
#if defined(US_SDK_S2S)
|
|
JsonWriter baseUrlsSpace;
|
|
baseUrlsSpace["msr"] = "{baseurl_msr}/{version}/profiles/applications";
|
|
baseUrlsSpace["aws"] = "{baseurl_aws}/{version}/profiles/{profileId}/inventory";
|
|
const MockAsyncResult parametersSpace = MockResultHelper::createSuccessResult(
|
|
TestUrlsPlaceholders_BF::getSpaceMockedParams(baseUrlsSpace.getJson()).renderContent());
|
|
|
|
mockFullLogin(nullptr, ¶metersApplication, ¶metersSpace);
|
|
#else
|
|
mockFullLogin(nullptr, ¶metersApplication);
|
|
#endif
|
|
}
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(getFacade().createSession(GET_CREDENTIALS(), {}, {})));
|
|
|
|
// Check that the placeholders have been replaced
|
|
#if defined(US_SDK_S2S)
|
|
EXPECT_EQ("https://uat-s2s-ubiservices.ubi.com/v1/profiles/applications", getFacade().getParametersClient().getResourceUrl("msr", 1));
|
|
EXPECT_EQ("https://ue1-uat-s2s-ubiservices.ubi.com/v1/profiles/{profileId}/inventory", getFacade().getParametersClient().getResourceUrl("aws", 1));
|
|
#else
|
|
EXPECT_EQ("https://msr-uat-public-ubiservices.ubi.com/v1/profiles/applications", getFacade().getParametersClient().getResourceUrl("msr", 1));
|
|
EXPECT_EQ("https://uat-public-ubiservices.ubi.com/v1/profiles/{profileId}/inventory", getFacade().getParametersClient().getResourceUrl("aws", 1));
|
|
EXPECT_EQ("wss://uat-public-ws-ubiservices.ubi.com/v1/websocket", getFacade().getParametersClient().getResourceUrl("ws", 1));
|
|
#endif
|
|
}
|
|
|
|
/// @test Validates we can retrieve Application parameters from another ApplicationId
|
|
TEST_F(PARAMETERS, US_RequestApplicationParameters)
|
|
{
|
|
const ApplicationId appId(TestParametersClient_BF::APPLICATION_ID_US_SDK_SPECIAL_TESTS_PC);
|
|
const Vector<String> parametersGroupsNames = { "otherParameters" };
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = getFacade().getParametersClient().requestParametersGroupsApplication(appId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
|
|
TestParametersClient_BF::validateRequestParametersResponse(result.getResult(), "app", 1);
|
|
}
|
|
|
|
/// @test Validates call works with the game default ApplicationId
|
|
TEST_F(PARAMETERS, US_RequestApplicationParametersUsingGameAppId)
|
|
{
|
|
const ApplicationId appId(InstancesManager::getInstance()->getApplicationId());
|
|
const Vector<String> parametersGroupsNames = { "us-sdkClientUrls" };
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = getFacade().getParametersClient().requestParametersGroupsApplication(appId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
EXPECT_TRUE(result.getResult().size() == 1);
|
|
}
|
|
|
|
/// @test Validates we get an error when passing empty group name list
|
|
TEST_F(PARAMETERS, US_RequestApplicationParametersErrorEmptyParamGroupNameList)
|
|
{
|
|
const ApplicationId appId(InstancesManager::getInstance()->getApplicationId());
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = getFacade().getParametersClient().requestParametersGroupsApplication(appId, {});
|
|
EXPECT_TRUE(AsyncHelper::waitFailure(result, Errors::PARAMETERS_INVALID_PARAMS));
|
|
}
|
|
|
|
#if !defined(US_SDK_S2S)
|
|
/// @test Validate the ParametersApplicationCache is working as expected
|
|
TEST_F(PARAMETERS_MOCK, USNOT_ValidateParametersApplicationCache)
|
|
{
|
|
// Could be any dummy ApplicationID
|
|
const ApplicationId appId("10101010-2222-3333-4444-101010101010");
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-parameters")
|
|
.WillOnce(testing::Return(MockResultHelper::createSuccessResult(
|
|
"{\"parameters\":{\"otherParameters\":{\"fields\":{\"appParameter2\":\"appValue2\",\"appParameter1\":\"appValue1\"},\"relatedPopulation\":null}}}")));
|
|
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
|
|
{ // The first call generates a server request.
|
|
const Vector<String> parametersGroupsNames = { "otherParameters" };
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsApplication(appId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
|
|
TestParametersClient_BF::validateRequestParametersResponse(result.getResult(), "app", 1);
|
|
}
|
|
|
|
{ // The second call only involves the cache (and therefore, the result is the same!)
|
|
const Vector<String> parametersGroupsNames = { "otherParameters" };
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsApplication(appId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
|
|
TestParametersClient_BF::validateRequestParametersResponse(result.getResult(), "app", 1);
|
|
}
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-parameters")
|
|
.WillOnce(testing::Return(MockResultHelper::createSuccessResult(
|
|
"{\"parameters\":{\"otherParameters\":{\"fields\":{\"appParameter11\":\"appValue11\",\"appParameter10\":\"appValue10\"},\"relatedPopulation\":null}}}")));
|
|
|
|
{ // The third call, using another appId, generates a server request.
|
|
const ApplicationId appIdNew("10101010-2222-3333-4444-FFFFFFFFFFFF");
|
|
const Vector<String> parametersGroupsNames = { "otherParameters" };
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsApplication(
|
|
appIdNew, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
|
|
TestParametersClient_BF::validateRequestParametersResponse(result.getResult(), "app", 10);
|
|
}
|
|
|
|
ParametersClientProxy::invalidateCache(client, CacheUnit::ParametersApplication);
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-parameters")
|
|
.WillOnce(testing::Return(MockResultHelper::createSuccessResult(
|
|
"{\"parameters\":{\"otherParameters\":{\"fields\":{\"appParameter4\":\"appValue4\",\"appParameter3\":\"appValue3\"},\"relatedPopulation\":null}}}")));
|
|
|
|
{ // The fourth call generates a server request.
|
|
const Vector<String> parametersGroupsNames = { "otherParameters" };
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsApplication(appId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
|
|
TestParametersClient_BF::validateRequestParametersResponse(result.getResult(), "app", 3);
|
|
}
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-parameters")
|
|
.WillOnce(testing::Return(MockResultHelper::createSuccessResult(
|
|
"{\"parameters\":{\"otherParameters\":{\"fields\":{\"appParameter2\":\"appValue2\",\"appParameter1\":\"appValue1\"},\"relatedPopulation\":null},\"extraParameters\":{\"fields\":{\"appParameter4\":\"appValue4\",\"appParameter3\":\"appValue3\"},\"relatedPopulation\":null}}}")));
|
|
|
|
{ // Call generates a server request because requesting different parameters
|
|
const Vector<String> parametersGroupsNames = { "otherParameters", "extraParameters" };
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsApplication(appId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
EXPECT_EQ(2, result.getResult().size());
|
|
}
|
|
|
|
{ // Another call with same AppId and groups uses the cache
|
|
const Vector<String> parametersGroupsNames = { "otherParameters", "extraParameters" };
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsApplication(appId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
EXPECT_EQ(2, result.getResult().size());
|
|
}
|
|
}
|
|
#endif
|
|
|
|
/// @test Validates we can retrieve Space parameters from another SpaceId
|
|
TEST_F(PARAMETERS, US_RequestSpaceParameters)
|
|
{
|
|
const SpaceId spaceId(TestParametersClient_BF::SPACE_ID_US_SDK_SPECIAL_TESTS_PC);
|
|
const Vector<String> parametersGroupsNames = { "otherParameters" };
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = getFacade().getParametersClient().requestParametersGroupsSpace(spaceId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
|
|
TestParametersClient_BF::validateRequestParametersResponse(result.getResult(), "space", 1);
|
|
}
|
|
|
|
/// @test Validate call succeed with game staging SpaceId
|
|
TEST_F(PARAMETERS, US_RequestSpaceParametersUsingGameSpaceId)
|
|
{
|
|
const SpaceId spaceId(getFacade().getWorkingSpaceId());
|
|
const Vector<String> parametersGroupsNames = { "us-sdkClientUrls" };
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = getFacade().getParametersClient().requestParametersGroupsSpace(spaceId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
EXPECT_TRUE(result.getResult().size() == 1);
|
|
}
|
|
|
|
#if !defined(US_SDK_S2S)
|
|
/// @test Validates we get the right parameters from a Populations aware SpaceId
|
|
TEST_F(PARAMETERS, US_RequestSpaceParametersProvidingPopulations)
|
|
{
|
|
// Same SpaceId use to validate Dynamic Population
|
|
const char* UBISERVICES_STAGING_TEST_PC_RETAIL_SPACEID = "42b384a0-371d-4356-8829-aea05e378819";
|
|
|
|
const SpaceId spaceId(UBISERVICES_STAGING_TEST_PC_RETAIL_SPACEID);
|
|
const Vector<String> parametersGroupsNames = { "sdkTestResources" };
|
|
|
|
Map<String, String> subjectPopulationList;
|
|
subjectPopulationList["PlayerLevel"] = "Intermediate"; // This subject-population defines the inWhichPopIAm value below
|
|
subjectPopulationList["SeasonPassOneOwner"] = "SeasonPassOnePopulation";
|
|
subjectPopulationList["SeasonPassTwoOwner"] = "defaultPopulation";
|
|
subjectPopulationList["Stage"] = "Retail";
|
|
subjectPopulationList["RemoteLogs"] = "None";
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = getFacade().getParametersClient().requestParametersGroupsSpace(
|
|
spaceId, parametersGroupsNames, subjectPopulationList);
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
|
|
const auto groups = result.getResult();
|
|
const auto& itGroup = groups.find("sdkTestResources");
|
|
ASSERT_TRUE(itGroup != groups.end());
|
|
EXPECT_EQ("Intermediate", itGroup->second.m_fields["inWhichPopIAm"].getValueString());
|
|
}
|
|
#endif
|
|
|
|
/// @test Validates we can retrieve Space parameters from another SpaceId
|
|
TEST_F(PARAMETERS, US_RequestSpaceParametersErrorEmptyParamGroupNameList)
|
|
{
|
|
const SpaceId spaceId(TestParametersClient_BF::SPACE_ID_US_SDK_SPECIAL_TESTS_PC);
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = getFacade().getParametersClient().requestParametersGroupsSpace(spaceId, {});
|
|
EXPECT_TRUE(AsyncHelper::waitFailure(result, Errors::PARAMETERS_INVALID_PARAMS));
|
|
}
|
|
|
|
#if !defined(US_SDK_S2S)
|
|
/// @test Validate the ParametersSpaceCache is working as expected
|
|
TEST_F(PARAMETERS_MOCK, USNOT_ValidateParametersSpaceCache)
|
|
{
|
|
HttpGet request(StringUrl(""));
|
|
|
|
// Could be any dummy SpaceID
|
|
const SpaceId spaceId("20202020-2222-3333-4444-202020202020");
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-parameters")
|
|
.WillOnce(testing::Return(MockResultHelper::createSuccessResult(
|
|
"{\"parameters\":{\"otherParameters\":{\"fields\":{\"spaceParameter2\":\"spaceValue2\",\"spaceParameter1\":\"spaceValue1\"},\"relatedPopulation\":null}}}")));
|
|
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
|
|
{ // The first call generates a server request.
|
|
const Vector<String> parametersGroupsNames = { "otherParameters" };
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsSpace(spaceId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
|
|
TestParametersClient_BF::validateRequestParametersResponse(result.getResult(), "space", 1);
|
|
}
|
|
|
|
{ // The second call only involves the cache (and therefore, the result is the same!)
|
|
const Vector<String> parametersGroupsNames = { "otherParameters" };
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsSpace(spaceId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
|
|
TestParametersClient_BF::validateRequestParametersResponse(result.getResult(), "space", 1);
|
|
}
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-parameters")
|
|
.WillOnce(testing::Return(MockResultHelper::createSuccessResult(
|
|
"{\"parameters\":{\"otherParameters\":{\"fields\":{\"spaceParameter11\":\"spaceValue11\",\"spaceParameter10\":\"spaceValue10\"},\"relatedPopulation\":null}}}")));
|
|
|
|
{ // The third call, on another SpaceId, generates a server request.
|
|
const SpaceId spaceIdNew("20202020-2222-3333-4444-FFFFFFFFFFFF");
|
|
const Vector<String> parametersGroupsNames = { "otherParameters" };
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsSpace(spaceIdNew, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
|
|
TestParametersClient_BF::validateRequestParametersResponse(result.getResult(), "space", 10);
|
|
}
|
|
|
|
ParametersClientProxy::invalidateCache(client, CacheUnit::ParametersSpace);
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-parameters")
|
|
.WillOnce(testing::Return(MockResultHelper::createSuccessResult(
|
|
"{\"parameters\":{\"otherParameters\":{\"fields\":{\"spaceParameter4\":\"spaceValue4\",\"spaceParameter3\":\"spaceValue3\"},\"relatedPopulation\":null}}}")));
|
|
|
|
{ // Call generates a server request after cache was cleared
|
|
const Vector<String> parametersGroupsNames = { "otherParameters" };
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsSpace(spaceId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
|
|
TestParametersClient_BF::validateRequestParametersResponse(result.getResult(), "space", 3);
|
|
}
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-parameters")
|
|
.WillOnce(testing::Return(MockResultHelper::createSuccessResult(
|
|
"{\"parameters\":{\"otherParameters\":{\"fields\":{\"spaceParameter2\":\"appValue2\",\"spaceParameter1\":\"appValue1\"},\"relatedPopulation\":null},\"extraParameters\":{\"fields\":{\"spaceParameter4\":\"appValue4\",\"spaceParameter3\":\"appValue3\"},\"relatedPopulation\":null}}}")));
|
|
|
|
{ // Call generates a server request because requesting different parameters
|
|
const Vector<String> parametersGroupsNames = { "otherParameters", "extraParameters" };
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsSpace(spaceId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
EXPECT_EQ(2, result.getResult().size());
|
|
}
|
|
|
|
{ // Another call with same SpaceId and groups uses the cache
|
|
const Vector<String> parametersGroupsNames = { "otherParameters", "extraParameters" };
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsSpace(spaceId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
EXPECT_EQ(2, result.getResult().size());
|
|
}
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-parameters")
|
|
.WillOnce(testing::Return(MockResultHelper::createSuccessResult(
|
|
"{\"parameters\":{\"otherParameters\":{\"fields\":{\"spaceParameter2\":\"appValue2\",\"spaceParameter1\":\"appValue1\"},\"relatedPopulation\":null},\"extraParameters\":{\"fields\":{\"spaceParameter4\":\"appValue4\",\"spaceParameter3\":\"appValue3\"},\"relatedPopulation\":null}}}")));
|
|
|
|
{ // Call generates a server request because providing populations
|
|
const Vector<String> parametersGroupsNames = { "otherParameters", "extraParameters" };
|
|
|
|
Map<String, String> subjectPopulationList;
|
|
subjectPopulationList["PlayerLevel"] = "Intermediate";
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsSpace(spaceId, parametersGroupsNames, subjectPopulationList);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
EXPECT_EQ(2, result.getResult().size());
|
|
}
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-parameters")
|
|
.WillOnce(testing::Return(MockResultHelper::createSuccessResult(
|
|
"{\"parameters\":{\"otherParameters\":{\"fields\":{\"spaceParameter2\":\"appValue2\",\"spaceParameter1\":\"appValue1\"},\"relatedPopulation\":null},\"extraParameters\":{\"fields\":{\"spaceParameter4\":\"appValue4\",\"spaceParameter3\":\"appValue3\"},\"relatedPopulation\":null}}}")));
|
|
|
|
{ // Call generates a server request because population changed
|
|
const Vector<String> parametersGroupsNames = { "otherParameters", "extraParameters" };
|
|
|
|
Map<String, String> subjectPopulationList;
|
|
subjectPopulationList["PlayerLevel"] = "Pro";
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsSpace(spaceId, parametersGroupsNames, subjectPopulationList);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
EXPECT_EQ(2, result.getResult().size());
|
|
}
|
|
}
|
|
|
|
/// @test Validate the Ubi-Populations header content when Populations are provided in Request Parameters
|
|
TEST_F(PARAMETERS_MOCK, USNOT_ValidateRequestSpaceParamUbiPopulationsHeader)
|
|
{
|
|
HttpGet request(StringUrl(""));
|
|
|
|
// Could be any dummy SpaceID
|
|
const SpaceId spaceId("20202020-2222-3333-4444-202020202020");
|
|
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-parameters")
|
|
.WillOnce(testing::DoAll(testing::SaveArg<0>(static_cast<HttpRequest*>(&request)), testing::Return(MockResultHelper::createSuccessResult(
|
|
"{\"parameters\":{\"otherParameters\":{\"fields\":{\"spaceParameter2\":\"appValue2\",\"spaceParameter1\":\"appValue1\"},\"relatedPopulation\":null},\"extraParameters\":{\"fields\":{\"spaceParameter4\":\"appValue4\",\"spaceParameter3\":\"appValue3\"},\"relatedPopulation\":null}}}"))));
|
|
|
|
{ // Validate population in header
|
|
const Vector<String> parametersGroupsNames = { "otherParameters", "extraParameters" };
|
|
|
|
Map<String, String> subjectPopulationList;
|
|
subjectPopulationList["PlayerLevel"] = "Intermediate";
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsSpace(spaceId, parametersGroupsNames, subjectPopulationList);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
EXPECT_EQ(2, result.getResult().size());
|
|
|
|
EXPECT_STREQ("PlayerLevel.Intermediate", request.getHeader("Ubi-Populations").getUtf8());
|
|
}
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-parameters")
|
|
.WillOnce(testing::DoAll(testing::SaveArg<0>(static_cast<HttpRequest*>(&request)), testing::Return(MockResultHelper::createSuccessResult(
|
|
"{\"parameters\":{\"otherParameters\":{\"fields\":{\"spaceParameter2\":\"appValue2\",\"spaceParameter1\":\"appValue1\"},\"relatedPopulation\":null},\"extraParameters\":{\"fields\":{\"spaceParameter4\":\"appValue4\",\"spaceParameter3\":\"appValue3\"},\"relatedPopulation\":null}}}"))));
|
|
|
|
{ // Validate population in header
|
|
const Vector<String> parametersGroupsNames = { "otherParameters", "extraParameters" };
|
|
|
|
Map<String, String> subjectPopulationList;
|
|
subjectPopulationList["PlayerLevel"] = "Pro";
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsSpace(spaceId, parametersGroupsNames, subjectPopulationList);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
EXPECT_EQ(2, result.getResult().size());
|
|
|
|
EXPECT_STREQ("PlayerLevel.Pro", request.getHeader("Ubi-Populations").getUtf8());
|
|
}
|
|
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/mock-parameters")
|
|
.WillOnce(testing::DoAll(testing::SaveArg<0>(static_cast<HttpRequest*>(&request)), testing::Return(MockResultHelper::createSuccessResult(
|
|
"{\"parameters\":{\"otherParameters\":{\"fields\":{\"spaceParameter2\":\"appValue2\",\"spaceParameter1\":\"appValue1\"},\"relatedPopulation\":null},\"extraParameters\":{\"fields\":{\"spaceParameter4\":\"appValue4\",\"spaceParameter3\":\"appValue3\"},\"relatedPopulation\":null}}}"))));
|
|
|
|
{ // Validate population in header is US_EMPTY_VALUE since we didn't provide any population
|
|
const Vector<String> parametersGroupsNames = { "otherParameters", "extraParameters" };
|
|
|
|
const AsyncResult<Map<String, ParametersGroupInfo>> result = client.requestParametersGroupsSpace(spaceId, parametersGroupsNames);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
EXPECT_EQ(2, result.getResult().size());
|
|
|
|
EXPECT_STREQ("US_EMPTY_VALUE", request.getHeader("Ubi-Populations").getUtf8());
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#if !defined(US_SDK_S2S) && defined(US_TARGET_WINDOWS) && defined(US_SDK_TEST_CHINA) // Windows is our only target for China
|
|
/// @disabled uplaycn platformtype is currently not supported by the service. JIRA US-16595 to reenable it.
|
|
TEST_F(PARAMETERS_NO_INIT, US_ParametersUrlPlaceholdersChina)
|
|
{
|
|
const US_TEST_NS::ScopedInit autoInit;
|
|
|
|
configureSdk(GameConfig(
|
|
ApplicationId("586cc2e2-29c0-4522-8626-a1159939abe4"), //UbiServices SDK PC China Retail
|
|
String("CHINA_IS_PROD")
|
|
, OnlineAccessContext::China
|
|
, GameConfigEvent(US_SDK_VERSION_CONST_CHAR, US_TEST_NS::US_SDK_DUMMY_GAME_SKU, Vector<EventTypeInfo>(), StringJson("{}"),
|
|
NS_COMMON::Options::getApplicationSecretKey().c_str())
|
|
));
|
|
|
|
Facade facade;
|
|
// Perform the login
|
|
const String sessionRailId(US_TEST_NS::WEGAME_SESSION_ID);
|
|
const US_NS::String playerRailId(US_TEST_NS::WEGAME_PROFILE_RAIL_ID);
|
|
const String gameRailId(US_TEST_NS::WEGAME_GAME_RAIL_ID);
|
|
|
|
const US_NS::String weGameToken(US_NS::CredentialsTypeHelper::getWeGameToken(sessionRailId, playerRailId, gameRailId));
|
|
|
|
const PlayerCredentials credentials(weGameToken, US_NS::CredentialsType::WeGame, playerRailId);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(credentials, {}, {})));
|
|
// No environment in the URL because with China we are redirected in Prod
|
|
EXPECT_EQ("https://public-ubiservices.ubisoft.cn/v1/testBaseUrl", facade.getParametersClient().getResourceUrl("testBaseUrl", 1));
|
|
}
|
|
#endif //!US_SDK_S2S && US_TARGET_WINDOWS && US_SDK_TEST_CHINA
|
|
|
|
/// @test validates that extra fields on he parameters's json response does not break the parameters flow.
|
|
TEST_F(PARAMETERS_MOCK_NO_LOGIN, USNOT_ConfigWithModifiedResponseForForwardCompatibility)
|
|
{
|
|
{
|
|
const String json = getMockedParametersApplication().getResult().getBodyAsString().replace(
|
|
"\"parameters\"",
|
|
"\"before\":true, \"parameters\"")
|
|
.replace("}}}}", "}}}, \"other\": 5}")
|
|
.replace("\"us-staging\":{", "\"us-staging\":{\"uselessArray\":[1,2,3,4,5], ");
|
|
|
|
const MockAsyncResult parametersApplicationResult = MockResultHelper::createSuccessResult(json);
|
|
const MockAsyncResult loginResult = getMockedLoginResponseNoUbiAccount();
|
|
::testing::Sequence s;
|
|
mockFullLogin(&loginResult, ¶metersApplicationResult);
|
|
}
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(getFacade().createSession(GET_CREDENTIALS(), {}, {})));
|
|
ASSERT_TRUE(US_TEST_NS::Helper::waitForWebsocketInit(getFacade()));
|
|
}
|
|
|
|
#if !defined(US_RETAIL) && !defined(US_DLL) && !defined(US_TARGET_ANDROID) // Assertions are not defined in retail
|
|
TEST_F(PARAMETERS_MOCK_NO_LOGIN, USNOT_ParametersAccessBeforeCreateSessionIsComplete)
|
|
{
|
|
struct Local
|
|
{
|
|
bool m_configSessionStarted;
|
|
AsyncResult<HttpResponse> setConfigPending()
|
|
{
|
|
m_configSessionStarted = true;
|
|
return MockResultHelper::createPendingResult();
|
|
}
|
|
|
|
bool isConfigSessionStarted() const
|
|
{
|
|
return m_configSessionStarted;
|
|
}
|
|
};
|
|
|
|
Local testLocal;
|
|
testLocal.m_configSessionStarted = false;
|
|
|
|
{
|
|
// Mock the login, block on parameters
|
|
#if defined(US_SDK_S2S)
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_POST, "/applications/sessions", getMockedLoginResponse());
|
|
#else
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_POST, "profiles/sessions", getMockedLoginResponse());
|
|
#endif
|
|
US_EXPECT_CALL_HTTP(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "/parameters")
|
|
.WillRepeatedly(testing::InvokeWithoutArgs(&testLocal, &Local::setConfigPending));
|
|
}
|
|
|
|
const AsyncResult<Empty> resultLogin = getFacade().createSession(GET_CREDENTIALS(), {}, {});
|
|
// DEFAULT_WAIT_TIME since There might be delays due to the 1st party token fetch
|
|
US_EXPECT_PROPERTY_WAIT(testLocal, Local::isConfigSessionStarted, true, NS_COMMON::DEFAULT_WAIT_TIME);
|
|
uint32 count = 0;
|
|
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
|
|
TestHelpers_BF::AssertHandler assertHandler;
|
|
EXPECT_EQ(count, assertHandler.m_assertCount);
|
|
client.getUsApplicationId(); // no assert, since appId is recovered from istanceManager
|
|
EXPECT_EQ(count++, assertHandler.m_assertCount);
|
|
client.getResourceUrl("dummy", 0);
|
|
#if !defined(US_SDK_S2S)
|
|
EXPECT_EQ(count++, assertHandler.m_assertCount);
|
|
client.getClubServicesUrl("dummy");
|
|
EXPECT_EQ(count++, assertHandler.m_assertCount);
|
|
client.getStormUrl("dummy");
|
|
#endif
|
|
EXPECT_EQ(count++, assertHandler.m_assertCount);
|
|
client.getParametersGroupApplication("dummy");
|
|
EXPECT_EQ(count++, assertHandler.m_assertCount);
|
|
client.getParametersGroupsApplication({ "dummy" });
|
|
EXPECT_EQ(count++, assertHandler.m_assertCount);
|
|
client.getParametersGroupSpace("dummy");
|
|
EXPECT_EQ(count++, assertHandler.m_assertCount);
|
|
client.getParametersGroupsSpace({ "dummy" });
|
|
EXPECT_EQ(count++, assertHandler.m_assertCount);
|
|
}
|
|
#endif //!US_RETAIL
|
|
|
|
#if defined(US_TARGET_WINDOWS) && !defined(US_SDK_S2S) // The test is enabled only for WINDOWS because that test population is created for that platform.
|
|
/// @test validates that the server configs replace the sdk hard-coded urls
|
|
#if defined(US_CHINA_ACCOUNTS_SETUP_NOT_DONE)
|
|
TEST_F(PARAMETERS_NOLOGIN, DISABLED_US_HardCodedResourceUrlReplacedByServerUrls)
|
|
#else
|
|
TEST_F(PARAMETERS_NOLOGIN, US_MINRUN_HardCodedResourceUrlReplacedByServerUrls)
|
|
#endif
|
|
{
|
|
// This is the profile of the population that has the test urls
|
|
PlayerCredentials credentials("ussdk008@ubisoft.com", "a1234567");
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(getFacade().createSession(credentials, {}, {})));
|
|
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
|
|
const String applications = client.getResourceUrl(GatewayResource::MAP.at(GatewayResource::Applications).m_name, 0);
|
|
EXPECT_EQ("http://dummyApplication", applications);
|
|
const String sessions = client.getResourceUrl(GatewayResource::MAP.at(GatewayResource::Sessions).m_name, 0);
|
|
EXPECT_EQ("http://dummySession", sessions);
|
|
const String users = client.getResourceUrl(GatewayResource::MAP.at(GatewayResource::Users).m_name, 0);
|
|
EXPECT_EQ("http://dummyUsers", users);
|
|
const String policies = client.getResourceUrl(GatewayResource::MAP.at(GatewayResource::Policies).m_name, 0);
|
|
EXPECT_EQ("http://dummyPolicies", policies);
|
|
const String profilesExternal = client.getResourceUrl(GatewayResource::MAP.at(GatewayResource::ProfilesExternal).m_name, 0);
|
|
EXPECT_EQ("http://dummyProfiles", profilesExternal);
|
|
const String parametersApplication = client.getResourceUrl(GatewayResource::MAP.at(GatewayResource::ParametersApplication).m_name, 0);
|
|
EXPECT_EQ("http://dummyParameters/application", parametersApplication);
|
|
const String parametersSpace = client.getResourceUrl(GatewayResource::MAP.at(GatewayResource::ParametersSpace).m_name, 0);
|
|
EXPECT_EQ("http://dummyParameters/spaces", parametersSpace);
|
|
}
|
|
#endif // defined(US_TARGET_WINDOWS)
|
|
|
|
|
|
#if !defined(US_SDK_S2S)
|
|
/// Tests that override parameter group mechanism works.
|
|
TEST_F(PARAMETERS_MOCK_NO_LOGIN, USNOT_OverrideCustomGroup)
|
|
{
|
|
static const char* const s_JSON_DEFAULT_VALUE1 = "dummyString1";
|
|
static const char* const s_JSON_DEFAULT_VALUE2 = "dummyString2";
|
|
|
|
static const char* const s_JSON_KEY1 = "dummyKey1";
|
|
static const char* const s_JSON_KEY2 = "dummyKey2";
|
|
|
|
class ParametersMockHelperOverrideCustomGroup : public ParametersSpaceMockHelper
|
|
{
|
|
public:
|
|
ParametersMockHelperOverrideCustomGroup(const String& customGroupName, const StringKeyMap<String>& overrideMap = StringKeyMap<String>())
|
|
: m_customGroupName(customGroupName)
|
|
, m_overrideMap(overrideMap)
|
|
{
|
|
{
|
|
m_map[s_JSON_KEY1] = s_JSON_DEFAULT_VALUE1;
|
|
m_map[s_JSON_KEY2] = s_JSON_DEFAULT_VALUE2;
|
|
addCustomGroup(m_customGroupName, m_map);
|
|
}
|
|
}
|
|
|
|
Json buildParametersGroupOverride() const override
|
|
{
|
|
JsonWriter fields;
|
|
if (!m_overrideMap.empty())
|
|
{
|
|
JsonWriter customValues;
|
|
for (const auto& value : m_overrideMap)
|
|
{
|
|
customValues[value.first] = value.second;
|
|
}
|
|
fields[m_customGroupName] = customValues.getJson();
|
|
}
|
|
return renderParameterGroup(fields.getJson());
|
|
}
|
|
|
|
private:
|
|
String m_customGroupName;
|
|
StringKeyMap<String> m_map;
|
|
StringKeyMap<String> m_overrideMap;
|
|
};
|
|
|
|
const String overrideStringValue1 = "smartString1";
|
|
const String overrideStringValue2 = "smartString2";
|
|
const String customGroupName = "customGroupString";
|
|
|
|
{
|
|
const MockAsyncResult parametersSpaceMock =
|
|
MockResultHelper::createSuccessResult(ParametersMockHelperOverrideCustomGroup(customGroupName).getParameters().renderContent());
|
|
mockFullLogin(nullptr, nullptr, ¶metersSpaceMock);
|
|
}
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(getFacade().createSession(getPlayerCredentials(), {}, {})));
|
|
|
|
{
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
const ParametersGroupInfo& info = client.getParametersGroupSpace(customGroupName);
|
|
ASSERT_EQ(s_JSON_DEFAULT_VALUE1, info.m_fields[s_JSON_KEY1].getValueString());
|
|
ASSERT_EQ(s_JSON_DEFAULT_VALUE2, info.m_fields[s_JSON_KEY2].getValueString());
|
|
}
|
|
|
|
{
|
|
mockDeleteSession();
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(getFacade().deleteSession()));
|
|
}
|
|
|
|
{
|
|
StringKeyMap<String> overrideMap;
|
|
overrideMap[s_JSON_KEY1] = overrideStringValue1;
|
|
overrideMap[s_JSON_KEY2] = overrideStringValue2;
|
|
|
|
const String a = ParametersMockHelperOverrideCustomGroup(customGroupName, overrideMap).getParameters().renderContent();
|
|
const MockAsyncResult parametersSpaceMock =
|
|
MockResultHelper::createSuccessResult(a);
|
|
mockFullLogin(nullptr, nullptr, ¶metersSpaceMock);
|
|
}
|
|
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(getFacade().createSession(getPlayerCredentials(), {}, {})));
|
|
|
|
{
|
|
ParametersClient& client = getFacade().getParametersClient();
|
|
const ParametersGroupInfo& info = client.getParametersGroupSpace(customGroupName);
|
|
ASSERT_EQ(overrideStringValue1, info.m_fields[s_JSON_KEY1].getValueString());
|
|
ASSERT_EQ(overrideStringValue2, info.m_fields[s_JSON_KEY2].getValueString());
|
|
|
|
ASSERT_NE(s_JSON_DEFAULT_VALUE1, info.m_fields[s_JSON_KEY1].getValueString());
|
|
ASSERT_NE(s_JSON_DEFAULT_VALUE2, info.m_fields[s_JSON_KEY2].getValueString());
|
|
}
|
|
}
|
|
#endif //#if !defined(US_SDK_S2S)
|
|
#endif //#if !defined(US_DLL)
|
|
};
|