Skip to content

Release #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ jobs:
run: ./gradlew build

- name: Codecov upload
run: bash <(curl -s https://codecov.io/bash)
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

## [Unreleased]
### Changed
- Client version updated on [5.2.26](https://github.com/reportportal/client-java/releases/tag/5.2.26), by @HardNorth
- `utils-java-formatting` dependency version updated on [5.2.5](https://github.com/reportportal/utils-java-formatting/releases/tag/5.2.5), by @HardNorth

## [5.3.6]
### Added
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repositories {
}

dependencies {
api 'com.epam.reportportal:utils-java-formatting:5.2.4'
api 'com.epam.reportportal:utils-java-formatting:5.2.5'
compileOnly "com.epam.reportportal:client-java:${client_version}"
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'commons-codec:commons-codec:1.15'
Expand All @@ -46,7 +46,7 @@ dependencies {
}

testImplementation "com.epam.reportportal:client-java:${client_version}"
testImplementation 'com.epam.reportportal:agent-java-test-utils:0.0.2'
testImplementation 'com.epam.reportportal:agent-java-test-utils:0.0.7'

testImplementation("org.junit.platform:junit-platform-runner:${junit5_runner_version}") {
exclude module: 'junit'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description=Report Portal logger for REST Assured
junit5_version=5.6.3
junit5_runner_version=1.6.3
mockito_version=4.5.1
client_version=5.2.23
client_version=5.2.26
scripts_url=https://raw.githubusercontent.com/reportportal/gradle-scripts
scripts_branch=master
excludeTests=
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.epam.reportportal.service.Launch;
import com.epam.reportportal.service.ReportPortal;
import com.epam.reportportal.service.step.StepReporter;
import com.epam.reportportal.util.test.CommonUtils;
import com.epam.reportportal.utils.files.Utils;
import io.restassured.config.LogConfig;
import io.restassured.config.RestAssuredConfig;
Expand Down Expand Up @@ -108,31 +109,31 @@ public Response send(RequestSender requestSender) {

@Override
public Response next(FilterableRequestSpecification requestSpecification,
FilterableResponseSpecification responseSpecification) {
FilterableResponseSpecification responseSpecification) {
return response;
}
};
}

public static Iterable<Object[]> requestData() {
return Arrays.asList(
new Object[] { JSON_TYPE, "{\"object\": {\"key\": \"value\"}}", "{\"object\": {\"key\": \"value\"}}", JsonPrettier.INSTANCE,
null, null },
new Object[] { "application/xml", "<test><key><value>value</value></key></test>",
"<test><key><value>value</value></key></test>", XmlPrettier.INSTANCE, null, null }
new Object[]{JSON_TYPE, "{\"object\": {\"key\": \"value\"}}", "{\"object\": {\"key\": \"value\"}}",
JsonPrettier.INSTANCE, null, null},
new Object[]{"application/xml", "<test><key><value>value</value></key></test>",
"<test><key><value>value</value></key></test>", XmlPrettier.INSTANCE, null, null}
);
}

private void runFilter(FilterableRequestSpecification requestSpecification, Response responseObject,
Consumer<MockedStatic<ReportPortal>> mocks, OrderedFilter filter) {
Consumer<MockedStatic<ReportPortal>> mocks, OrderedFilter filter) {
try (MockedStatic<ReportPortal> utilities = Mockito.mockStatic(ReportPortal.class)) {
mocks.accept(utilities);
filter.filter(requestSpecification, null, getFilterContext(responseObject));
}
}

private void runFilter(FilterableRequestSpecification requestSpecification, Response responseObject,
Consumer<MockedStatic<ReportPortal>> mocks) {
Consumer<MockedStatic<ReportPortal>> mocks) {
runFilter(requestSpecification, responseObject, mocks, new ReportPortalRestAssuredLoggingFilter(42, LogLevel.INFO));
}

Expand All @@ -147,7 +148,7 @@ private List<String> runFilterTextMessageCapture(FilterableRequestSpecification
}

private List<ReportPortalMessage> runFilterBinaryMessageCapture(FilterableRequestSpecification requestSpecification,
Response responseObject) {
Response responseObject) {
ArgumentCaptor<ReportPortalMessage> logCapture = ArgumentCaptor.forClass(ReportPortalMessage.class);
runFilter(
requestSpecification,
Expand All @@ -167,7 +168,7 @@ private Triple<List<String>, List<String>, List<ReportPortalMessage>> runFilterC
StepReporter reporter = mock(StepReporter.class);
utilities.when(Launch::currentLaunch).thenReturn(launch);
when(launch.getStepReporter()).thenReturn(reporter);
doNothing().when(reporter).sendStep(any(ItemStatus.class), stepCaptor.capture());
when(reporter.sendStep(any(ItemStatus.class), stepCaptor.capture())).thenReturn(CommonUtils.createMaybeUuid());
runFilter(
requestSpecification, responseObject, mock -> {
mock.when(() -> ReportPortal.emitLog(stringArgumentCaptor.capture(), anyString(), any(Date.class)))
Expand Down Expand Up @@ -222,7 +223,7 @@ public void test_rest_assured_logger_null_values() {
@MethodSource("requestData")
@SuppressWarnings("rawtypes")
public void test_rest_assured_logger_text_body(String mimeType, Object requestBody, Object responseBody,
Function<String, String> prettier) {
Function<String, String> prettier) {
FilterableRequestSpecification requestSpecification = mockBasicRequest(mimeType);
when(requestSpecification.getBody()).thenReturn(requestBody);

Expand All @@ -244,7 +245,7 @@ public void test_rest_assured_logger_text_body(String mimeType, Object requestBo
}

public static Iterable<Object[]> testTypes() {
return Arrays.asList(new Object[] { HTML_TYPE }, new Object[] { null });
return Arrays.asList(new Object[]{HTML_TYPE}, new Object[]{null});
}

@ParameterizedTest
Expand Down Expand Up @@ -361,7 +362,7 @@ private byte[] getResource(String imagePath) {
private static final String WILDCARD_TYPE = "*/*";

@ParameterizedTest
@ValueSource(strings = { IMAGE_TYPE, WILDCARD_TYPE })
@ValueSource(strings = {IMAGE_TYPE, WILDCARD_TYPE})
@SuppressWarnings("rawtypes")
public void test_rest_assured_logger_image_body(String mimeType) throws IOException {
FilterableRequestSpecification requestSpecification = mockBasicRequest(mimeType);
Expand Down Expand Up @@ -461,7 +462,7 @@ private MultiPartSpecification getBinaryPart(String mimeType, String filePath, b
}

@ParameterizedTest
@ValueSource(booleans = { true, false })
@ValueSource(booleans = {true, false})
public void test_rest_assured_logger_image_multipart(boolean isFile) throws IOException {
byte[] image = getResource(IMAGE);
String imageType = ContentType.IMAGE_JPEG.getMimeType();
Expand Down Expand Up @@ -557,13 +558,13 @@ public void test_rest_assured_logger_text_and_image_multipart() throws IOExcepti

public static Iterable<Object[]> invalidContentTypes() {
return Arrays.asList(
new Object[] { "", ContentType.APPLICATION_OCTET_STREAM.getMimeType() },
new Object[] { null, ContentType.APPLICATION_OCTET_STREAM.getMimeType() },
new Object[] { "*/*", "*/*" },
new Object[] { "something invalid", "something invalid" },
new Object[] { "/", "/" },
new Object[] { "#*'\\`%^!@/\"$;", "#*'\\`%^!@/\"$" },
new Object[] { "a/a;F#%235f\\=f324$%^&", "a/a" }
new Object[]{"", ContentType.APPLICATION_OCTET_STREAM.getMimeType()},
new Object[]{null, ContentType.APPLICATION_OCTET_STREAM.getMimeType()},
new Object[]{"*/*", "*/*"},
new Object[]{"something invalid", "something invalid"},
new Object[]{"/", "/"},
new Object[]{"#*'\\`%^!@/\"$;", "#*'\\`%^!@/\"$"},
new Object[]{"a/a;F#%235f\\=f324$%^&", "a/a"}
);
}

Expand Down Expand Up @@ -641,18 +642,24 @@ public void test_rest_assured_logger_text_as_file_multipart() {
@Test
public void test_rest_assured_header_filter() {
FilterableRequestSpecification requestSpecification = mockBasicRequest(HTML_TYPE);
RestAssuredConfig config = RestAssuredConfig.config().logConfig(LogConfig.logConfig().blacklistHeader("Authorization"));
RestAssuredConfig config = RestAssuredConfig.config().logConfig(
LogConfig.logConfig().blacklistHeader("Authorization").blacklistHeader("Set-Cookie"));
when(requestSpecification.getConfig()).thenReturn(config);
Headers headers = new Headers(new Header(HttpHeaders.AUTHORIZATION, "Bearer some_token"));
when(requestSpecification.getHeaders()).thenReturn(headers);
Headers requestHeaders = new Headers(new Header(HttpHeaders.AUTHORIZATION, "Bearer some_token"),
new Header("Cookies", "request_cookie"));
when(requestSpecification.getHeaders()).thenReturn(requestHeaders);
Response responseObject = mockBasicResponse(HTML_TYPE);
Headers responseHeaders = new Headers(new Header("Set-Cookie", "response_cookie"));
when(responseObject.getHeaders()).thenReturn(responseHeaders);

List<String> logs = runFilterTextMessageCapture(requestSpecification, responseObject);
assertThat(logs, hasSize(2)); // Request + Response

String headerString = "\n\n**Headers**\n" + HttpHeaders.AUTHORIZATION + ": " + REMOVED_TAG;
String requestHeaderString = "\n\n**Headers**\n" + HttpHeaders.AUTHORIZATION + ": " + REMOVED_TAG +
"\nCookies: request_cookie";
assertThat(logs.get(0), equalTo(EMPTY_REQUEST + requestHeaderString));

assertThat(logs.get(0), equalTo(EMPTY_REQUEST + headerString));
assertThat(logs.get(1), equalTo(EMPTY_RESPONSE));
String responseHeaderString = "\n\n**Headers**\nSet-Cookie: " + REMOVED_TAG;
assertThat(logs.get(1), equalTo(EMPTY_RESPONSE + responseHeaderString));
}
}
Loading