public void CommentBusiness_RequiredParameters() { var clientInfo = new ClientInfo { ClientId = "6305557f7fcb4988abae4e404d3e6e1d", ClientSecret = "a8ba06d0" }; var ssoService = new SsoService(clientInfo); var outputToken = new OAuthResponseSrv(); var refreshTokenVo = RefreshAccessTokenVo.ConcreteBuilder .SetGrantType("refresh_token") .SetRefreshToken("077372c5cbc9429086ec37f50e2f898c") .Build(); ssoService.RefreshAccessToken(refreshTokenVo, response => Listener.GetResult(response, out outputToken)); var internalServiceCallVo = InternalServiceCallVo.ConcreteBuilder .SetToken(outputToken.Access_Token) .Build(); var output = new ResultSrv <long>(); var commentBusinessVo = CommentBusinessVo.ConcreteBuilder .SetServiceCallParameters(internalServiceCallVo) .SetBusinessId(13059) .SetText("test Comment") .Build(); DealingService.CommentBusiness(commentBusinessVo, response => Listener.GetResult(response, out output)); Assert.False(output.HasError); }
public virtual async Task ConfigureAsync(string configFile) { MasterPath = Path.GetDirectoryName(configFile); var serializer = new XmlSerializer(typeof(Configuration)); if (!File.Exists(configFile)) { throw new ArgumentException($"{configFile} config file does not exist."); } await using (var fs = File.OpenRead(configFile)) { Logger.Config = Config = (Configuration)serializer.Deserialize(fs); UchuContextBase.Config = Config; } await SetupApiAsync().ConfigureAwait(false); if (!string.IsNullOrWhiteSpace(Config.ResourcesConfiguration?.GameResourceFolder)) { Resources = new LocalResources(Config); } var certificateFilePath = Path.Combine(MasterPath, Config.Networking.Certificate); if (Config.Networking?.Certificate != default && File.Exists(certificateFilePath)) { var cert = new X509Certificate2(certificateFilePath); Logger.Information($"PRIVATE KEY: {cert.HasPrivateKey} {cert.PrivateKey}"); Certificate = cert; RakNetServer = new TcpUdpServer(Port, "3.25 ND1", Certificate, 150); } else { RakNetServer = new TcpUdpServer(Port, "3.25 ND1"); } SsoService = new SsoService(Config.SsoConfig?.Domain ?? ""); try { SessionCache = new RedisSessionCache(); } catch (RedisConnectionException) { Logger.Error("Failed to establish Redis connection, falling back to database."); SessionCache = new DatabaseCache(); } Logger.Information($"Server {Id} configured on port: {Port}"); }
public SsoMethodInvoke() { try { ClientInfo = new ClientInfo { ClientId = "", ClientSecret = "" }; ssoService = new SsoService(ClientInfo); } catch (PodException podException) { Console.WriteLine($"-- {podException.Code}-an error has occured : {Environment.NewLine}{podException.Message}"); throw; } catch (Exception exception) { Console.WriteLine(exception.Message); throw; } }
public void ApplicationTestInitialize() { _ssoService = new SsoService(); }
/// <summary> /// Configures the server by parsing config files and setting up certificates. /// </summary> /// <param name="configFile">The config file to use as configuration</param> /// <exception cref="ArgumentException">If the provided config file can't be found</exception> public virtual async Task ConfigureAsync(string configFile) { if (configFile == null) { throw new ArgumentNullException(nameof(configFile), ResourceStrings.Server_ConfigureAsync_ConfigFileNullException); } MasterPath = Path.GetDirectoryName(configFile); Config = UchuConfiguration.Load(configFile); if (!Config.DebugConfig.StartInstancesAsThreads) { Logger.SetConfiguration(Config); } UchuContextBase.Config = Config; if (!File.Exists(configFile)) { throw new ArgumentException($"{configFile} config file does not exist."); } await SetupApiAsync().ConfigureAwait(false); if (!string.IsNullOrWhiteSpace(Config.ResourcesConfiguration?.GameResourceFolder)) { Resources = new LocalResources(Config); } // Setup the RakNet server and possible certificate var certificateFilePath = Path.Combine(MasterPath, Config.Networking.Certificate); if (Config.Networking?.Certificate != default && File.Exists(certificateFilePath)) { var cert = new X509Certificate2(certificateFilePath); Logger.Information($"PRIVATE KEY: {cert.HasPrivateKey} {cert.PrivateKey}"); Certificate = cert; RakNetServer = new TcpUdpServer(Port, "3.25 ND1", Certificate, 150); } else { RakNetServer = new TcpUdpServer(Port, "3.25 ND1"); } SsoService = new SsoService(Config.SsoConfig?.Domain ?? ""); // Try to connect to Redis, otherwise fallback to DB caching if (Config.CacheConfig.UseService) { try { SessionCache = new RedisSessionCache(Config.CacheConfig); Logger.Information($"Established Redis connection at {Config.CacheConfig.Host}:{Config.CacheConfig.Port}"); } catch (RedisConnectionException) { Logger.Error("Failed to establish Redis connection, falling back to database."); SessionCache = new DatabaseCache(); } } else { Logger.Information("Caching service is disabled, falling back to database."); SessionCache = new DatabaseCache(); } HeartBeatsPerInterval = Config.Networking.WorldServerHeartBeatsPerInterval; HeartBeatIntervalInMinutes = Config.Networking.WorldServerHeartBeatIntervalInMinutes; Logger.Information($"Server {Id} configured on port: {Port}"); }