From 8063c88527e7ebaf8ab0c99868e0a31746ee0fda Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 11 Jan 2024 21:14:30 +0300 Subject: [PATCH] Client version update --- CHANGELOG.md | 2 +- build.gradle | 2 +- .../formatting/AbstractHttpFormatter.java | 4 +- .../formatting/http/Constants.java | 31 ++++---- .../formatting/http/ContentType.java | 78 ------------------- .../formatting/http/HttpFormatUtils.java | 17 ++-- .../formatting/http/HttpRequestFormatter.java | 3 +- .../http/HttpResponseFormatter.java | 2 +- .../SanitizingHttpHeaderConverter.java | 3 +- .../converters/SanitizingUriConverter.java | 2 +- 10 files changed, 34 insertions(+), 110 deletions(-) delete mode 100644 src/main/java/com/epam/reportportal/formatting/http/ContentType.java diff --git a/CHANGELOG.md b/CHANGELOG.md index ba67a3c..43f9256 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## [Unreleased] ### Changed -- Client version updated on [5.1.25](https://github.com/reportportal/client-java/releases/tag/5.1.25), by @HardNorth +- Client version updated on [5.2.0](https://github.com/reportportal/client-java/releases/tag/5.2.0), by @HardNorth ### Removed - HttpCore dependency was removed to avoid conflicts, by @HardNorth diff --git a/build.gradle b/build.gradle index 2a243e5..d917fe3 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ repositories { } dependencies { - api 'com.epam.reportportal:client-java:5.1.27' + api 'com.epam.reportportal:client-java:5.2.0' api 'com.google.code.findbugs:jsr305:3.0.2' api 'com.epam.reportportal:commons-model:5.0.0' diff --git a/src/main/java/com/epam/reportportal/formatting/AbstractHttpFormatter.java b/src/main/java/com/epam/reportportal/formatting/AbstractHttpFormatter.java index 2dad7c7..b5ad331 100644 --- a/src/main/java/com/epam/reportportal/formatting/AbstractHttpFormatter.java +++ b/src/main/java/com/epam/reportportal/formatting/AbstractHttpFormatter.java @@ -16,7 +16,6 @@ package com.epam.reportportal.formatting; -import com.epam.reportportal.formatting.http.ContentType; import com.epam.reportportal.formatting.http.HttpFormatter; import com.epam.reportportal.formatting.http.HttpPartFormatter; import com.epam.reportportal.formatting.http.HttpRequestFormatter; @@ -29,7 +28,8 @@ import com.epam.reportportal.service.Launch; import com.epam.reportportal.service.ReportPortal; import com.epam.reportportal.service.step.StepReporter; -import com.google.common.io.ByteSource; +import com.epam.reportportal.utils.files.ByteSource; +import com.epam.reportportal.utils.http.ContentType; import javax.annotation.Nonnull; import javax.annotation.Nullable; diff --git a/src/main/java/com/epam/reportportal/formatting/http/Constants.java b/src/main/java/com/epam/reportportal/formatting/http/Constants.java index f53be1c..807847b 100644 --- a/src/main/java/com/epam/reportportal/formatting/http/Constants.java +++ b/src/main/java/com/epam/reportportal/formatting/http/Constants.java @@ -20,6 +20,7 @@ import com.epam.reportportal.formatting.http.prettiers.HtmlPrettier; import com.epam.reportportal.formatting.http.prettiers.JsonPrettier; import com.epam.reportportal.formatting.http.prettiers.XmlPrettier; +import com.epam.reportportal.utils.http.ContentType; import java.util.*; import java.util.function.Function; @@ -48,11 +49,11 @@ public class Constants { public static final Set TEXT_TYPES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(ContentType.APPLICATION_JSON, - ContentType.TEXT_PLAIN, - ContentType.TEXT_HTML, - ContentType.TEXT_XML, - ContentType.APPLICATION_XML - ))); + ContentType.TEXT_PLAIN, + ContentType.TEXT_HTML, + ContentType.TEXT_XML, + ContentType.APPLICATION_XML + ))); public static final Set FORM_TYPES = Collections.singleton(ContentType.APPLICATION_FORM_URLENCODED); @@ -64,16 +65,16 @@ public class Constants { public static final Map> DEFAULT_PRETTIERS = Collections.unmodifiableMap(new HashMap>() {{ - put(ContentType.APPLICATION_XML, XmlPrettier.INSTANCE); - put(ContentType.APPLICATION_SOAP_XML, XmlPrettier.INSTANCE); - put(ContentType.APPLICATION_ATOM_XML, XmlPrettier.INSTANCE); - put(ContentType.APPLICATION_SVG_XML, XmlPrettier.INSTANCE); - put(ContentType.APPLICATION_XHTML_XML, XmlPrettier.INSTANCE); - put(ContentType.TEXT_XML, XmlPrettier.INSTANCE); - put(ContentType.APPLICATION_JSON, JsonPrettier.INSTANCE); - put("text/json", JsonPrettier.INSTANCE); - put(ContentType.TEXT_HTML, HtmlPrettier.INSTANCE); - }}); + put(ContentType.APPLICATION_XML, XmlPrettier.INSTANCE); + put(ContentType.APPLICATION_SOAP_XML, XmlPrettier.INSTANCE); + put(ContentType.APPLICATION_ATOM_XML, XmlPrettier.INSTANCE); + put(ContentType.APPLICATION_SVG_XML, XmlPrettier.INSTANCE); + put(ContentType.APPLICATION_XHTML_XML, XmlPrettier.INSTANCE); + put(ContentType.TEXT_XML, XmlPrettier.INSTANCE); + put(ContentType.APPLICATION_JSON, JsonPrettier.INSTANCE); + put("text/json", JsonPrettier.INSTANCE); + put(ContentType.TEXT_HTML, HtmlPrettier.INSTANCE); + }}); private Constants() { throw new RuntimeException("No instances should exist for the class!"); diff --git a/src/main/java/com/epam/reportportal/formatting/http/ContentType.java b/src/main/java/com/epam/reportportal/formatting/http/ContentType.java deleted file mode 100644 index 62c2879..0000000 --- a/src/main/java/com/epam/reportportal/formatting/http/ContentType.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2023 EPAM Systems - * - * 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 - * - * http://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 com.epam.reportportal.formatting.http; - -import javax.annotation.Nullable; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -@SuppressWarnings("unused") -public class ContentType { - private static final Pattern HTTP_HEADER_DELIMITER_PATTERN = Pattern.compile("[=;,]"); - - // Binary types - public static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; - public static final String IMAGE_BMP = "image/bmp"; - public static final String IMAGE_GIF = "image/gif"; - public static final String IMAGE_JPEG = "image/jpeg"; - public static final String IMAGE_PNG = "image/png"; - public static final String IMAGE_TIFF = "image/tiff"; - public static final String IMAGE_WEBP = "image/webp"; - - - // Text types - public static final String APPLICATION_ATOM_XML = "application/atom+xml"; - public static final String APPLICATION_JSON = "application/json"; - public static final String APPLICATION_SOAP_XML = "application/soap+xml"; - public static final String APPLICATION_SVG_XML = "application/svg+xml"; - public static final String APPLICATION_XHTML_XML = "application/xhtml+xml"; - public static final String APPLICATION_XML = "application/xml"; - public static final String IMAGE_SVG = "image/svg+xml"; - public static final String TEXT_PLAIN = "text/plain"; - public static final String TEXT_HTML = "text/html"; - public static final String TEXT_XML = "text/xml"; - - // Form types - public static final String APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded"; - - // Multipart types - public static final String MULTIPART_FORM_DATA = "multipart/form-data"; - public static final String MULTIPART_MIXED = "multipart/mixed"; - public static final String MULTIPART_ALTERNATIVE = "multipart/alternative"; - public static final String MULTIPART_DIGEST = "multipart/digest"; - public static final String MULTIPART_PARALLEL = "multipart/parallel"; - - private ContentType() { - throw new RuntimeException("No instances should exist for the class!"); - } - - @Nullable - public static String parse(@Nullable String contentType) { - if (contentType == null || contentType.trim().isEmpty()) { - return null; - } - String trimmed = contentType.trim(); - Matcher m = HTTP_HEADER_DELIMITER_PATTERN.matcher(trimmed); - String mimeType; - if (m.find()) { - mimeType = trimmed.substring(0, m.start()); - } else { - mimeType = trimmed; - } - return mimeType.isEmpty() ? null : mimeType; - } -} diff --git a/src/main/java/com/epam/reportportal/formatting/http/HttpFormatUtils.java b/src/main/java/com/epam/reportportal/formatting/http/HttpFormatUtils.java index 4aa7314..f07b1c5 100644 --- a/src/main/java/com/epam/reportportal/formatting/http/HttpFormatUtils.java +++ b/src/main/java/com/epam/reportportal/formatting/http/HttpFormatUtils.java @@ -23,6 +23,7 @@ import com.epam.reportportal.formatting.http.entities.Cookie; import com.epam.reportportal.formatting.http.entities.Header; import com.epam.reportportal.formatting.http.entities.Param; +import com.epam.reportportal.utils.http.ContentType; import org.apache.commons.lang3.tuple.Pair; import javax.annotation.Nonnull; @@ -67,7 +68,7 @@ public static String joinParts(@Nonnull String delimiter, @Nullable String... pa @Nonnull public static String format(@Nullable List entities, @Nonnull Function converter, - @Nullable String tag) { + @Nullable String tag) { String prefix = tag == null ? "" : tag + LINE_DELIMITER; if (entities == null || entities.isEmpty()) { return ""; @@ -80,7 +81,7 @@ public static String format(@Nullable List entities, @Nonnull Function headers, - @Nullable Function headerConverter) { + @Nullable Function headerConverter) { return format(headers, headerConverter == null ? DefaultHttpHeaderConverter.INSTANCE : headerConverter, HEADERS_TAG @@ -89,7 +90,7 @@ public static String formatHeaders(@Nullable List
headers, @Nonnull public static String formatCookies(@Nullable List cookies, - @Nullable Function cookieConverter) { + @Nullable Function cookieConverter) { return format(cookies, cookieConverter == null ? DefaultCookieConverter.INSTANCE : cookieConverter, COOKIES_TAG @@ -98,7 +99,7 @@ public static String formatCookies(@Nullable List cookies, @Nonnull public static String formatText(@Nullable String header, @Nullable List params, @Nullable String tag, - @Nullable Function paramConverter) { + @Nullable Function paramConverter) { if (params == null || params.isEmpty()) { return header == null ? "" : header; } @@ -114,7 +115,7 @@ public static String formatText(@Nullable String header, @Nullable List p @Nonnull public static String formatText(@Nullable String header, @Nullable String body, @Nullable String tag, - @Nullable Map> contentPrettiers, String contentType) { + @Nullable Map> contentPrettiers, String contentType) { Map> prettiers = contentPrettiers; if (contentPrettiers == null) { prettiers = Collections.emptyMap(); @@ -162,9 +163,9 @@ public static Stream> toKeyValue(@Nonnull String headerValu @Nonnull public static Cookie toCookie(@Nonnull String name, @Nullable String value, @Nullable String comment, - @Nullable String path, @Nullable String domain, @Nullable Long maxAge, @Nullable Boolean secured, - @Nullable Boolean httpOnly, @Nullable Date expiryDate, @Nullable Integer version, - @Nullable String sameSite) { + @Nullable String path, @Nullable String domain, @Nullable Long maxAge, @Nullable Boolean secured, + @Nullable Boolean httpOnly, @Nullable Date expiryDate, @Nullable Integer version, + @Nullable String sameSite) { Cookie cookie = new Cookie(name); cookie.setValue(value); cookie.setComment(comment); diff --git a/src/main/java/com/epam/reportportal/formatting/http/HttpRequestFormatter.java b/src/main/java/com/epam/reportportal/formatting/http/HttpRequestFormatter.java index 45fea31..bfa138f 100644 --- a/src/main/java/com/epam/reportportal/formatting/http/HttpRequestFormatter.java +++ b/src/main/java/com/epam/reportportal/formatting/http/HttpRequestFormatter.java @@ -24,6 +24,7 @@ import com.epam.reportportal.formatting.http.entities.Cookie; import com.epam.reportportal.formatting.http.entities.Header; import com.epam.reportportal.formatting.http.entities.Param; +import com.epam.reportportal.utils.http.ContentType; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -232,7 +233,7 @@ public Builder addCookie(Cookie cookie) { } public Builder addCookie(String name, String value, String comment, String path, String domain, Long maxAge, - Boolean secured, Boolean httpOnly, Date expiryDate, Integer version, String sameSite) { + Boolean secured, Boolean httpOnly, Date expiryDate, Integer version, String sameSite) { return addCookie(HttpFormatUtils.toCookie(name, value, comment, diff --git a/src/main/java/com/epam/reportportal/formatting/http/HttpResponseFormatter.java b/src/main/java/com/epam/reportportal/formatting/http/HttpResponseFormatter.java index 0313592..a6a7f06 100644 --- a/src/main/java/com/epam/reportportal/formatting/http/HttpResponseFormatter.java +++ b/src/main/java/com/epam/reportportal/formatting/http/HttpResponseFormatter.java @@ -189,7 +189,7 @@ public Builder addCookie(Cookie cookie) { } public Builder addCookie(String name, String value, String comment, String path, String domain, Long maxAge, - Boolean secured, Boolean httpOnly, Date expiryDate, Integer version, String sameSite) { + Boolean secured, Boolean httpOnly, Date expiryDate, Integer version, String sameSite) { return addCookie(HttpFormatUtils.toCookie(name, value, comment, diff --git a/src/main/java/com/epam/reportportal/formatting/http/converters/SanitizingHttpHeaderConverter.java b/src/main/java/com/epam/reportportal/formatting/http/converters/SanitizingHttpHeaderConverter.java index 177a2cf..080ffad 100644 --- a/src/main/java/com/epam/reportportal/formatting/http/converters/SanitizingHttpHeaderConverter.java +++ b/src/main/java/com/epam/reportportal/formatting/http/converters/SanitizingHttpHeaderConverter.java @@ -17,7 +17,6 @@ package com.epam.reportportal.formatting.http.converters; import com.epam.reportportal.formatting.http.entities.Header; -import com.google.common.net.HttpHeaders; import javax.annotation.Nullable; import java.util.Collections; @@ -30,7 +29,7 @@ public class SanitizingHttpHeaderConverter implements Function { public static final Set SENSITIVE_HEADERS = Collections.unmodifiableSet(new HashSet<>(Collections.singletonList( - HttpHeaders.AUTHORIZATION))); + "Authorization"))); public static final Function INSTANCE = new SanitizingHttpHeaderConverter(); diff --git a/src/main/java/com/epam/reportportal/formatting/http/converters/SanitizingUriConverter.java b/src/main/java/com/epam/reportportal/formatting/http/converters/SanitizingUriConverter.java index b8d244d..5cc3926 100644 --- a/src/main/java/com/epam/reportportal/formatting/http/converters/SanitizingUriConverter.java +++ b/src/main/java/com/epam/reportportal/formatting/http/converters/SanitizingUriConverter.java @@ -33,7 +33,7 @@ public String apply(String uriStr) { .map(info -> info.split(":", 2)) .map(info -> { if (info.length > 1) { - return new String[] { info[0], REMOVED_TAG }; + return new String[]{info[0], REMOVED_TAG}; } return info; })