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

            var request = new RequiresPermissionRequest {RequestData = "test"};
            // ReSharper disable once RedundantTypeArgumentsOfMethod  (Parameter type added for clarity only)
            var error = Assert.Throws<WebServiceException>(() => client.Send<RequiresPermissionResponse>(request));

            Assert.AreEqual((int) HttpStatusCode.Forbidden, error.StatusCode);
            Assert.AreEqual("Invalid Permission", error.StatusDescription);
            Assert.AreEqual("Invalid Permission", error.ErrorCode);
        }
示例#2
0
 public void can_call_RequiredPermission_service_with_BasicAuth()
 {
     var client = GetClientWithUserPassword();
     var request = new RequiresPermissionRequest {RequestData = "test"};
     // ReSharper disable once RedundantTypeArgumentsOfMethod  (Parameter type added for clarity only)
     var response = client.Send<RequiresPermissionResponse>(request);
     Assert.That(response.Result, Is.EqualTo(request.RequestData));
 }
示例#3
0
 public void RequiredPermission_service_returns_unauthorized_if_no_basic_auth_header_exists()
 {
     var client = GetClient();
     var request = new RequiresPermissionRequest {RequestData = "test"};
     // ReSharper disable once RedundantTypeArgumentsOfMethod  (Parameter type added for clarity only)
     var error = Assert.Throws<WebServiceException>(() => client.Send<RequiresPermissionResponse>(request));
     Assert.AreEqual((int) HttpStatusCode.Unauthorized, error.StatusCode);
     Assert.AreEqual("Unauthorized", error.StatusDescription);
     Assert.AreEqual("Unauthorized", error.ErrorCode);
 }
 public RequiresPermissionResponse Any(RequiresPermissionRequest request)
 {
     return new RequiresPermissionResponse { Result = request.RequestData };
 }