diff --git a/mangooio-core/src/main/java/io/mangoo/admin/AdminController.java b/mangooio-core/src/main/java/io/mangoo/admin/AdminController.java index 94d4f6279f..99f1f95fee 100644 --- a/mangooio-core/src/main/java/io/mangoo/admin/AdminController.java +++ b/mangooio-core/src/main/java/io/mangoo/admin/AdminController.java @@ -309,7 +309,6 @@ public Response routes() { json.put("limit", route.getLimit()); json.put("basicAuthentication", route.hasBasicAuthentication()); json.put("authentication", route.hasAuthentication()); - json.put("authorization", route.hasAuthorization()); json.put("blocking", route.isBlocking()); routes.add(json); }); diff --git a/mangooio-core/src/main/java/io/mangoo/core/Application.java b/mangooio-core/src/main/java/io/mangoo/core/Application.java index b4ea30549a..38deac5ff6 100644 --- a/mangooio-core/src/main/java/io/mangoo/core/Application.java +++ b/mangooio-core/src/main/java/io/mangoo/core/Application.java @@ -406,11 +406,6 @@ private static void prepareRoutes() { LOG.error("Could not find controller method '{}' in controller class '{}'", requestRoute.getControllerMethod(), requestRoute.getControllerClass()); failsafe(); } - - if (requestRoute.hasAuthorization() && (!MangooUtils.resourceExists(Default.MODEL_CONF.toString()) || !MangooUtils.resourceExists(Default.POLICY_CSV.toString()))) { - LOG.error("Route on method '{}' in controller class '{}' requires authorization, but either model.conf or policy.csv is missing", requestRoute.getControllerMethod(), requestRoute.getControllerClass()); - failsafe(); - } }); } @@ -496,7 +491,6 @@ private static RoutingHandler getRoutingHandler() { .withMaxEntitySize(requestRoute.getMaxEntitySize()) .withBasicAuthentication(requestRoute.getUsername(), requestRoute.getPassword()) .withAuthentication(requestRoute.hasAuthentication()) - .withAuthorization(requestRoute.hasAuthorization()) .withLimit(requestRoute.getLimit()); routingHandler.add(requestRoute.getMethod().toString(), requestRoute.getUrl(), dispatcherHandler); diff --git a/mangooio-core/src/main/java/io/mangoo/routing/Attachment.java b/mangooio-core/src/main/java/io/mangoo/routing/Attachment.java index 362f1cd577..414cf0c2dc 100644 --- a/mangooio-core/src/main/java/io/mangoo/routing/Attachment.java +++ b/mangooio-core/src/main/java/io/mangoo/routing/Attachment.java @@ -9,8 +9,6 @@ import java.util.Map; import java.util.Objects; -import org.apache.commons.lang3.StringUtils; - import io.mangoo.enums.Required; import io.mangoo.i18n.Messages; import io.mangoo.routing.bindings.Authentication; @@ -52,7 +50,6 @@ public class Attachment { private int methodParametersCount; private boolean requestFilter; private boolean requiresAuthentication; - private boolean requiresAuthorization; public static Attachment build() { return new Attachment(); @@ -161,10 +158,6 @@ public String getUsername() { public boolean hasAuthentication() { return this.requiresAuthentication; } - - public boolean hasBasicAuthentication() { - return StringUtils.isNotBlank(this.username) && StringUtils.isNotBlank(this.password); - } public boolean hasLimit() { return this.limit > 0; @@ -288,13 +281,4 @@ public Attachment withAuthentication(boolean authentication) { this.requiresAuthentication = authentication; return this; } - - public Attachment withAuthorization(boolean authorization) { - this.requiresAuthorization = authorization; - return this; - } - - public boolean hasAuthorization() { - return this.requiresAuthorization; - } } \ No newline at end of file diff --git a/mangooio-core/src/main/java/io/mangoo/routing/bindings/Validator.java b/mangooio-core/src/main/java/io/mangoo/routing/bindings/Validator.java index 854629bb88..eb4db160ff 100644 --- a/mangooio-core/src/main/java/io/mangoo/routing/bindings/Validator.java +++ b/mangooio-core/src/main/java/io/mangoo/routing/bindings/Validator.java @@ -76,45 +76,6 @@ public void expectValue(String name, String message) { } } - /** - * Validates a given field to have a minimum length - * - * @deprecated - * Use {@link #expectMinValue(String, double)} or {@link #expectMinLength(String, double)} instead - * - * @param name The field to check - * @param minLength The minimum length - */ - @Deprecated(since = "6.7.0", forRemoval = true) - public void expectMin(String name, double minLength) { - expectMin(name, minLength, null); - } - - /** - * Validates a given field to have a minimum length - * - * @deprecated - * Use {@link #expectMinValue(String, double, String)} or {@link #expectMinLength(String, double, String)} instead - * - * @param name The field to check - * @param minLength The minimum length - * @param message A custom error message instead of the default one - */ - @Deprecated(since = "6.7.0", forRemoval = true) - public void expectMin(String name, double minLength, String message) { - String value = Optional.ofNullable(get(name)).orElse(""); - - if (StringUtils.isNumeric(value)) { - if (Double.parseDouble(value) < minLength) { - addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.MIN_KEY.toString(), name, minLength))); - } - } else { - if (value.length() < minLength) { - addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.MIN_KEY.toString(), name, minLength))); - } - } - } - /** * Validates a given field to have a minimum value * @@ -168,20 +129,6 @@ public void expectMinLength(String name, double minLength, String message) { addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.MIN_LENGTH_KEY.toString(), name, minLength))); } } - - /** - * Validates a given field to have a maximum length - * - * @deprecated - * Use {@link #expectMaxLength(String, double)} or {@link #expectMaxValue(String, double)} instead - * - * @param maxLength The maximum length - * @param name The field to check - */ - @Deprecated(since = "6.7.0", forRemoval = true) - public void expectMax(String name, double maxLength) { - expectMax(name, maxLength, null); - } /** * Validates a given field to have a maximum value @@ -227,31 +174,6 @@ public void expectNumeric(String name, String message) { } } - /** - * Validates a given field to have a maximum length - * - * @deprecated - * Use {@link #expectMaxLength(String, double, String)} or {@link #expectMaxValue(String, double, String)} instead - * - * @param name The field to check - * @param maxLength The maximum length - * @param message A custom error message instead of the default one - */ - @Deprecated(since = "6.7.0", forRemoval = true) - public void expectMax(String name, double maxLength, String message) { - String value = Optional.ofNullable(get(name)).orElse(""); - - if (StringUtils.isNumeric(value)) { - if (Double.parseDouble(value) > maxLength) { - addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.MAX_KEY.toString(), name, maxLength))); - } - } else { - if (value.length() > maxLength) { - addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.MAX_KEY.toString(), name, maxLength))); - } - } - } - /** * Validates a given field to have a maximum length * @@ -454,21 +376,6 @@ public void expectIpv6(String name, String message) { addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.IPV6_KEY.toString(), name))); } } - - /** - * Validates a field to be in a certain range - * - * @deprecated - * Use {@link #expectRangeLength(String, int, int)} or {@link #expectRangeValue(String, int, int)} instead - * - * @param name The field to check - * @param minLength The minimum length - * @param maxLength The maximum length - */ - @Deprecated(since = "6.7.0", forRemoval = true) - public void expectRange(String name, int minLength, int maxLength) { - expectRange(name, minLength, maxLength, null); - } /** * Validates a field to be in a certain range length @@ -528,33 +435,6 @@ public void expectRangeLength(String name, int minLength, int maxLength, String addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.RANGE_LENGTH_KEY.toString(), name, minLength, maxLength))); } } - - /** - * Validates a field to be in a certain range - * - * @deprecated - * Use {@link #expectRangeLength(String, int, int, String)} or {@link #expectRangeValue(String, int, int, String)} instead - * - * @param name The field to check - * @param minLength The minimum length - * @param maxLength The maximum length - * @param message A custom error message instead of the default one - */ - @Deprecated(since = "6.7.0", forRemoval = true) - public void expectRange(String name, int minLength, int maxLength, String message) { - String value = Optional.ofNullable(get(name)).orElse(""); - - if (StringUtils.isNumeric(value)) { - double doubleValue = Double.parseDouble(value); - if (doubleValue < minLength || doubleValue > maxLength) { - addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.RANGE_KEY.toString(), name, minLength, maxLength))); - } - } else { - if (value.length() < minLength || value.length() > maxLength) { - addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.RANGE_KEY.toString(), name, minLength, maxLength))); - } - } - } /** * Validates a field by a given regular expression pattern @@ -609,131 +489,6 @@ public void expectUrl(String name, String message) { addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.URL_KEY.toString(), name))); } } - - /** - * Validates a given value to be true - * - * @deprecated - * Use {@link #expectTrue(String, boolean, String)} instead - * - * @param value The value to check - * @param name The name of the field to display the error message - * @param message A custom error message instead of the default one - */ - @Deprecated(since = "6.7.0", forRemoval = true) - public void validateTrue(boolean value, String name, String message) { - if (!value) { - addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.TRUE_KEY.toString(), name))); - } - } - - /** - * Validates a given value to be true - * - * @deprecated - * Use {@link #expectTrue(String, boolean)} instead - * - * @param value The value to check - * @param name The name of the field to display the error message - */ - @Deprecated(since = "6.7.0", forRemoval = true) - public void validateTrue(boolean value, String name) { - validateTrue(value, name, null); - } - - /** - * Validates a given value to be false - * - * @deprecated - * Use {@link #expectFalse(String, boolean, String)} instead - * - * @param value The value to check - * @param name The name of the field to display the error message - * @param message A custom error message instead of the default one - */ - @SuppressWarnings("all") - @Deprecated(since = "6.7.0", forRemoval = true) - public void validateFalse(boolean value, String name, String message) { - if (value) { - addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.FALSE_KEY.toString(), name))); - } - } - - /** - * Validates a given value to be false - * - * @deprecated - * Use {@link #expectFalse(String, boolean)} instead - * - * @param value The value to check - * @param name The name of the field to display the error message - */ - @Deprecated(since = "6.7.0", forRemoval = true) - public void validateFalse(boolean value, String name) { - validateFalse(value, name, null); - } - - /** - * Validates a given object to be not null - * - * @deprecated - * Use {@link #expectNotNull(String, Object, String)} instead - * - * @param object The object to check - * @param name The name of the field to display the error message - * @param message A custom error message instead of the default one - */ - @Deprecated(since = "6.7.0", forRemoval = true) - public void validateNotNull(Object object, String name, String message) { - if (object == null) { - addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.NOTNULL_KEY.toString(), name))); - } - } - - /** - * Validates a given object to be not null - * - * @deprecated - * Use {@link #expectNotNull(String, Object)} instead - * - * @param object The object to check - * @param name The name of the field to display the error message - */ - @Deprecated(since = "6.7.0", forRemoval = true) - public void validateNotNull(Object object, String name) { - validateNotNull(object, name, null); - } - - /** - * Validates a given object to be null - * - * @deprecated - * Use {@link #expectNull(String, Object, String)} instead - * - * @param object The object to check - * @param name The name of the field to display the error message - * @param message A custom error message instead of the default one - */ - @Deprecated(since = "6.7.0", forRemoval = true) - public void validateNull(Object object, String name, String message) { - if (object != null) { - addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.NULL_KEY.toString(), name))); - } - } - - /** - * Validates a given object to be null - * - * @deprecated - * Use {@link #expectNull(String, Object)} instead - * - * @param object The object to check - * @param name The name of the field to display the error message - */ - @Deprecated(since = "6.7.0", forRemoval = true) - public void validateNull(Object object, String name) { - validateNull(object, name, null); - } /** * Validates a given value to be true diff --git a/mangooio-core/src/main/java/io/mangoo/routing/handlers/DispatcherHandler.java b/mangooio-core/src/main/java/io/mangoo/routing/handlers/DispatcherHandler.java index ce7e343738..a942a5892d 100644 --- a/mangooio-core/src/main/java/io/mangoo/routing/handlers/DispatcherHandler.java +++ b/mangooio-core/src/main/java/io/mangoo/routing/handlers/DispatcherHandler.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.Objects; +import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -58,7 +59,6 @@ public class DispatcherHandler implements HttpHandler { private boolean requestFilter; private boolean blocking; private boolean authentication; - private boolean authorization; public DispatcherHandler dispatch(Class controllerClass, String controllerMethodName) { Objects.requireNonNull(controllerClass, Required.CONTROLLER_CLASS.toString()); @@ -118,11 +118,6 @@ public DispatcherHandler withMaxEntitySize(long maxEntitySize) { return this; } - public DispatcherHandler withAuthorization(boolean authorization) { - this.authorization = authorization; - return this; - } - public DispatcherHandler withLimit(int limit) { this.limit = limit; return this; @@ -154,7 +149,6 @@ public void handleRequest(HttpServerExchange exchange) throws Exception { .withMessages(this.messages) .withLimit(this.limit) .withAuthentication(this.authentication) - .withAuthorization(this.authorization) .withBasicAuthentication(this.username, this.password) .withTemplateEngine(this.templateEngine); @@ -186,6 +180,15 @@ private Map> getMethodParameters() { * @throws Exception Thrown when an exception occurs */ private void nextHandler(HttpServerExchange exchange) throws Exception { - Application.getInstance(LimitHandler.class).handleRequest(exchange); + if (StringUtils.isNotBlank(this.username) && StringUtils.isNotBlank(this.password)) { + HttpHandler httpHandler = RequestUtils.wrapBasicAuthentication( + Application.getInstance(LocaleHandler.class), + this.username, + this.password); + + httpHandler.handleRequest(exchange); + } else { + Application.getInstance(LocaleHandler.class).handleRequest(exchange); + } } } \ No newline at end of file diff --git a/mangooio-core/src/main/java/io/mangoo/routing/handlers/LimitHandler.java b/mangooio-core/src/main/java/io/mangoo/routing/handlers/LimitHandler.java deleted file mode 100644 index 37237ac94f..0000000000 --- a/mangooio-core/src/main/java/io/mangoo/routing/handlers/LimitHandler.java +++ /dev/null @@ -1,120 +0,0 @@ -package io.mangoo.routing.handlers; - -import java.net.InetSocketAddress; -import java.util.Locale; -import java.util.Objects; - -import org.apache.commons.lang3.StringUtils; - -import com.google.inject.Inject; - -import io.mangoo.cache.Cache; -import io.mangoo.cache.CacheProvider; -import io.mangoo.core.Application; -import io.mangoo.enums.CacheName; -import io.mangoo.enums.Header; -import io.mangoo.enums.Required; -import io.mangoo.enums.Template; -import io.mangoo.routing.Attachment; -import io.mangoo.utils.RequestUtils; -import io.undertow.server.HttpHandler; -import io.undertow.server.HttpServerExchange; -import io.undertow.util.HeaderMap; -import io.undertow.util.HeaderValues; -import io.undertow.util.StatusCodes; - -/** - * - * @author svenkubiak - * - */ -public class LimitHandler implements HttpHandler { - private Attachment attachment; - private Cache cache; - - @Inject - public LimitHandler(CacheProvider cacheProvider) { - Objects.requireNonNull(cacheProvider, Required.CACHE_PROVIDER.toString()); - this.cache = cacheProvider.getCache(CacheName.REQUEST); - } - - @Override - public void handleRequest(HttpServerExchange exchange) throws Exception { - attachment = exchange.getAttachment(RequestUtils.getAttachmentKey()); - if (attachment.hasLimit()) { - String key = getCacheKey(exchange); - if (cache.getAndIncrementCounter(key).get() > attachment.getLimit()) { - endRequest(exchange); - } else { - nextHandler(exchange); - } - } else { - nextHandler(exchange); - } - } - - /** - * Creates a key used for limiting a request containing the requested URL and the source host - * - * @param exchange The HttpServerExchange - * @return The key (URL + host) - */ - private String getCacheKey(HttpServerExchange exchange) { - String host = ""; - - HeaderMap headerMap = exchange.getRequestHeaders(); - if (headerMap != null) { - HeaderValues headerValues = headerMap.get(Header.X_FORWARDED_FOR.toHttpString()); - if (headerValues != null) { - host = headerValues.element(); - } - } - - if (StringUtils.isBlank(host)) { - InetSocketAddress inetSocketAddress = exchange.getSourceAddress(); - if (inetSocketAddress != null) { - host = inetSocketAddress.getHostString(); - } - } - - if (StringUtils.isNotBlank(host)) { - host = host.toLowerCase(Locale.ENGLISH); - } - - String url = exchange.getRequestURL(); - if (StringUtils.isNotBlank(url)) { - url = url.toLowerCase(Locale.ENGLISH); - } - - return url + host; - } - - /** - * Ends the current request by sending a HTTP 429 status code - * @param exchange The HttpServerExchange - */ - private void endRequest(HttpServerExchange exchange) { - exchange.setStatusCode(StatusCodes.TOO_MANY_REQUESTS); - exchange.getResponseSender().send(Template.DEFAULT.tooManyRequests()); - exchange.endExchange(); - } - - /** - * Handles the next request in the handler chain - * - * @param exchange The HttpServerExchange - * @throws Exception Thrown when an exception occurs - */ - protected void nextHandler(HttpServerExchange exchange) throws Exception { - if (attachment.hasBasicAuthentication()) { - HttpHandler httpHandler = RequestUtils.wrapBasicAuthentication( - Application.getInstance(LocaleHandler.class), - attachment.getUsername(), - attachment.getPassword()); - - httpHandler.handleRequest(exchange); - } else { - Application.getInstance(LocaleHandler.class).handleRequest(exchange); - } - } -} \ No newline at end of file diff --git a/mangooio-core/src/main/java/io/mangoo/routing/routes/ControllerRoute.java b/mangooio-core/src/main/java/io/mangoo/routing/routes/ControllerRoute.java index c9dba9b340..755c1345cb 100644 --- a/mangooio-core/src/main/java/io/mangoo/routing/routes/ControllerRoute.java +++ b/mangooio-core/src/main/java/io/mangoo/routing/routes/ControllerRoute.java @@ -54,18 +54,10 @@ public void withRoutes(MangooRoute... routes) { requestRoute.withAuthentication(); } - if (hasAuthorization()) { - requestRoute.withAuthorization(); - } - if (hasBlocking()) { requestRoute.withNonBlocking(); } - if (requestRoute.getLimit() == 0) { - requestRoute.withRequestLimit(limit); - } - if (requestRoute.hasMultipleMethods()) { for (Http method : requestRoute.getMethods()) { requestRoute.withHttpMethod(method); diff --git a/mangooio-core/src/main/java/io/mangoo/routing/routes/RequestRoute.java b/mangooio-core/src/main/java/io/mangoo/routing/routes/RequestRoute.java index 9940b26cdc..714d91a0c5 100644 --- a/mangooio-core/src/main/java/io/mangoo/routing/routes/RequestRoute.java +++ b/mangooio-core/src/main/java/io/mangoo/routing/routes/RequestRoute.java @@ -26,7 +26,6 @@ public class RequestRoute implements MangooRoute { private long maxEntitySize; private boolean blocking; private boolean authentication; - private boolean authorization; public RequestRoute(Http method) { Objects.requireNonNull(method, Required.HTTP_METHOD.toString()); @@ -69,17 +68,6 @@ public RequestRoute respondeWith(String method) { return this; } - /** - * Sets a request limit to the request - * - * @param limit Maximum numbers of request in a 60 seconds window - * @return RequestRoute instance - */ - public RequestRoute withRequestLimit(int limit) { - this.limit = limit; - return this; - } - /** * Sets the controller class of this request * @@ -128,18 +116,6 @@ public RequestRoute withAuthentication() { return this; } - /** - * Sets authorization to true for this route, default is false - * Also sets authentication to true, default is false - * - * @return RequestRoute instance - */ - public RequestRoute withAuthorization() { - this.authentication = true; - this.authorization = true; - return this; - } - /** * Configures this request as long running request that is * executed in a different thread pool to not block the @@ -175,10 +151,6 @@ public String getUrl() { public boolean hasAuthentication() { return authentication; } - - public boolean hasAuthorization() { - return authorization; - } public boolean hasBasicAuthentication() { return StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password); diff --git a/mangooio-integration-test/src/main/java/app/Bootstrap.java b/mangooio-integration-test/src/main/java/app/Bootstrap.java index a1f453b97a..f38ea26cd7 100644 --- a/mangooio-integration-test/src/main/java/app/Bootstrap.java +++ b/mangooio-integration-test/src/main/java/app/Bootstrap.java @@ -135,7 +135,6 @@ public void initializeRoutes() { On.get().to("/prettytime").respondeWith("prettytime"), On.get().to("/location/{myloca}").respondeWith("location"), On.get().to("/redirect").respondeWith("redirect"), - On.get().to("/limit").respondeWith("limit").withRequestLimit(10), On.get().to("/text").respondeWith("text"), On.get().to("/forbidden").respondeWith("forbidden"), On.get().to("/badrequest").respondeWith("badrequest"), diff --git a/mangooio-integration-test/src/test/java/io/mangoo/controllers/ApplicationControllerTest.java b/mangooio-integration-test/src/test/java/io/mangoo/controllers/ApplicationControllerTest.java index 0768678830..52029edcbe 100644 --- a/mangooio-integration-test/src/test/java/io/mangoo/controllers/ApplicationControllerTest.java +++ b/mangooio-integration-test/src/test/java/io/mangoo/controllers/ApplicationControllerTest.java @@ -140,22 +140,6 @@ public void testPrettyTime() { assertThat(response.getContent(), containsString("vor")); assertThat(response.getContent(), containsString("Stunden")); } - - @Test - public void testLimit() { - //given - TestResponse response = null; - - //then - for (int i=0; i < 10; i++) { - response = TestRequest.get("/limit").execute(); - assertThat(response, not(nullValue())); - assertThat(response.getStatusCode(), equalTo(StatusCodes.OK)); - } - response = TestRequest.get("/limit").execute(); - assertThat(response, not(nullValue())); - assertThat(response.getStatusCode(), equalTo(StatusCodes.TOO_MANY_REQUESTS)); - } @Test public void testRequest() { diff --git a/mangooio-integration-test/src/test/java/io/mangoo/routing/AttachmentTest.java b/mangooio-integration-test/src/test/java/io/mangoo/routing/AttachmentTest.java index c81975412d..da4bf7159f 100644 --- a/mangooio-integration-test/src/test/java/io/mangoo/routing/AttachmentTest.java +++ b/mangooio-integration-test/src/test/java/io/mangoo/routing/AttachmentTest.java @@ -62,6 +62,5 @@ public void testCreateAttachment() { assertThat(attachment.getRequestParameter(), instanceOf(HashMap.class)); assertThat(attachment.getTemplateEngine(), instanceOf(TemplateEngine.class)); assertThat(attachment.getUsername(), equalTo("peter")); - assertThat(attachment.hasBasicAuthentication(), equalTo(true)); } } \ No newline at end of file diff --git a/mangooio-integration-test/src/test/java/io/mangoo/routing/bindings/InjectionTest.java b/mangooio-integration-test/src/test/java/io/mangoo/routing/bindings/InjectionTest.java index 3f0f74ebe8..6d302ce06f 100644 --- a/mangooio-integration-test/src/test/java/io/mangoo/routing/bindings/InjectionTest.java +++ b/mangooio-integration-test/src/test/java/io/mangoo/routing/bindings/InjectionTest.java @@ -22,7 +22,6 @@ import io.mangoo.routing.handlers.ExceptionHandler; import io.mangoo.routing.handlers.FallbackHandler; import io.mangoo.routing.handlers.InboundCookiesHandler; -import io.mangoo.routing.handlers.LimitHandler; import io.mangoo.routing.handlers.LocaleHandler; import io.mangoo.routing.handlers.OutboundCookiesHandler; import io.mangoo.routing.handlers.ResponseHandler; @@ -241,16 +240,7 @@ public void testValidator() { //then assertThat(validator, not(nullValue())); } - - @Test - public void testLimitHandler() { - //given - LimitHandler limitHandler = Application.getInstance(LimitHandler.class); - - //then - assertThat(limitHandler, not(nullValue())); - } - + @Test public void testLocaleHandler() { //given diff --git a/mangooio-integration-test/src/test/java/io/mangoo/routing/routes/ControllerRouteTest.java b/mangooio-integration-test/src/test/java/io/mangoo/routing/routes/ControllerRouteTest.java index 7a12048fa6..513556710a 100644 --- a/mangooio-integration-test/src/test/java/io/mangoo/routing/routes/ControllerRouteTest.java +++ b/mangooio-integration-test/src/test/java/io/mangoo/routing/routes/ControllerRouteTest.java @@ -113,7 +113,6 @@ public void testWithAuthorization() { RequestRoute requestRoute = collectedRoutes.iterator().next(); assertThat(requestRoute.hasAuthentication(), equalTo(true)); - assertThat(requestRoute.hasAuthorization(), equalTo(true)); } @Test @@ -158,25 +157,4 @@ public void testUrl() { assertThat(requestRoute.getUrl(), equalTo("/" + url)); } - - @Test - public void testWithLimit() { - //given - String route1 = UUID.randomUUID().toString(); - - //when - ControllerRoute route = new ControllerRoute(ApplicationController.class); - route.withRequestLimit(42).withRoutes( - On.get().to("/route1").respondeWith(route1) - ); - - //then - Set collectedRoutes = Router.getRequestRoutes() - .filter(r -> r.getControllerMethod().equals(route1)) - .collect(Collectors.toSet()); - - RequestRoute requestRoute = collectedRoutes.iterator().next(); - - assertThat(requestRoute.getLimit(), equalTo(42)); - } } \ No newline at end of file diff --git a/mangooio-integration-test/src/test/java/io/mangoo/routing/routes/RequestRouteTest.java b/mangooio-integration-test/src/test/java/io/mangoo/routing/routes/RequestRouteTest.java index bf77664103..0a8d8c0937 100644 --- a/mangooio-integration-test/src/test/java/io/mangoo/routing/routes/RequestRouteTest.java +++ b/mangooio-integration-test/src/test/java/io/mangoo/routing/routes/RequestRouteTest.java @@ -31,19 +31,6 @@ public void testTo() { assertThat(requestRoute.getUrl(), equalTo("/bar")); } - @Test - public void testAuthorization() { - //given - RequestRoute requestRoute = new RequestRoute(Http.GET); - - //when - requestRoute.withAuthorization(); - - //then - assertThat(requestRoute.hasAuthentication(), equalTo(true)); - assertThat(requestRoute.hasAuthorization(), equalTo(true)); - } - @Test public void testAuthentication() { //given @@ -54,7 +41,6 @@ public void testAuthentication() { //then assertThat(requestRoute.hasAuthentication(), equalTo(true)); - assertThat(requestRoute.hasAuthorization(), equalTo(false)); } @Test @@ -80,17 +66,4 @@ public void testNonBlocking() { //then assertThat(requestRoute.isBlocking(), equalTo(true)); } - - @Test - public void testWithLimit() { - //given - RequestRoute requestRoute = new RequestRoute(Http.GET); - requestRoute.to("/foo"); - - //when - requestRoute.withRequestLimit(42); - - //then - assertThat(requestRoute.getLimit(), equalTo(42)); - } } \ No newline at end of file diff --git a/mangooio-integration-test/src/test/java/io/mangoo/utils/CodecUtilsTest.java b/mangooio-integration-test/src/test/java/io/mangoo/utils/CodecUtilsTest.java index 17267a5b2c..f741ed2fb7 100644 --- a/mangooio-integration-test/src/test/java/io/mangoo/utils/CodecUtilsTest.java +++ b/mangooio-integration-test/src/test/java/io/mangoo/utils/CodecUtilsTest.java @@ -19,7 +19,7 @@ @ExtendWith({TestExtension.class}) public class CodecUtilsTest { - private static final String SERIALIZED = "rO0ABXNyAB9pby5tYW5nb28ucm91dGluZy5iaW5kaW5ncy5Gb3Jtr0x38MTUh5ACAANaAARrZWVwWgAJc3VibWl0dGVkTAAIdmFsdWVNYXB0AA9MamF2YS91dGlsL01hcDt4cgAkaW8ubWFuZ29vLnJvdXRpbmcuYmluZGluZ3MuVmFsaWRhdG9y3cEYQhBJCTwCAANMAAZlcnJvcnNxAH4AAUwACG1lc3NhZ2VzdAAZTGlvL21hbmdvby9pMThuL01lc3NhZ2VzO0wABnZhbHVlc3EAfgABeHBzcgARamF2YS51dGlsLkhhc2hNYXAFB9rBwxZg0QMAAkYACmxvYWRGYWN0b3JJAAl0aHJlc2hvbGR4cD9AAAAAAAAAdwgAAAAQAAAAAHhzcg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24ubWluLmxlbmd0aHQALHswfSBtdXN0IGJlIGEgdmFsdWUgd2l0aCBhIG1pbiBsZW5ndGggb2YgezF9dAAOdmFsaWRhdGlvbi51cmx0ABd7MH0gbXVzdCBiZSBhIHZhbGlkIFVSTHQAFXZhbGlkYXRpb24ubWF4Lmxlbmd0aHQALHswfSBtdXN0IGJlIGEgdmFsdWUgd2l0aCBhIG1heCBsZW5ndGggb2YgezF9dAAWdmFsaWRhdGlvbi5tYXRjaHZhbHVlc3QAHlRoZSB2YWx1ZXMgb2YgezB9IGlzIG5vdCB2YWxpZHhzcQB+AAU/QAAAAAAADHcIAAAAEAAAAAF0AANmb290AANiYXJ4AABzcQB+AAU/QAAAAAAAAHcIAAAAEAAAAAB4"; private static final String PLAIN = "this is a plain text"; private static final String JBCRYPT_HASH = "$2a$12$I.tRIbGLB82DDLUHTz.IUOSGeHCwUgX/MnGj67SRFvfzoNZzx2je6";