Ejemplo n.º 1
0
        private Token createTokenFromResponse(IHttpClientResponse response)
        {
            string accessValue   = response.GetHeader("token");
            int    expirySeconds = int.Parse(response.GetHeader("tokenexpiry"));

            return(new Token {
                AccessValue = accessValue, ExpirySeconds = expirySeconds
            });
        }
Ejemplo n.º 2
0
        public async Task PostAuthenticate_WhenValidCredentials_ReturnsToken()
        {
            RestClient client = new RestClient(mockTokenProvider.Object);

            IHttpClientResponse response = await client.Post("http://online.cuprum.com/webapixamarin/Api/Authenticate/Authenticate", new { ClaveAcceso = "arodriguez", Contrasena = "admin123$" });

            Assert.AreEqual("\"Authorized\"", response.GetContent());
            Assert.IsNotNull(response.GetHeader("token"));
        }