public void testWrite_expectMissingTokenException() { var baseUrl = new RestConfig().GetUrl(); var client = new RestClient(new HttpClient(), baseUrl, new DummyParser()); client.WriteDouble("path", "field", 0f, null); }
public void RestConfigConstructorTest() { XmlDocument d = new XmlDocument(); XmlNode root = d.CreateElement("restServices"); d.AppendChild(root); XmlNode assemblies = d.CreateElement("Assemblies"); root.AppendChild(assemblies); XmlNode add; XmlAttribute name; add = d.CreateElement("add"); assemblies.AppendChild(add); name = d.CreateAttribute("name"); name.Value = this.GetType().Assembly.FullName; add.Attributes.Append(name); RestConfig target = new RestConfig(d); Assert.AreEqual(1, target.Count); }
public static IEnumerable <PocIdioma> ConsultarIdiomas() { var url = RestConfig.Get("ApiCore", "General", "ConsultarIdiomas"); return(RestClient.CoreRequest <IEnumerable <PocIdioma> > (url, restMethod: RestMethod.Get)); }
public void testSetTokenEmpty_expectMissingTokenException() { var baseUrl = new RestConfig().GetUrl(); var client = new RestClient(new HttpClient(), baseUrl, new DummyParser()); client.SetToken(""); }
public static List <PocPregunta> ObtenerPreguntas() { var url = RestConfig.Get("ApiCore", "Membresia", "ObtenerPreguntas"); return(RestClient.CoreRequest <List <PocPregunta> > (url, restMethod: RestMethod.Get)); }
public static PocInfoSesion ValidarUsuario(ModLogin login) { login.Password = login.Password.Encrypt(); var url = RestConfig.Get("ApiCore", "Auth", "ValidarUsuario"); var user = RestClient.CoreRequest <PocInfoSesion>(url, login); SeguridadDelegate.UsuarioTemporal = user; return(user); }
public static void ActualizarContrasena(ModCambioContrasena cambio) { cambio.Contrasena = cambio.Contrasena.Encrypt(); cambio.ContrasenaActual = cambio.ContrasenaActual.Encrypt(); cambio.ConfirmarContrasena = cambio.ConfirmarContrasena.Encrypt(); var url = RestConfig.Get("ApiCore", "Membresia", "ActualizarContrasena"); RestClient.CoreRequest(url, cambio); }
public static ModRenovarContrasenaPaso2 ValidarRenovacion(string username, string email) { var url = RestConfig.Get("ApiCore", "Membresia", "ValidarRenovacion"); return(RestClient.CoreRequest <ModRenovarContrasenaPaso2>(url, new { AliasUsuario = username, Correo = email })); }
public static string IniciarSesion(string user, string ticket) { var url = RestConfig.Get("ApiCore", "Auth", "IniciarSesion"); return(RestClient.CoreRequest <string>(url, new { user = user, ticket = ticket })); }
public static bool ValidarPinAutenticacion(string codUsuario, string codigo2FA) { var url = RestConfig.Get("ApiCore", "Auth", "ValidarPinAutenticacion"); return(RestClient.CoreRequest <bool>(url, new { codUsuario = codUsuario, codigo2FA = codigo2FA })); }
public static bool ComprobarPreguntasUsuario(string codUsuario, List <ModPreguntaUsuario> preguntas) { preguntas.Update(m => { m.CodUsuario = codUsuario; m.Respuesta = m.Respuesta.ToLower().EncryptPBKDF2(); }); var url = RestConfig.Get("ApiCore", "Membresia", "ComprobarPreguntasUsuario"); return(RestClient.CoreRequest <bool>(url, preguntas)); }
public ClientConfiguration(Properties properties) { Properties = properties; DefaultChannel = properties.Get("DefaultChannel", "rest"); StompEnabled = properties.Get("Stomp.Enabled", false); AppId = properties.Get("AppId"); TraceDir = properties.Get("TraceDir"); CacheDir = properties.Get("CacheDir"); RestConfig = new RestConfig(properties); AuthConfig = new AuthConfig(properties); StompConfig = new StompConfig(properties); }
/// <summary> /// Creates a new instance of the <see cref="NestClient"/>. /// </summary> public NestClient(RestConfig restConfig) { var messageParser = new MessageParser(new ObjectModelMapper(notifier)); var httpClient = new HttpClient(); var streamingHttpClient = new HttpClient(new HttpClientHandler { AllowAutoRedirect = true, MaxAutomaticRedirections = 10, }, true); //.connectTimeout(10, TimeUnit.SECONDS) streamingHttpClient.Timeout = TimeSpan.FromSeconds(60);//.readTimeout(60, TimeUnit.SECONDS) restClient = new RestClient(httpClient, restConfig.GetUrl(), messageParser); streamingClient = new RestStreamClient(streamingHttpClient, restConfig, messageParser, exceptionHandler: exception => { StreamingError?.Invoke(exception); }); cameras = new CameraSetter(restClient); structures = new StructureSetter(restClient); thermostats = new ThermostatSetter(restClient); }
public ClientConfig() { Identify = new Identify { IsCompress = true, Properties = new IdentifyProperties { OS = Environment.OSVersion.Platform.ToString(), Browser = "DiscordCs", Device = "DiscordCs" }, LargeThreshold = 50, Presence = new PresenceStatusUpdate { Status = PresenceStatus.Online }, Intents = IdentifyIntent.Default, IsGuildSubscriptions = false }; GatewayConfig = new GatewayConfig { BaseUrl = "wss://gateway.discord.gg", Version = 8, Encoding = "json" }; Gateway = new GatewayContext(); Logger = new Logger { Level = LoggingLevel.Warning }; CacheContext = new CacheContext(new CacheConfig { }); RestConfig = new RestConfig { BaseUrl = "https://discord.com", Version = 8 }; Rest = new RestContext(); }
private static void RestConfigTest( ) { var rest = RestConfig.Default() .UseBaseUrl("http://localhost:65374") .UseEncoding(Encoding.UTF8) .UseSerializer(o => JsonConvert.SerializeObject(o)) .UseDeserializer((s, t) => JsonConvert.DeserializeObject(s, t)) .Build(); var desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); try { var req = rest.Create() .UseMethod(Method.POST) .UseUrl("weatherforecast/index") .UseContinueTimeout(10000) .AddParameter(new int[] { 123, 123 }) .AddFile(Path.Combine(desktop, "123.exe")) //.UseFileWriter(fileWriter => //{ // var targetFile = Path.Combine(desktop, $"{DateTime.Now.Ticks}.txt"); // using var fs = File.Create(targetFile); // fileWriter.WriteTo(fs); //}) .AddParameter("loginName", "123") .AddParameter("password", "123"); var resp = req.Execute(); resp.GetResult <int[]>(); Console.WriteLine(resp); } catch (Exception e) { Console.WriteLine(e); } Console.ReadKey(); }
public void RestTesterInvalidUrlTest() { // Make sure we don't get any proxy intercepts var restConfig = new RestConfig(); var input = new List <List <string> > { new List <string> { "Proxy", "None" } }; _ = restConfig.DoTable(input); var rt = new RestTester { EndPoint = "http://localhost:8765", RequestBody = "{ \"userId\":96 }" }; rt.SendTo("Post", "posts"); Assert.AreEqual(403, rt.ResponseCode); }
public static string ObtenerClaveAut() { var url = RestConfig.Get("ApiCore", "Membresia", "ObtenerClaveAut"); return(RestClient.CoreRequest <string>(url)); }
public void RestConfigTableTest() { var c = new RestConfig(); var input = new List <List <string> > { new List <string> { "DefaultAccept", "application/json" }, new List <string> { "DefaultContentType", "application/json" }, new List <string> { "Headers", "header1:test1\r\nheader2:test2" }, new List <string> { "ContentTypeMapping", "application/xml:XML\r\napplication/json:JSON\r\ntext/plain:TEXT\r\ndefault:JSON" }, new List <string> { "Proxy", "System" }, new List <string> { "Encoding", "iso-8859-1" }, new List <string> { "DefaultUserAgent", "FitNesseRest" }, new List <string> { "DefaultXmlNameSpaceKey", "atom" }, new List <string> { "XmlValueTypeAttribute", string.Empty }, new List <string> { "Timeout", "7.5" }, new List <string> { "TrimWhitespace", "false" }, /* new List<string> {"CookieDomain", "localhost"}, */ new List <string> { "Cookies", "cookie1=value1\r\ncookie2=value2" }, new List <string> { "SecurityProtocol", "Tls12" }, // this must be the last one new List <string> { "NonExisting", "Bogus Value" } }; var output = c.DoTable(input); Assert.AreEqual(input.Count, output.Count); for (var i = 0; i < output.Count - 1; i++) { var line = output[i] as List <string>; Assert.IsNotNull(line); Assert.AreEqual(string.Empty, line[0]); Assert.AreEqual("pass", line[1], "line " + i); } var lastLine = output[output.Count - 1] as List <string>; Assert.IsNotNull(lastLine); Assert.AreEqual(string.Empty, lastLine[1]); }
public static PocInfoSesion ObtenerUsuarioPorTicket(string ticket) { var url = RestConfig.Get("ApiCore", "Auth", "ObtenerUsuarioTicket"); return(RestClient.CoreRequest <PocInfoSesion>(url, ticket)); }
public static void FinalizarSesion(string user, string ticket) { var url = RestConfig.Get("ApiCore", "Auth", "FinalizarSesion"); RestClient.CoreRequest(url, new { user = user, ticket = ticket }); }
public static void RegistrarPerfil(ModUsuarioRegistro registro) { var url = RestConfig.Get("ApiCore", "Membresia", "RegistrarPerfil"); RestClient.CoreRequest(url, registro); }
public static ModDobleFactorAut GenerarCodigo(string codUsuario) { var url = RestConfig.Get("ApiCore", "Auth", "GenerarCodigo"); return(RestClient.CoreRequest <ModDobleFactorAut>(url, codUsuario)); }