From 681c15609a36068a5a96e913581e3fe6c45bfc23 Mon Sep 17 00:00:00 2001 From: Valery Yatsynovich Date: Fri, 26 Jul 2024 11:56:14 +0300 Subject: [PATCH] Re-group HTTP steps and related logic (#5243) --- .../plugins/pages/plugin-rest-api.adoc | 24 ++++ .../pages/plugin-web-app-to-rest-api.adoc | 25 +--- .../vividus/http/HttpRedirectsProvider.java | 0 .../http/PublishingAttachmentInterceptor.java | 4 +- .../steps/ByteArrayValidationRule.java | 8 +- .../api => http/steps}/HttpCookieSteps.java | 4 +- .../api => http/steps}/HttpRequestSteps.java | 85 +++++++++++- .../steps}/HttpResourceValidationSteps.java | 9 +- .../steps}/HttpResponseValidationSteps.java | 5 +- .../steps}/JsonResponseValidationSteps.java | 4 +- .../{steps/api => http/steps}/JwtSteps.java | 4 +- .../http/steps}/RedirectValidationSteps.java | 122 +++++++++++++++++- .../AbstractResourceValidation.java | 2 +- .../validation/{model => }/CheckStatus.java | 4 +- .../{model => }/ResourceValidation.java | 4 +- .../http/validation/ResourceValidator.java | 2 - .../org/vividus/model/RequestPartType.java | 102 --------------- .../{steps/ssl => ssl/steps}/SslSteps.java | 4 +- .../{ => steps}/attachment/api-message.ftl | 0 .../http-resources-validation-results.ftl | 0 .../redirect-validation-test-report.ftl | 0 .../resources-response-body-fragment.ftl | 0 .../properties/defaults/default.properties | 2 + .../main/resources/vividus-plugin/spring.xml | 112 +++++++++------- .../http/HttpRedirectsProviderTests.java | 0 .../PublishingAttachmentInterceptorTests.java | 6 +- .../PkceExpressionProcessorTests.java | 9 +- .../steps/ByteArrayValidationRuleTests.java | 4 +- .../steps}/HttpCookieStepsTests.java | 4 +- .../steps}/HttpRequestStepsTests.java | 4 +- .../HttpResourceValidationStepsTests.java | 15 ++- .../HttpResponseValidationStepsTests.java | 5 +- .../JsonResponseValidationStepsTests.java | 4 +- .../api => http/steps}/JwtStepsTests.java | 4 +- .../steps}/RedirectValidationStepsTests.java | 27 ++-- .../steps}/RequestPartTypeTests.java | 36 +++--- .../validation/ResourceValidatorTests.java | 2 - .../ssl => ssl/steps}/SslStepsTests.java | 4 +- .../vividus/{steps/api => http/steps}/swf.swf | Bin .../org/vividus/http/ExpectedRedirect.java | 59 --------- .../vividus/http/RedirectValidationState.java | 93 ------------- .../steps/integration/ResourceCheckSteps.java | 2 +- .../model/ResourceValidationError.java | 2 +- .../model/WebPageResourceValidation.java | 4 +- .../properties/defaults/default.properties | 2 - .../resources/resources-validation-result.ftl | 2 +- .../main/resources/vividus-plugin/spring.xml | 17 --- .../integration/ResourceCheckStepsTests.java | 2 +- ...dationSteps.story => HTTP Redirects.story} | 2 +- 49 files changed, 384 insertions(+), 451 deletions(-) rename {vividus-plugin-web-app-to-rest-api => vividus-plugin-rest-api}/src/main/java/org/vividus/http/HttpRedirectsProvider.java (100%) rename vividus-plugin-rest-api/src/main/java/org/vividus/{ => http}/steps/ByteArrayValidationRule.java (89%) rename vividus-plugin-rest-api/src/main/java/org/vividus/{steps/api => http/steps}/HttpCookieSteps.java (98%) rename vividus-plugin-rest-api/src/main/java/org/vividus/{steps/api => http/steps}/HttpRequestSteps.java (81%) rename vividus-plugin-rest-api/src/main/java/org/vividus/{steps/http => http/steps}/HttpResourceValidationSteps.java (90%) rename vividus-plugin-rest-api/src/main/java/org/vividus/{steps/api => http/steps}/HttpResponseValidationSteps.java (99%) rename vividus-plugin-rest-api/src/main/java/org/vividus/{steps/api => http/steps}/JsonResponseValidationSteps.java (98%) rename vividus-plugin-rest-api/src/main/java/org/vividus/{steps/api => http/steps}/JwtSteps.java (97%) rename {vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/steps/integration => vividus-plugin-rest-api/src/main/java/org/vividus/http/steps}/RedirectValidationSteps.java (71%) rename vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/{model => }/AbstractResourceValidation.java (98%) rename vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/{model => }/CheckStatus.java (89%) rename vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/{model => }/ResourceValidation.java (92%) delete mode 100644 vividus-plugin-rest-api/src/main/java/org/vividus/model/RequestPartType.java rename vividus-plugin-rest-api/src/main/java/org/vividus/{steps/ssl => ssl/steps}/SslSteps.java (96%) rename vividus-plugin-rest-api/src/main/resources/org/vividus/http/{ => steps}/attachment/api-message.ftl (100%) rename vividus-plugin-rest-api/src/main/resources/{ => org/vividus/http/steps/attachment}/http-resources-validation-results.ftl (100%) rename {vividus-plugin-web-app-to-rest-api/src/main/resources/org/vividus/steps/integration => vividus-plugin-rest-api/src/main/resources/org/vividus/http/steps/attachment}/redirect-validation-test-report.ftl (100%) rename vividus-plugin-rest-api/src/main/resources/{ => org/vividus/http/steps/attachment}/resources-response-body-fragment.ftl (100%) rename {vividus-plugin-web-app-to-rest-api => vividus-plugin-rest-api}/src/test/java/org/vividus/http/HttpRedirectsProviderTests.java (100%) rename vividus-plugin-rest-api/src/test/java/org/vividus/{ => http}/steps/ByteArrayValidationRuleTests.java (97%) rename vividus-plugin-rest-api/src/test/java/org/vividus/{steps/api => http/steps}/HttpCookieStepsTests.java (98%) rename vividus-plugin-rest-api/src/test/java/org/vividus/{steps/api => http/steps}/HttpRequestStepsTests.java (99%) rename vividus-plugin-rest-api/src/test/java/org/vividus/{steps/http => http/steps}/HttpResourceValidationStepsTests.java (86%) rename vividus-plugin-rest-api/src/test/java/org/vividus/{steps/api => http/steps}/HttpResponseValidationStepsTests.java (99%) rename vividus-plugin-rest-api/src/test/java/org/vividus/{steps/api => http/steps}/JsonResponseValidationStepsTests.java (98%) rename vividus-plugin-rest-api/src/test/java/org/vividus/{steps/api => http/steps}/JwtStepsTests.java (95%) rename {vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/steps/integration => vividus-plugin-rest-api/src/test/java/org/vividus/http/steps}/RedirectValidationStepsTests.java (93%) rename vividus-plugin-rest-api/src/test/java/org/vividus/{model => http/steps}/RequestPartTypeTests.java (69%) rename vividus-plugin-rest-api/src/test/java/org/vividus/{steps/ssl => ssl/steps}/SslStepsTests.java (96%) rename vividus-plugin-rest-api/src/test/resources/org/vividus/{steps/api => http/steps}/swf.swf (100%) delete mode 100644 vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/http/ExpectedRedirect.java delete mode 100644 vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/http/RedirectValidationState.java rename vividus-tests/src/main/resources/story/integration/{RedirectValidationSteps.story => HTTP Redirects.story} (94%) diff --git a/docs/modules/plugins/pages/plugin-rest-api.adoc b/docs/modules/plugins/pages/plugin-rest-api.adoc index 37b8596cc7..82dc98c73f 100644 --- a/docs/modules/plugins/pages/plugin-rest-api.adoc +++ b/docs/modules/plugins/pages/plugin-rest-api.adoc @@ -873,6 +873,30 @@ Then HTTP resources are valid: | https://vividus-test-site-a92k.onrender.com/img/vividus.png | ---- +=== Validate redirects + +Check that all URLs from xref:ROOT:glossary.adoc#_examplestable[ExamplesTable] redirect to proper pages with correct redirects number. Validation fails if either actual final URL or number of redirects do not match the expected values. + +NOTE: The step throws the error in case if https://developer.mozilla.org/en-US/docs/Web/HTTP/Status[HTTP response status code] of checked URL out of range 200-207. + +[source,gherkin] +---- +Then I validate HTTP redirects:$expectedRedirects +---- + +. `$expectedRedirects` - The xref:ROOT:glossary.adoc#_examplestable[ExamplesTable] with redirect parameters containing the following columns: +** [subs=+quotes]`*startUrl*` - The URL from which redirection starts. +** [subs=+quotes]`*endUrl*` - The expected final URL to redirect to. +** [subs=+quotes]`*redirectsNumber*` - The expected number of redirects between `startUrl` and `endUrl` (optional). + +.Validate redirects +[source,gherkin] +---- +Then I validate HTTP redirects: +|startUrl |endUrl |redirectsNumber | +|http://example.com/redirect |http://example.com/get-response |1 | +---- + == HTTP cookie steps diff --git a/docs/modules/plugins/pages/plugin-web-app-to-rest-api.adoc b/docs/modules/plugins/pages/plugin-web-app-to-rest-api.adoc index 3a1c658ce4..4f487d216e 100644 --- a/docs/modules/plugins/pages/plugin-web-app-to-rest-api.adoc +++ b/docs/modules/plugins/pages/plugin-web-app-to-rest-api.adoc @@ -502,27 +502,10 @@ Then all resources found by CSS selector `a,img` in ${source-code} are valid === Validate redirects -Check that all URLs from xref:ROOT:glossary.adoc#_examplestable[ExamplesTable] redirect to proper pages with correct redirects number. Validation fails if either actual final URL or number of redirects do not match the expected values. - -NOTE: The step throws the error in case if https://developer.mozilla.org/en-US/docs/Web/HTTP/Status[HTTP response status code] of checked URL out of range 200-207. - -[source,gherkin] ----- -Then I validate HTTP redirects: $expectedRedirects ----- - -. `$expectedRedirects` - The xref:ROOT:glossary.adoc#_examplestable[ExamplesTable] with redirect parameters containing the following columns: -** [subs=+quotes]`*startUrl*` - The URL from which redirection starts. -** [subs=+quotes]`*endUrl*` - The expected final URL to redirect to. -** [subs=+quotes]`*redirectsNumber*` - The expected number of redirects between `startUrl` and `endUrl` (optional). - -.Validate redirects -[source,gherkin] ----- -Then I validate HTTP redirects: -|startUrl |endUrl |redirectsNumber | -|http://example.com/redirect |http://example.com/get-response |1 | ----- +[WARNING] +==== +The step xref:plugins:plugin-rest-api.adoc#_validate_redirects[has been moved] to `vividus-plugin-rest-api`. +==== === Validate SSL rating diff --git a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/http/HttpRedirectsProvider.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/HttpRedirectsProvider.java similarity index 100% rename from vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/http/HttpRedirectsProvider.java rename to vividus-plugin-rest-api/src/main/java/org/vividus/http/HttpRedirectsProvider.java diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/http/PublishingAttachmentInterceptor.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/PublishingAttachmentInterceptor.java index 02373c8701..eb8c301e8f 100644 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/http/PublishingAttachmentInterceptor.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/http/PublishingAttachmentInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,6 +95,6 @@ private void attachApiMessage(String title, Header[] headers, byte[] body, Strin dataMap.put("bodyContentType", mimeType); dataMap.put("statusCode", statusCode); - attachmentPublisher.publishAttachment("/org/vividus/http/attachment/api-message.ftl", dataMap, title); + attachmentPublisher.publishAttachment("/org/vividus/http/steps/attachment/api-message.ftl", dataMap, title); } } diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/ByteArrayValidationRule.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/ByteArrayValidationRule.java similarity index 89% rename from vividus-plugin-rest-api/src/main/java/org/vividus/steps/ByteArrayValidationRule.java rename to vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/ByteArrayValidationRule.java index e83ab33e6e..6a71878861 100644 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/ByteArrayValidationRule.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/ByteArrayValidationRule.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2021 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps; +package org.vividus.http.steps; import org.hamcrest.Matchers; import org.vividus.softassert.ISoftAssert; @@ -30,7 +30,7 @@ public void assertMatchesRule(ISoftAssert softAssert, byte[] expected, byte[] ac { if (Matchers.equalTo(expected).matches(actual)) { - softAssert.recordPassedAssertion(ByteArrayValidationRule.ARRAYS_ARE_EQUAL); + softAssert.recordPassedAssertion(ARRAYS_ARE_EQUAL); } else { @@ -59,7 +59,7 @@ public void assertMatchesRule(ISoftAssert softAssert, byte[] expected, byte[] ac } else { - softAssert.recordFailedAssertion(ByteArrayValidationRule.ARRAYS_ARE_EQUAL); + softAssert.recordFailedAssertion(ARRAYS_ARE_EQUAL); } } }; diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/HttpCookieSteps.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/HttpCookieSteps.java similarity index 98% rename from vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/HttpCookieSteps.java rename to vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/HttpCookieSteps.java index 7fb888259d..abb4811887 100644 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/HttpCookieSteps.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/HttpCookieSteps.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.api; +package org.vividus.http.steps; import static org.hamcrest.Matchers.greaterThan; diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/HttpRequestSteps.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/HttpRequestSteps.java similarity index 81% rename from vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/HttpRequestSteps.java rename to vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/HttpRequestSteps.java index c25fdf8ec9..923ffaa568 100644 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/HttpRequestSteps.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/HttpRequestSteps.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.api; +package org.vividus.http.steps; import static java.util.stream.Collectors.toList; @@ -27,11 +27,14 @@ import java.util.function.Consumer; import java.util.stream.Collectors; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; +import org.apache.hc.client5.http.entity.mime.ByteArrayBody; import org.apache.hc.client5.http.entity.mime.ContentBody; import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; +import org.apache.hc.client5.http.entity.mime.StringBody; import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpEntity; @@ -48,8 +51,8 @@ import org.vividus.http.HttpMethod; import org.vividus.http.HttpRequestExecutor; import org.vividus.http.HttpTestContext; -import org.vividus.model.RequestPartType; import org.vividus.steps.DataWrapper; +import org.vividus.util.ResourceUtils; public class HttpRequestSteps { @@ -273,4 +276,80 @@ public void setApiEndpoint(String apiEndpoint) { this.apiEndpoint = apiEndpoint; } + + public enum RequestPartType + { + STRING + { + @Override + public ContentType getDefaultContentType() + { + return ContentType.DEFAULT_TEXT; + } + + @Override + public ContentBody createPart(String value, ContentType contentType) + { + return new StringBody(value, contentType); + } + + @Override + public ContentBody createPart(String value, ContentType contentType, String fileName) + { + throw new IllegalArgumentException( + String.format("'fileName' parameter is not allowed for %s request part type", name())); + } + }, + FILE + { + @Override + public ContentType getDefaultContentType() + { + return ContentType.DEFAULT_BINARY; + } + + @Override + public ContentBody createPart(String value, ContentType contentType) throws IOException + { + String fileName = FilenameUtils.getName(value); + return createPart(value, contentType, fileName); + } + + @Override + public ContentBody createPart(String value, ContentType contentType, String fileName) throws IOException + { + byte[] byteArray = ResourceUtils.loadResourceOrFileAsByteArray(value); + return new ByteArrayBody(byteArray, contentType, fileName); + } + }, + BINARY + { + @Override + public ContentType getDefaultContentType() + { + return ContentType.DEFAULT_BINARY; + } + + @Override + public ContentBody createPart(String value, ContentType contentType) + { + throw new IllegalArgumentException( + String.format("'fileName' parameter is required for %s request part type", name())); + } + + @Override + public ContentBody createPart(String value, ContentType contentType, String fileName) + { + byte[] byteArray = value.getBytes(StandardCharsets.UTF_8); + return new ByteArrayBody(byteArray, contentType, fileName); + } + }; + + public abstract ContentType getDefaultContentType(); + + public abstract ContentBody createPart(String value, ContentType contentType) throws IOException; + + public abstract ContentBody createPart(String value, ContentType contentType, String fileName) + throws IOException; + } } diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/http/HttpResourceValidationSteps.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/HttpResourceValidationSteps.java similarity index 90% rename from vividus-plugin-rest-api/src/main/java/org/vividus/steps/http/HttpResourceValidationSteps.java rename to vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/HttpResourceValidationSteps.java index ebdce9c1ef..1607f3d4a7 100644 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/http/HttpResourceValidationSteps.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/HttpResourceValidationSteps.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,15 +14,15 @@ * limitations under the License. */ -package org.vividus.steps.http; +package org.vividus.http.steps; import java.util.List; import java.util.Map; import org.jbehave.core.annotations.Then; import org.jbehave.core.model.ExamplesTable; +import org.vividus.http.validation.ResourceValidation; import org.vividus.http.validation.ResourceValidator; -import org.vividus.http.validation.model.ResourceValidation; import org.vividus.reporter.event.AttachmentPublisher; import org.vividus.softassert.ISoftAssert; import org.vividus.util.UriUtils; @@ -63,7 +63,8 @@ public void verifyHttpResources(ExamplesTable resources) .sorted() .toList(); - attachmentPublisher.publishAttachment("http-resources-validation-results.ftl", + attachmentPublisher.publishAttachment( + "/org/vividus/http/steps/attachment/http-resources-validation-results.ftl", Map.of("results", validations), "HTTP resources validation results"); }); } diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/HttpResponseValidationSteps.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/HttpResponseValidationSteps.java similarity index 99% rename from vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/HttpResponseValidationSteps.java rename to vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/HttpResponseValidationSteps.java index 66d994dcf1..4ed20a75bb 100644 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/HttpResponseValidationSteps.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/HttpResponseValidationSteps.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.api; +package org.vividus.http.steps; import static org.hamcrest.Matchers.contains; @@ -39,7 +39,6 @@ import org.vividus.http.HttpTestContext; import org.vividus.http.client.HttpResponse; import org.vividus.softassert.ISoftAssert; -import org.vividus.steps.ByteArrayValidationRule; import org.vividus.steps.ComparisonRule; import org.vividus.steps.StringComparisonRule; import org.vividus.steps.SubSteps; diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/JsonResponseValidationSteps.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/JsonResponseValidationSteps.java similarity index 98% rename from vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/JsonResponseValidationSteps.java rename to vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/JsonResponseValidationSteps.java index 514ad0e324..191cdbf946 100644 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/JsonResponseValidationSteps.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/JsonResponseValidationSteps.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.api; +package org.vividus.http.steps; import java.time.Duration; import java.util.Optional; diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/JwtSteps.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/JwtSteps.java similarity index 97% rename from vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/JwtSteps.java rename to vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/JwtSteps.java index aef0b5f2e1..7ec1129299 100644 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/api/JwtSteps.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/JwtSteps.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.api; +package org.vividus.http.steps; import static java.lang.String.format; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/steps/integration/RedirectValidationSteps.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/RedirectValidationSteps.java similarity index 71% rename from vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/steps/integration/RedirectValidationSteps.java rename to vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/RedirectValidationSteps.java index 895ac2e04f..ed98921f8c 100644 --- a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/steps/integration/RedirectValidationSteps.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/http/steps/RedirectValidationSteps.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.integration; +package org.vividus.http.steps; import java.io.IOException; import java.net.URI; @@ -22,10 +22,9 @@ import java.util.List; import java.util.Map; +import org.jbehave.core.annotations.AsParameters; import org.jbehave.core.annotations.Then; -import org.vividus.http.ExpectedRedirect; import org.vividus.http.HttpRedirectsProvider; -import org.vividus.http.RedirectValidationState; import org.vividus.reporter.event.IAttachmentPublisher; import org.vividus.softassert.ISoftAssert; import org.vividus.util.UriUtils; @@ -74,7 +73,7 @@ public RedirectValidationSteps(HttpRedirectsProvider redirectsProvider, ISoftAss *
  • redirectsNumber - The expected number of redirects between startUrl and endUrl (optional)
  • * */ - @Then("I validate HTTP redirects: $expectedRedirects") + @Then("I validate HTTP redirects:$expectedRedirects") public void validateRedirects(List expectedRedirects) { softAssert.runIgnoringTestFailFast(() -> @@ -92,7 +91,7 @@ public void validateRedirects(List expectedRedirects) private void performPostCheckActions(List states) { - attachmentPublisher.publishAttachment("/org/vividus/steps/integration/redirect-validation-test-report.ftl", + attachmentPublisher.publishAttachment("/org/vividus/http/steps/attachment/redirect-validation-test-report.ftl", Map.of("results", states), "Redirects validation test report"); } @@ -176,4 +175,115 @@ private static void initTestResult(RedirectValidationState validationState, List validationState.setActualRedirectsNumber(0); } } + + @AsParameters + public static class ExpectedRedirect + { + private URI startUrl; + private URI endUrl; + private Integer redirectsNumber; + + public URI getStartUrl() + { + return startUrl; + } + + public void setStartUrl(URI startUrl) + { + this.startUrl = startUrl; + } + + public URI getEndUrl() + { + return endUrl; + } + + public void setEndUrl(URI endUrl) + { + this.endUrl = endUrl; + } + + public Integer getRedirectsNumber() + { + return redirectsNumber; + } + + public void setRedirectsNumber(Integer redirectsNumber) + { + this.redirectsNumber = redirectsNumber; + } + } + + public static class RedirectValidationState + { + private final ExpectedRedirect expectedRedirect; + + private URI actualEndUrl; + private int actualRedirectsNumber = -1; + private List redirects; + + private String resultMessage = "Passed"; + private boolean passed = true; + + public RedirectValidationState(ExpectedRedirect expectedRedirect) + { + this.expectedRedirect = expectedRedirect; + } + + public void fail(String resultMessage) + { + this.resultMessage = "Fail: " + resultMessage; + passed = false; + } + + public void pass(String resultMessage) + { + this.resultMessage = "Passed: " + resultMessage; + } + + public ExpectedRedirect getExpectedRedirect() + { + return expectedRedirect; + } + + public URI getActualEndUrl() + { + return actualEndUrl; + } + + public void setActualEndUrl(URI actualEndUrl) + { + this.actualEndUrl = actualEndUrl; + } + + public boolean isPassed() + { + return passed; + } + + public String getResultMessage() + { + return resultMessage; + } + + public int getActualRedirectsNumber() + { + return actualRedirectsNumber; + } + + public void setActualRedirectsNumber(int actualRedirectsNumber) + { + this.actualRedirectsNumber = actualRedirectsNumber; + } + + public List getRedirects() + { + return redirects; + } + + public void setRedirects(List redirects) + { + this.redirects = redirects; + } + } } diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/model/AbstractResourceValidation.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/AbstractResourceValidation.java similarity index 98% rename from vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/model/AbstractResourceValidation.java rename to vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/AbstractResourceValidation.java index fb9ff56aac..2c461f3307 100644 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/model/AbstractResourceValidation.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/AbstractResourceValidation.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.http.validation.model; +package org.vividus.http.validation; import java.net.URI; import java.util.Objects; diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/model/CheckStatus.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/CheckStatus.java similarity index 89% rename from vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/model/CheckStatus.java rename to vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/CheckStatus.java index 52305e536f..7b21225e30 100644 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/model/CheckStatus.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/CheckStatus.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.http.validation.model; +package org.vividus.http.validation; public enum CheckStatus { diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/model/ResourceValidation.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/ResourceValidation.java similarity index 92% rename from vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/model/ResourceValidation.java rename to vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/ResourceValidation.java index dea0481333..1bcd5d3fcb 100644 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/model/ResourceValidation.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/ResourceValidation.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.http.validation.model; +package org.vividus.http.validation; import java.net.URI; diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/ResourceValidator.java b/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/ResourceValidator.java index 59c98e4325..f9923d1991 100644 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/ResourceValidator.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/http/validation/ResourceValidator.java @@ -30,8 +30,6 @@ import org.apache.hc.core5.http.HttpStatus; import org.vividus.http.client.HttpResponse; import org.vividus.http.client.IHttpClient; -import org.vividus.http.validation.model.AbstractResourceValidation; -import org.vividus.http.validation.model.CheckStatus; import org.vividus.softassert.ISoftAssert; public class ResourceValidator> diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/model/RequestPartType.java b/vividus-plugin-rest-api/src/main/java/org/vividus/model/RequestPartType.java deleted file mode 100644 index c013e9d7f0..0000000000 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/model/RequestPartType.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2019-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.vividus.model; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; - -import org.apache.commons.io.FilenameUtils; -import org.apache.hc.client5.http.entity.mime.ByteArrayBody; -import org.apache.hc.client5.http.entity.mime.ContentBody; -import org.apache.hc.client5.http.entity.mime.StringBody; -import org.apache.hc.core5.http.ContentType; -import org.vividus.util.ResourceUtils; - -public enum RequestPartType -{ - STRING - { - @Override - public ContentType getDefaultContentType() - { - return ContentType.DEFAULT_TEXT; - } - - @Override - public ContentBody createPart(String value, ContentType contentType) - { - return new StringBody(value, contentType); - } - - @Override - public ContentBody createPart(String value, ContentType contentType, String fileName) - { - throw new IllegalArgumentException( - String.format("'fileName' parameter is not allowed for %s request part type", name())); - } - }, - FILE - { - @Override - public ContentType getDefaultContentType() - { - return ContentType.DEFAULT_BINARY; - } - - @Override - public ContentBody createPart(String value, ContentType contentType) throws IOException - { - String fileName = FilenameUtils.getName(value); - return createPart(value, contentType, fileName); - } - - @Override - public ContentBody createPart(String value, ContentType contentType, String fileName) throws IOException - { - byte[] byteArray = ResourceUtils.loadResourceOrFileAsByteArray(value); - return new ByteArrayBody(byteArray, contentType, fileName); - } - }, - BINARY - { - @Override - public ContentType getDefaultContentType() - { - return ContentType.DEFAULT_BINARY; - } - - @Override - public ContentBody createPart(String value, ContentType contentType) - { - throw new IllegalArgumentException( - String.format("'fileName' parameter is required for %s request part type", name())); - } - - @Override - public ContentBody createPart(String value, ContentType contentType, String fileName) - { - byte[] byteArray = value.getBytes(StandardCharsets.UTF_8); - return new ByteArrayBody(byteArray, contentType, fileName); - } - }; - - public abstract ContentType getDefaultContentType(); - - public abstract ContentBody createPart(String value, ContentType contentType) throws IOException; - - public abstract ContentBody createPart(String value, ContentType contentType, String fileName) throws IOException; -} diff --git a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/ssl/SslSteps.java b/vividus-plugin-rest-api/src/main/java/org/vividus/ssl/steps/SslSteps.java similarity index 96% rename from vividus-plugin-rest-api/src/main/java/org/vividus/steps/ssl/SslSteps.java rename to vividus-plugin-rest-api/src/main/java/org/vividus/ssl/steps/SslSteps.java index d057d2a4cb..c558884150 100644 --- a/vividus-plugin-rest-api/src/main/java/org/vividus/steps/ssl/SslSteps.java +++ b/vividus-plugin-rest-api/src/main/java/org/vividus/ssl/steps/SslSteps.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2021 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.ssl; +package org.vividus.ssl.steps; import java.io.IOException; import java.security.GeneralSecurityException; diff --git a/vividus-plugin-rest-api/src/main/resources/org/vividus/http/attachment/api-message.ftl b/vividus-plugin-rest-api/src/main/resources/org/vividus/http/steps/attachment/api-message.ftl similarity index 100% rename from vividus-plugin-rest-api/src/main/resources/org/vividus/http/attachment/api-message.ftl rename to vividus-plugin-rest-api/src/main/resources/org/vividus/http/steps/attachment/api-message.ftl diff --git a/vividus-plugin-rest-api/src/main/resources/http-resources-validation-results.ftl b/vividus-plugin-rest-api/src/main/resources/org/vividus/http/steps/attachment/http-resources-validation-results.ftl similarity index 100% rename from vividus-plugin-rest-api/src/main/resources/http-resources-validation-results.ftl rename to vividus-plugin-rest-api/src/main/resources/org/vividus/http/steps/attachment/http-resources-validation-results.ftl diff --git a/vividus-plugin-web-app-to-rest-api/src/main/resources/org/vividus/steps/integration/redirect-validation-test-report.ftl b/vividus-plugin-rest-api/src/main/resources/org/vividus/http/steps/attachment/redirect-validation-test-report.ftl similarity index 100% rename from vividus-plugin-web-app-to-rest-api/src/main/resources/org/vividus/steps/integration/redirect-validation-test-report.ftl rename to vividus-plugin-rest-api/src/main/resources/org/vividus/http/steps/attachment/redirect-validation-test-report.ftl diff --git a/vividus-plugin-rest-api/src/main/resources/resources-response-body-fragment.ftl b/vividus-plugin-rest-api/src/main/resources/org/vividus/http/steps/attachment/resources-response-body-fragment.ftl similarity index 100% rename from vividus-plugin-rest-api/src/main/resources/resources-response-body-fragment.ftl rename to vividus-plugin-rest-api/src/main/resources/org/vividus/http/steps/attachment/resources-response-body-fragment.ftl diff --git a/vividus-plugin-rest-api/src/main/resources/properties/defaults/default.properties b/vividus-plugin-rest-api/src/main/resources/properties/defaults/default.properties index 4c17929e0d..c6de873955 100644 --- a/vividus-plugin-rest-api/src/main/resources/properties/defaults/default.properties +++ b/vividus-plugin-rest-api/src/main/resources/properties/defaults/default.properties @@ -4,3 +4,5 @@ rest-api.http.cookie-store-level=global rest-api.http.extended-logging=false resource-checker.publish-response-body=false + +http.redirects-provider.circular-redirects-allowed=false diff --git a/vividus-plugin-rest-api/src/main/resources/vividus-plugin/spring.xml b/vividus-plugin-rest-api/src/main/resources/vividus-plugin/spring.xml index dc34731a50..627a32c7f5 100644 --- a/vividus-plugin-rest-api/src/main/resources/vividus-plugin/spring.xml +++ b/vividus-plugin-rest-api/src/main/resources/vividus-plugin/spring.xml @@ -7,51 +7,17 @@ http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd" default-lazy-init="true"> - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - + + - - - + @@ -77,30 +43,76 @@ + + + + + + + + + + + - + + + + + + + - - + + + + + + + + + + - + + + - + + + + + + + + - + + + + + + - - - + + + + @@ -116,7 +128,7 @@ - - + + diff --git a/vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/http/HttpRedirectsProviderTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/http/HttpRedirectsProviderTests.java similarity index 100% rename from vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/http/HttpRedirectsProviderTests.java rename to vividus-plugin-rest-api/src/test/java/org/vividus/http/HttpRedirectsProviderTests.java diff --git a/vividus-plugin-rest-api/src/test/java/org/vividus/http/PublishingAttachmentInterceptorTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/http/PublishingAttachmentInterceptorTests.java index 570b2f9cf1..291d5f595a 100644 --- a/vividus-plugin-rest-api/src/test/java/org/vividus/http/PublishingAttachmentInterceptorTests.java +++ b/vividus-plugin-rest-api/src/test/java/org/vividus/http/PublishingAttachmentInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ class PublishingAttachmentInterceptorTests { private static final String ENDPOINT = "https://uri.com/"; private static final String METHOD = "method"; - private static final String API_MESSAGE_FTL = "/org/vividus/http/attachment/api-message.ftl"; + private static final String API_MESSAGE_FTL = "/org/vividus/http/steps/attachment/api-message.ftl"; private static final String RESPONSE = "Response: method " + ENDPOINT; private static final String REQUEST = "Request: method " + ENDPOINT; private static final String CONTENT_TYPE = "Content-Type"; @@ -162,7 +162,7 @@ void testHttpResponseIsAttachedSuccessfully() throws IOException when(httpResponse.getResponseHeaders()).thenReturn(new Header[] { mock(Header.class) }); interceptor.handle(httpResponse); var argumentCaptor = verifyPublishAttachment(RESPONSE); - assertEquals(HttpStatus.SC_OK, argumentCaptor.getValue().get("statusCode").intValue()); + assertEquals(HttpStatus.SC_OK, argumentCaptor.getValue().get("statusCode")); } @Test diff --git a/vividus-plugin-rest-api/src/test/java/org/vividus/http/expression/PkceExpressionProcessorTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/http/expression/PkceExpressionProcessorTests.java index 2ff28cd18c..4d67015684 100644 --- a/vividus-plugin-rest-api/src/test/java/org/vividus/http/expression/PkceExpressionProcessorTests.java +++ b/vividus-plugin-rest-api/src/test/java/org/vividus/http/expression/PkceExpressionProcessorTests.java @@ -19,7 +19,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mockStatic; -import static org.mockito.Mockito.when; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; @@ -55,13 +54,13 @@ void testExecute() throws NoSuchAlgorithmException processor.execute(String.format(GENERATE_CODE_CHALLENGE, CODE_VERIFIER_VALUE))); } - @SuppressWarnings("unchecked") @Test - void testExecuteWithException() throws NoSuchAlgorithmException + void testExecuteWithException() { - try (MockedStatic md = mockStatic(MessageDigest.class)) + try (MockedStatic messageDigestStaticMock = mockStatic(MessageDigest.class)) { - when(MessageDigest.getInstance(ALGORITHM)).thenThrow(new NoSuchAlgorithmException()); + messageDigestStaticMock.when(() -> MessageDigest.getInstance(ALGORITHM)).thenThrow( + new NoSuchAlgorithmException()); assertThrows(IllegalArgumentException.class, () -> expressionProcessor.execute(String.format(GENERATE_CODE_CHALLENGE, CODE_VERIFIER_VALUE))); } diff --git a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/ByteArrayValidationRuleTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/ByteArrayValidationRuleTests.java similarity index 97% rename from vividus-plugin-rest-api/src/test/java/org/vividus/steps/ByteArrayValidationRuleTests.java rename to vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/ByteArrayValidationRuleTests.java index 0d5fdd3f83..a1e73b02af 100644 --- a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/ByteArrayValidationRuleTests.java +++ b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/ByteArrayValidationRuleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2021 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps; +package org.vividus.http.steps; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.never; diff --git a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/HttpCookieStepsTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/HttpCookieStepsTests.java similarity index 98% rename from vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/HttpCookieStepsTests.java rename to vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/HttpCookieStepsTests.java index 61adfb62ba..00b2391954 100644 --- a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/HttpCookieStepsTests.java +++ b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/HttpCookieStepsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.api; +package org.vividus.http.steps; import static com.github.valfirst.slf4jtest.LoggingEvent.info; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/HttpRequestStepsTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/HttpRequestStepsTests.java similarity index 99% rename from vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/HttpRequestStepsTests.java rename to vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/HttpRequestStepsTests.java index c6e2864907..e73ad690e2 100644 --- a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/HttpRequestStepsTests.java +++ b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/HttpRequestStepsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.api; +package org.vividus.http.steps; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; diff --git a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/http/HttpResourceValidationStepsTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/HttpResourceValidationStepsTests.java similarity index 86% rename from vividus-plugin-rest-api/src/test/java/org/vividus/steps/http/HttpResourceValidationStepsTests.java rename to vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/HttpResourceValidationStepsTests.java index 586632c4f6..4182f03779 100644 --- a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/http/HttpResourceValidationStepsTests.java +++ b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/HttpResourceValidationStepsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.http; +package org.vividus.http.steps; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; @@ -31,9 +31,9 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import org.vividus.http.validation.CheckStatus; +import org.vividus.http.validation.ResourceValidation; import org.vividus.http.validation.ResourceValidator; -import org.vividus.http.validation.model.CheckStatus; -import org.vividus.http.validation.model.ResourceValidation; import org.vividus.reporter.event.AttachmentPublisher; import org.vividus.softassert.FailableRunnable; import org.vividus.softassert.ISoftAssert; @@ -61,15 +61,16 @@ void shouldVerifyHttpResources() when(resourceValidator.perform(failed2)).thenReturn(failed2); doAnswer(a -> { - FailableRunnable runnable = a.getArgument(0); + FailableRunnable runnable = a.getArgument(0); runnable.run(); return null; - }).when(softAssert).runIgnoringTestFailFast(any(FailableRunnable.class)); + }).when(softAssert).runIgnoringTestFailFast(any()); steps.verifyHttpResources( new ExamplesTable(String.format("|url|%n|%s|%n|%s|%n|%s|%n", passedUrl, failedUrl1, failedUrl2))); - verify(attachmentPublisher).publishAttachment("http-resources-validation-results.ftl", + verify(attachmentPublisher).publishAttachment( + "/org/vividus/http/steps/attachment/http-resources-validation-results.ftl", Map.of("results", List.of(failed1, failed2, passed)), "HTTP resources validation results"); } diff --git a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/HttpResponseValidationStepsTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/HttpResponseValidationStepsTests.java similarity index 99% rename from vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/HttpResponseValidationStepsTests.java rename to vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/HttpResponseValidationStepsTests.java index 939493f444..dec69961ea 100644 --- a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/HttpResponseValidationStepsTests.java +++ b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/HttpResponseValidationStepsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.api; +package org.vividus.http.steps; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.lessThan; @@ -52,7 +52,6 @@ import org.vividus.http.HttpTestContext; import org.vividus.http.client.HttpResponse; import org.vividus.softassert.ISoftAssert; -import org.vividus.steps.ByteArrayValidationRule; import org.vividus.steps.ComparisonRule; import org.vividus.steps.SubSteps; import org.vividus.util.ResourceUtils; diff --git a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/JsonResponseValidationStepsTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/JsonResponseValidationStepsTests.java similarity index 98% rename from vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/JsonResponseValidationStepsTests.java rename to vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/JsonResponseValidationStepsTests.java index 2fb63fc0ac..8a25f1c621 100644 --- a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/JsonResponseValidationStepsTests.java +++ b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/JsonResponseValidationStepsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.api; +package org.vividus.http.steps; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; diff --git a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/JwtStepsTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/JwtStepsTests.java similarity index 95% rename from vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/JwtStepsTests.java rename to vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/JwtStepsTests.java index 979776fadf..1f6cc57190 100644 --- a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/api/JwtStepsTests.java +++ b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/JwtStepsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.api; +package org.vividus.http.steps; import static org.mockito.Mockito.verify; diff --git a/vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/steps/integration/RedirectValidationStepsTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/RedirectValidationStepsTests.java similarity index 93% rename from vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/steps/integration/RedirectValidationStepsTests.java rename to vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/RedirectValidationStepsTests.java index e339b7fa6d..99bf083c1b 100644 --- a/vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/steps/integration/RedirectValidationStepsTests.java +++ b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/RedirectValidationStepsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.integration; +package org.vividus.http.steps; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -43,9 +43,9 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.vividus.http.ExpectedRedirect; import org.vividus.http.HttpRedirectsProvider; -import org.vividus.http.RedirectValidationState; +import org.vividus.http.steps.RedirectValidationSteps.ExpectedRedirect; +import org.vividus.http.steps.RedirectValidationSteps.RedirectValidationState; import org.vividus.reporter.event.IAttachmentPublisher; import org.vividus.softassert.FailableRunnable; import org.vividus.softassert.ISoftAssert; @@ -82,10 +82,10 @@ void beforeEach() { doAnswer(a -> { - FailableRunnable runnable = a.getArgument(0); + FailableRunnable runnable = a.getArgument(0); runnable.run(); return null; - }).when(softAssert).runIgnoringTestFailFast(any(FailableRunnable.class)); + }).when(softAssert).runIgnoringTestFailFast(any()); } @Test @@ -98,7 +98,7 @@ void shouldSuccessValidateRedirects() throws IOException verify(softAssert, never()).recordFailedAssertion(anyString()); RedirectValidationState result = verifyAttachmentAndCaptureResult().get(0); verifyStartEndActualUrlSet(result, REDIRECT_URL, REDIRECT_URL); - assertEquals(REDIRECTS_NUMBER, result.getExpectedRedirect().getRedirectsNumber().intValue()); + assertEquals(REDIRECTS_NUMBER, result.getExpectedRedirect().getRedirectsNumber()); assertEquals(REDIRECTS_NUMBER, result.getActualRedirectsNumber()); assertTrue(result.isPassed()); assertEquals(PASSED_MESSAGE, result.getResultMessage()); @@ -131,7 +131,7 @@ void shouldValidateRedirectsWithWrongRedirectUrl() throws IOException RedirectValidationState result = verifyAttachmentAndCaptureResult().get(0); verifyStartEndActualUrlSet(result, REDIRECT_URL, URL_WITH_REDIRECT_RESPONSE); verify(attachmentPublisher).publishAttachment(anyString(), any(), anyString()); - assertEquals(REDIRECTS_NUMBER, result.getExpectedRedirect().getRedirectsNumber().intValue()); + assertEquals(REDIRECTS_NUMBER, result.getExpectedRedirect().getRedirectsNumber()); assertFalse(result.isPassed()); assertEquals(FAIL_MESSAGE_FOR_URLS, result.getResultMessage()); } @@ -180,7 +180,7 @@ void shouldValidateRedirectsWithWrongRedirectNumber() throws IOException URL_WITH_REDIRECT_RESPONSE, URL_WITH_REDIRECT_RESPONSE, wrongRedirectsNumber, actualRedirectsNumber)); RedirectValidationState result = verifyAttachmentAndCaptureResult().get(0); verifyStartEndActualUrlSet(result, URL_WITH_REDIRECT_RESPONSE, URL_WITH_REDIRECT_RESPONSE); - assertEquals(wrongRedirectsNumber, result.getExpectedRedirect().getRedirectsNumber().intValue()); + assertEquals(wrongRedirectsNumber, result.getExpectedRedirect().getRedirectsNumber()); assertEquals(REDIRECTS_NUMBER, result.getActualRedirectsNumber()); assertFalse(result.isPassed()); assertEquals(FAIL + "different redirects number", result.getResultMessage()); @@ -198,7 +198,7 @@ void shouldValidateRedirectsWithWrongRedirectUrlAndRedirectsNumber() throws IOEx RedirectValidationState result = verifyAttachmentAndCaptureResult().get(0); verifyStartEndActualUrlSet(result, REDIRECT_URL, URL_WITH_REDIRECT_RESPONSE); - assertEquals(wrongRedirectsNumber, result.getExpectedRedirect().getRedirectsNumber().intValue()); + assertEquals(wrongRedirectsNumber, result.getExpectedRedirect().getRedirectsNumber()); assertFalse(result.isPassed()); assertEquals(FAIL_MESSAGE_FOR_URLS, result.getResultMessage()); } @@ -224,7 +224,7 @@ void shouldValidateRedirectsWithNoRedirect() throws IOException private List verifyAttachmentAndCaptureResult() { verify(attachmentPublisher).publishAttachment( - eq("/org/vividus/steps/integration/redirect-validation-test-report.ftl"), + eq("/org/vividus/http/steps/attachment/redirect-validation-test-report.ftl"), resultCaptor.capture(), eq(REDIRECT_VALIDATION)); return resultCaptor.getValue().get("results"); } @@ -232,7 +232,7 @@ private List verifyAttachmentAndCaptureResult() private static List initParameters(URI endUrl, Integer redirectsNumber) { ExpectedRedirect expectedRedirect = new ExpectedRedirect(); - expectedRedirect.setStartUrl(RedirectValidationStepsTests.URL_WITH_REDIRECT_RESPONSE); + expectedRedirect.setStartUrl(URL_WITH_REDIRECT_RESPONSE); expectedRedirect.setEndUrl(endUrl); expectedRedirect.setRedirectsNumber(redirectsNumber); return Collections.singletonList(expectedRedirect); @@ -240,8 +240,7 @@ private static List initParameters(URI endUrl, Integer redirec private static void verifyStartEndActualUrlSet(RedirectValidationState result, URI end, URI actual) { - assertEquals(RedirectValidationStepsTests.URL_WITH_REDIRECT_RESPONSE, - result.getExpectedRedirect().getStartUrl()); + assertEquals(URL_WITH_REDIRECT_RESPONSE, result.getExpectedRedirect().getStartUrl()); assertEquals(end, result.getExpectedRedirect().getEndUrl()); assertEquals(actual, result.getActualEndUrl()); } diff --git a/vividus-plugin-rest-api/src/test/java/org/vividus/model/RequestPartTypeTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/RequestPartTypeTests.java similarity index 69% rename from vividus-plugin-rest-api/src/test/java/org/vividus/model/RequestPartTypeTests.java rename to vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/RequestPartTypeTests.java index ee736f595f..b2b663daa8 100644 --- a/vividus-plugin-rest-api/src/test/java/org/vividus/model/RequestPartTypeTests.java +++ b/vividus-plugin-rest-api/src/test/java/org/vividus/http/steps/RequestPartTypeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.model; +package org.vividus.http.steps; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -28,6 +28,7 @@ import org.apache.hc.client5.http.entity.mime.StringBody; import org.apache.hc.core5.http.ContentType; import org.junit.jupiter.api.Test; +import org.vividus.http.steps.HttpRequestSteps.RequestPartType; class RequestPartTypeTests { @@ -37,15 +38,15 @@ class RequestPartTypeTests @Test void shouldCreateStringPart() throws IOException { - String value = "stringValue"; - StringBody part = (StringBody) RequestPartType.STRING.createPart(value, CONTENT_TYPE); + var value = "stringValue"; + var part = (StringBody) RequestPartType.STRING.createPart(value, CONTENT_TYPE); assertRequestPart(part, value, null); } @Test void shouldNotCreateStringPartWithFileName() { - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, + var exception = assertThrows(IllegalArgumentException.class, () -> RequestPartType.STRING.createPart(null, CONTENT_TYPE, "string-filename")); assertEquals("'fileName' parameter is not allowed for STRING request part type", exception.getMessage()); } @@ -53,33 +54,32 @@ void shouldNotCreateStringPartWithFileName() @Test void shouldCreateFilePartWithDefaultFileName() throws IOException { - String fileName = "requestBody.txt"; - ByteArrayBody part = (ByteArrayBody) RequestPartType.FILE.createPart("/" + fileName, CONTENT_TYPE); + var fileName = "requestBody.txt"; + var part = (ByteArrayBody) RequestPartType.FILE.createPart("/" + fileName, CONTENT_TYPE); assertRequestPart(part, FILE_CONTENT, fileName); } @Test void shouldCreateFilePartWithCustomFileName() throws IOException { - String fileName = "file.txt"; - ByteArrayBody part = (ByteArrayBody) RequestPartType.FILE.createPart("/requestBody.txt", CONTENT_TYPE, - fileName); + var fileName = "file.txt"; + var part = (ByteArrayBody) RequestPartType.FILE.createPart("/requestBody.txt", CONTENT_TYPE, fileName); assertRequestPart(part, FILE_CONTENT, fileName); } @Test void shouldCreateBinaryPart() throws IOException { - String data = "data"; - String fileName = "binary.txt"; - ByteArrayBody part = (ByteArrayBody) RequestPartType.BINARY.createPart(data, CONTENT_TYPE, fileName); + var data = "data"; + var fileName = "binary.txt"; + var part = (ByteArrayBody) RequestPartType.BINARY.createPart(data, CONTENT_TYPE, fileName); assertRequestPart(part, data, fileName); } @Test void shouldNotCreateBinaryPartWithoutFileName() { - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, + var exception = assertThrows(IllegalArgumentException.class, () -> RequestPartType.BINARY.createPart(null, CONTENT_TYPE)); assertEquals("'fileName' parameter is required for BINARY request part type", exception.getMessage()); } @@ -87,9 +87,11 @@ void shouldNotCreateBinaryPartWithoutFileName() private void assertRequestPart(AbstractContentBody part, String data, String fileName) throws IOException { assertEquals(CONTENT_TYPE, part.getContentType()); - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - part.writeTo(byteArrayOutputStream); - assertEquals(data, byteArrayOutputStream.toString(StandardCharsets.UTF_8)); + try (var byteArrayOutputStream = new ByteArrayOutputStream()) + { + part.writeTo(byteArrayOutputStream); + assertEquals(data, byteArrayOutputStream.toString(StandardCharsets.UTF_8)); + } assertEquals(fileName, part.getFilename()); } } diff --git a/vividus-plugin-rest-api/src/test/java/org/vividus/http/validation/ResourceValidatorTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/http/validation/ResourceValidatorTests.java index 92c7d1b255..4774219bf6 100644 --- a/vividus-plugin-rest-api/src/test/java/org/vividus/http/validation/ResourceValidatorTests.java +++ b/vividus-plugin-rest-api/src/test/java/org/vividus/http/validation/ResourceValidatorTests.java @@ -39,8 +39,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.vividus.http.client.HttpResponse; import org.vividus.http.client.IHttpClient; -import org.vividus.http.validation.model.CheckStatus; -import org.vividus.http.validation.model.ResourceValidation; import org.vividus.softassert.ISoftAssert; @ExtendWith(MockitoExtension.class) diff --git a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/ssl/SslStepsTests.java b/vividus-plugin-rest-api/src/test/java/org/vividus/ssl/steps/SslStepsTests.java similarity index 96% rename from vividus-plugin-rest-api/src/test/java/org/vividus/steps/ssl/SslStepsTests.java rename to vividus-plugin-rest-api/src/test/java/org/vividus/ssl/steps/SslStepsTests.java index e335b2eeb3..a7975312c1 100644 --- a/vividus-plugin-rest-api/src/test/java/org/vividus/steps/ssl/SslStepsTests.java +++ b/vividus-plugin-rest-api/src/test/java/org/vividus/ssl/steps/SslStepsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2021 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.vividus.steps.ssl; +package org.vividus.ssl.steps; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; diff --git a/vividus-plugin-rest-api/src/test/resources/org/vividus/steps/api/swf.swf b/vividus-plugin-rest-api/src/test/resources/org/vividus/http/steps/swf.swf similarity index 100% rename from vividus-plugin-rest-api/src/test/resources/org/vividus/steps/api/swf.swf rename to vividus-plugin-rest-api/src/test/resources/org/vividus/http/steps/swf.swf diff --git a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/http/ExpectedRedirect.java b/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/http/ExpectedRedirect.java deleted file mode 100644 index 4315a469b4..0000000000 --- a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/http/ExpectedRedirect.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2019-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.vividus.http; - -import java.net.URI; - -import org.jbehave.core.annotations.AsParameters; - -@AsParameters -public class ExpectedRedirect -{ - private URI startUrl; - private URI endUrl; - private Integer redirectsNumber; - - public URI getStartUrl() - { - return startUrl; - } - - public void setStartUrl(URI startUrl) - { - this.startUrl = startUrl; - } - - public URI getEndUrl() - { - return endUrl; - } - - public void setEndUrl(URI endUrl) - { - this.endUrl = endUrl; - } - - public Integer getRedirectsNumber() - { - return redirectsNumber; - } - - public void setRedirectsNumber(Integer redirectsNumber) - { - this.redirectsNumber = redirectsNumber; - } -} diff --git a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/http/RedirectValidationState.java b/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/http/RedirectValidationState.java deleted file mode 100644 index e817d8b179..0000000000 --- a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/http/RedirectValidationState.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2019-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.vividus.http; - -import java.net.URI; -import java.util.List; - -public class RedirectValidationState -{ - private final ExpectedRedirect expectedRedirect; - - private URI actualEndUrl; - private int actualRedirectsNumber = -1; - private List redirects; - - private String resultMessage = "Passed"; - private boolean passed = true; - - public RedirectValidationState(ExpectedRedirect expectedRedirect) - { - this.expectedRedirect = expectedRedirect; - } - - public void fail(String resultMessage) - { - this.resultMessage = "Fail: " + resultMessage; - passed = false; - } - - public void pass(String resultMessage) - { - this.resultMessage = "Passed: " + resultMessage; - } - - public ExpectedRedirect getExpectedRedirect() - { - return expectedRedirect; - } - - public URI getActualEndUrl() - { - return actualEndUrl; - } - - public void setActualEndUrl(URI actualEndUrl) - { - this.actualEndUrl = actualEndUrl; - } - - public boolean isPassed() - { - return passed; - } - - public String getResultMessage() - { - return resultMessage; - } - - public int getActualRedirectsNumber() - { - return actualRedirectsNumber; - } - - public void setActualRedirectsNumber(int actualRedirectsNumber) - { - this.actualRedirectsNumber = actualRedirectsNumber; - } - - public List getRedirects() - { - return redirects; - } - - public void setRedirects(List redirects) - { - this.redirects = redirects; - } -} diff --git a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/steps/integration/ResourceCheckSteps.java b/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/steps/integration/ResourceCheckSteps.java index b903d2bca5..7ffb9ef2c2 100644 --- a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/steps/integration/ResourceCheckSteps.java +++ b/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/steps/integration/ResourceCheckSteps.java @@ -43,8 +43,8 @@ import org.vividus.http.HttpMethod; import org.vividus.http.HttpRequestExecutor; import org.vividus.http.HttpTestContext; +import org.vividus.http.validation.CheckStatus; import org.vividus.http.validation.ResourceValidator; -import org.vividus.http.validation.model.CheckStatus; import org.vividus.reporter.event.AttachmentPublisher; import org.vividus.softassert.ISoftAssert; import org.vividus.testcontext.ContextCopyingExecutor; diff --git a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/validator/model/ResourceValidationError.java b/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/validator/model/ResourceValidationError.java index 557eba2873..06cba5ace6 100644 --- a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/validator/model/ResourceValidationError.java +++ b/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/validator/model/ResourceValidationError.java @@ -18,7 +18,7 @@ import java.util.function.Consumer; -import org.vividus.http.validation.model.CheckStatus; +import org.vividus.http.validation.CheckStatus; public enum ResourceValidationError { diff --git a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/validator/model/WebPageResourceValidation.java b/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/validator/model/WebPageResourceValidation.java index da1827bc5a..dbe6e59a07 100644 --- a/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/validator/model/WebPageResourceValidation.java +++ b/vividus-plugin-web-app-to-rest-api/src/main/java/org/vividus/validator/model/WebPageResourceValidation.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2023 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import java.util.Comparator; import org.apache.commons.lang3.tuple.Pair; -import org.vividus.http.validation.model.AbstractResourceValidation; +import org.vividus.http.validation.AbstractResourceValidation; public class WebPageResourceValidation extends AbstractResourceValidation { diff --git a/vividus-plugin-web-app-to-rest-api/src/main/resources/properties/defaults/default.properties b/vividus-plugin-web-app-to-rest-api/src/main/resources/properties/defaults/default.properties index 6d85801ea2..e81da17ceb 100644 --- a/vividus-plugin-web-app-to-rest-api/src/main/resources/properties/defaults/default.properties +++ b/vividus-plugin-web-app-to-rest-api/src/main/resources/properties/defaults/default.properties @@ -1,5 +1,3 @@ -http.redirects-provider.circular-redirects-allowed=false - sitemap.parser.site-url= sitemap.parser.base-url= sitemap.parser.follow-redirects=true diff --git a/vividus-plugin-web-app-to-rest-api/src/main/resources/resources-validation-result.ftl b/vividus-plugin-web-app-to-rest-api/src/main/resources/resources-validation-result.ftl index 0f07bbdce7..4afa3ec4c8 100644 --- a/vividus-plugin-web-app-to-rest-api/src/main/resources/resources-validation-result.ftl +++ b/vividus-plugin-web-app-to-rest-api/src/main/resources/resources-validation-result.ftl @@ -79,7 +79,7 @@ Status code: ${(result.statusCode.isPresent())?then(result.statusCode.getAsInt(),'N/A')} - <#include "resources-response-body-fragment.ftl"> + <#include "org/vividus/http/steps/attachment/resources-response-body-fragment.ftl"> <#assign pageURL = result.pageURL> diff --git a/vividus-plugin-web-app-to-rest-api/src/main/resources/vividus-plugin/spring.xml b/vividus-plugin-web-app-to-rest-api/src/main/resources/vividus-plugin/spring.xml index f676e61d4b..b6261ba701 100644 --- a/vividus-plugin-web-app-to-rest-api/src/main/resources/vividus-plugin/spring.xml +++ b/vividus-plugin-web-app-to-rest-api/src/main/resources/vividus-plugin/spring.xml @@ -19,28 +19,12 @@ - - - - - - - - - - - - - - @@ -112,7 +96,6 @@ - diff --git a/vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/steps/integration/ResourceCheckStepsTests.java b/vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/steps/integration/ResourceCheckStepsTests.java index 4bd9bca1cd..201fd66854 100644 --- a/vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/steps/integration/ResourceCheckStepsTests.java +++ b/vividus-plugin-web-app-to-rest-api/src/test/java/org/vividus/steps/integration/ResourceCheckStepsTests.java @@ -63,8 +63,8 @@ import org.vividus.http.HttpRequestExecutor; import org.vividus.http.HttpTestContext; import org.vividus.http.client.HttpResponse; +import org.vividus.http.validation.CheckStatus; import org.vividus.http.validation.ResourceValidator; -import org.vividus.http.validation.model.CheckStatus; import org.vividus.reporter.event.AttachmentPublisher; import org.vividus.softassert.FailableRunnable; import org.vividus.softassert.ISoftAssert; diff --git a/vividus-tests/src/main/resources/story/integration/RedirectValidationSteps.story b/vividus-tests/src/main/resources/story/integration/HTTP Redirects.story similarity index 94% rename from vividus-tests/src/main/resources/story/integration/RedirectValidationSteps.story rename to vividus-tests/src/main/resources/story/integration/HTTP Redirects.story index 7aabca6137..59d9d91ae5 100644 --- a/vividus-tests/src/main/resources/story/integration/RedirectValidationSteps.story +++ b/vividus-tests/src/main/resources/story/integration/HTTP Redirects.story @@ -1,7 +1,7 @@ Description: Integration tests for RedirectValidationSteps class Meta: - @epic vividus-plugin-rest-to-web-api + @epic vividus-plugin-rest-api Scenario: Step verification "Then I validate HTTP redirects: $expectedRedirects" with redirects number Then I validate HTTP redirects: