示例#1
0
        public void RequiresAnyRole_service_returns_forbidden_if_basic_auth_header_exists()
        {
            var client = GetClient();
            ((ServiceClientBase) client).UserName = SystemConstants.EmailBasedUsername;
            ((ServiceClientBase) client).Password = SystemConstants.PasswordForEmailBasedAccount;

           
            var request = new RequiresAnyRoleRequest {RequestData = "some data"};
            // ReSharper disable once RedundantTypeArgumentsOfMethod  (Parameter type added for clarity only)
            var error = Assert.Throws<WebServiceException>(() => client.Send<RequiresAnyRoleResponse>(request));
            Assert.AreEqual((int) HttpStatusCode.Forbidden, error.StatusCode);
            Assert.AreEqual("Invalid Role", error.StatusDescription);
            Assert.AreEqual("Invalid Role", error.ErrorCode);
        }
示例#2
0
 public void can_call_RequiresAnyRole_service_with_BasicAuth()
 {
     var client = GetClientWithUserPassword();
     
     var request = new RequiresAnyRoleRequest {RequestData = "some data"};
     // ReSharper disable once RedundantTypeArgumentsOfMethod  (Parameter type added for clarity only)
     var response = client.Send<RequiresAnyRoleResponse>(request);
     Assert.AreEqual(response.Result, request.RequestData);
 }
示例#3
0
        public void RequiresAnyRole_service_returns_unauthorized_if_no_basic_auth_header_exists()
        {
            var client = GetClient();
           
            var request = new RequiresAnyRoleRequest {RequestData = "some data"};
            var error = Assert.Throws<WebServiceException>(() => client.Send<RequiresAnyRoleRequest>(request));

            Assert.AreEqual((int) HttpStatusCode.Unauthorized, error.StatusCode);
            Assert.AreEqual("Unauthorized", error.StatusDescription);
            Assert.AreEqual("Unauthorized", error.ErrorCode);
        }
 public object Any(RequiresAnyRoleRequest request)
 {
     return new RequiresAnyRoleResponse { Result = request.RequestData };
 }