using BrokerApiCore; using BrokerApiServer; using ServerCore; using ServerBase; using ServerCommon; namespace BrokerTest; 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 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; } } }