초기커밋
This commit is contained in:
70
BrokerApiTest/Helper/TestUserHelper.cs
Normal file
70
BrokerApiTest/Helper/TestUserHelper.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using BrokerApiServer.Extensions;
|
||||
|
||||
using BrokerCore;
|
||||
using BrokerCore.Entity;
|
||||
using BrokerCore.Repository;
|
||||
using BrokerCore.Services;
|
||||
|
||||
using ServerCommon;
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
namespace BrokerTest.Helper;
|
||||
|
||||
public class TestUserHelper
|
||||
{
|
||||
readonly BrokerServerLogic m_server_logic;
|
||||
private readonly UserAuthAction m_auth_action;
|
||||
private readonly PlanetUserEntity m_planet_user;
|
||||
|
||||
public TestUserHelper(string serviceEnv)
|
||||
{
|
||||
AppBuilderExtensions.initGlobalNlog();
|
||||
Log.initLog("BrokerApiServer", "Developer");
|
||||
var config = initBrokerServerConfig(serviceEnv);
|
||||
var logic = new BrokerServerLogic(config);
|
||||
logic.onInit().Wait();
|
||||
ServerLogicApp.setServerLogicApp(logic);
|
||||
m_server_logic = logic;
|
||||
|
||||
m_planet_user = new PlanetUserEntity(logic);
|
||||
m_planet_user.onInit().Wait();
|
||||
m_auth_action = new UserAuthAction(m_planet_user, logic.getDynamoDbClient());
|
||||
}
|
||||
|
||||
private static ServerConfigMetaverseBroker initBrokerServerConfig(string serviceEnv)
|
||||
{
|
||||
string config_path = serviceEnv switch
|
||||
{
|
||||
"Dev" => "ServerConfig.json",
|
||||
"QA" => "ServerConfig-QA.json",
|
||||
"Stage" => "ServerConfig-Stage.json",
|
||||
_ => throw new ArgumentException($"Invalid service environment: {serviceEnv}")
|
||||
};
|
||||
// 서버 설정
|
||||
var server_config = new ServerConfigMetaverseBroker();
|
||||
var server_config_path = $"./Config/{config_path}";
|
||||
server_config.setConfigFilePath(server_config_path);
|
||||
var result = server_config.tryLoadConfig().GetAwaiter().GetResult();
|
||||
Assert.True(result.isSuccess(), $"ServerConfig Load Failed => {result}");
|
||||
return server_config;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<string> getUserGuidByAccountId(string accountId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await m_auth_action.findAndSetAllAttributeByAccountId(accountId);
|
||||
return result.isFail() ? string.Empty : m_planet_user.UserGuid;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.getLogger().Error(ex, $"{nameof(TestUserHelper)}.getUserGuidByAccountId() Exception => {ex.Message}");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user