Пример #1
0
        public void Html_clients_receive_redirect_to_login_page_when_accessing_unauthenticated()
        {
            var client = (ServiceClientBase)GetHtmlClient();

            client.AllowAutoRedirect = false;
            string lastResponseLocationHeader = null;

            client.ResponseFilter = response =>
            {
                lastResponseLocationHeader = response.Headers["Location"];
            };

            var request = new Secured {
                Name = "test"
            };

            client.Send <SecureResponse>(request);

            var locationUri = new Uri(lastResponseLocationHeader);
            var loginPath   = "/".CombineWith(VirtualDirectory).CombineWith(LoginUrl);

            Assert.That(locationUri.AbsolutePath, Is.EqualTo(loginPath).IgnoreCase);
        }
Пример #2
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 =>
            {
                authResponse.PrintDump();
                client.SendAsync <SecureResponse>(request, r => response = r, FailOnAsyncError);
            }, FailOnAsyncError);

            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.That(response.Result, Is.EqualTo(request.Name));
        }
Пример #3
0
 public object Get(Secured request)
 {
     throw new ArgumentException("unicorn nuggets");
 }
Пример #4
0
 public object Post(Secured request)
 {
     return(new SecuredResponse {
         Result = request.Name
     });
 }