public void Get_401_When_accessing_Secure_using_RestClient_PUT_without_Authorization()
        {
            var client = CreateNewRestClientAsync();

            if (client == null)
            {
                return;
            }

            SecureResponse response = null;
            var            wasError = false;

            client.PutAsync <SecureResponse>(ServiceClientBaseUri + "secure", new Secure(),
                                             r => response = r, (r, ex) => wasError = Assert401(r, ex));

            Thread.Sleep(1000);
            Assert.That(wasError, Is.True,
                        "Should throw WebServiceException.StatusCode == 401");
        }
        public void Can_login_with_Basic_auth_to_access_Secure_service_using_RestClientAsync()
        {
            var format = GetFormat();

            if (format == null)
            {
                return;
            }

            var client = CreateNewRestClientAsync();

            client.SetCredentials(AllowedUser, AllowedPass);

            SecureResponse response = null;

            client.GetAsync <SecureResponse>(ServiceClientBaseUri + "secure",
                                             r => response = r, FailOnAsyncError);

            Thread.Sleep(2000);
            Assert.That(response.Result, Is.EqualTo("Confidential"));
        }
Example #3
0
        public void Does_work_with_CredentailsAuth_Async()
        {
            var client = GetClient();

            var request = new Secured {
                Name = "test"
            };
            SecureResponse response = null;

            client.SendAsync <AuthResponse>(new Auth {
                provider   = CredentialsAuthProvider.Name,
                UserName   = "******",
                Password   = "******",
                RememberMe = true,
            }, authResponse => {
                Console.WriteLine(authResponse.Dump());
                client.SendAsync <SecureResponse>(request, r => response = r, FailOnAsyncError);
            }, FailOnAsyncError);

            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.That(response.Result, Is.EqualTo(request.Name));
        }