예제 #1
0
        public void BasicAuthenticationWithIncorrectCredentials()
        {
            using (IRestClient client = restClientFactory.CreateRestClient())
            {
                const string Username = "******";
                const string Password = "******";
                client.Credentials(new NetworkCredential(Username, Password));

                RestException ex = Assert.Throws <RestException>(
                    () => client.Get("http://httpbin.org/basic-auth/{0}/{1}".Fmt(Username, "hamster")).Do());
                Assert.AreEqual((int)HttpStatusCode.Unauthorized, ex.StatusCode);
            }
        }
예제 #2
0
        public void BasicAuthenticationWithCorrectCredentials()
        {
            using (IRestClient client = restClientFactory.CreateRestClient())
            {
                const string Username = "******";
                const string Password = "******";
                client.Credentials(new NetworkCredential(Username, Password));

                var reponse = client.Get(
                    "http://httpbin.org/basic-auth/{0}/{1}".Fmt(Username, Password)).Do().Response;
                Assert.IsNotNull(reponse);
            }
        }