diff --git a/tests/Check.ServiceInterface/ErrorsService.cs b/tests/Check.ServiceInterface/ErrorsService.cs index 7f35fbbf7ba..ac97336c6de 100644 --- a/tests/Check.ServiceInterface/ErrorsService.cs +++ b/tests/Check.ServiceInterface/ErrorsService.cs @@ -1,5 +1,9 @@ -using Check.ServiceModel; +using System; +using System.IO; +using System.Security.Authentication; +using Check.ServiceModel; using ServiceStack; +using ServiceStack.Data; namespace Check.ServiceInterface { @@ -14,5 +18,39 @@ public object Any(Throw404 request) { throw HttpError.NotFound(request.Message ?? "Custom Status Description"); } + + public object Any(ThrowType request) + { + switch (request.Type ?? "Exception") + { + case "Exception": + throw new Exception(request.Message ?? "Server Error"); + case "NotFound": + throw HttpError.NotFound(request.Message ?? "What you're looking for isn't here"); + case "Unauthorized": + throw HttpError.Unauthorized(request.Message ?? "You shall not pass!"); + case "Conflict": + throw HttpError.Conflict(request.Message ?? "We haz Conflict!"); + case "NotImplementedException": + throw new NotImplementedException(request.Message ?? "Not implemented yet, try again later"); + case "ArgumentException": + throw new ArgumentException(request.Message ?? "Client Argument Error"); + case "AuthenticationException": + throw new AuthenticationException(request.Message ?? "We haz issue Authenticatting"); + case "UnauthorizedAccessException": + throw new UnauthorizedAccessException(request.Message ?? "You shall not pass!"); + case "OptimisticConcurrencyException": + throw new OptimisticConcurrencyException(request.Message ?? "Sorry too optimistic"); + case "UnhandledException": + throw new FileNotFoundException(request.Message ?? "File was never here"); + case "RawResponse": + Response.StatusCode = 418; + Response.StatusDescription = request.Message ?? "On a tea break"; + Response.Close(); + break; + } + + return request; + } } } \ No newline at end of file diff --git a/tests/Check.ServiceModel/ThrowHttpError.cs b/tests/Check.ServiceModel/ThrowHttpError.cs index 1feff3e5bea..687d548c4c9 100644 --- a/tests/Check.ServiceModel/ThrowHttpError.cs +++ b/tests/Check.ServiceModel/ThrowHttpError.cs @@ -15,4 +15,16 @@ public class Throw404 { public string Message { get; set; } } + + [Route("/throw/{Type}")] + public class ThrowType : IReturn + { + public string Type { get; set; } + public string Message { get; set; } + } + + public class ThrowTypeResponse + { + public ResponseStatus ResponseStatus { get; set; } + } } \ No newline at end of file diff --git a/tests/CheckWeb/Global.asax.cs b/tests/CheckWeb/Global.asax.cs index 2f2ba42f5a0..7a81930cbee 100644 --- a/tests/CheckWeb/Global.asax.cs +++ b/tests/CheckWeb/Global.asax.cs @@ -76,6 +76,7 @@ public override void Configure(Container container) Plugins.Add(new AutoQueryFeature()); Plugins.Add(new PostmanFeature()); + Plugins.Add(new CorsFeature()); container.Register( new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider));