Skip to content
Open
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
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Mon Dec 30 16:31:57 CET 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
43 changes: 24 additions & 19 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
import org.slf4j.LoggerFactory;

import java.net.URISyntaxException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -74,6 +71,12 @@ private HttpRequestWrapper generateFrom(EndpointTestRequestData endpointTestRequ
if (endpointTestRequestData.hasHeaderParameters()) {
updateRequestWithRequestHeaders(httpRequest, endpointTestRequestData.getHeaderParameters());
}
if ((httpRequest.getHeaders("content-type") == null
|| Arrays.stream(httpRequest.getHeaders("content-type")).count() == 0 )
&& !endpointTestRequestData.getConsumesMimeTypes().isEmpty()){
httpRequest.addHeader("content-type", endpointTestRequestData.getConsumesMimeTypes().get(0));
}
//httpRequest.addHeader("content-type", "application/json");
} catch (URISyntaxException uriSyntaxException) {
logger.error("Couldn't generate http request for {}", endpointTestRequestData, uriSyntaxException);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public List<List<PropertyValueNode>> fuzz(Fuzzer fuzzer) {
@Override
public Map<String, Object> bodyParameterJsonRepresentationMap() {
HashMap<String, Object> representationMap = new HashMap<>(1);
if(value == null) {
return representationMap;
}
representationMap.put(this.getName(), value.stream().map(PropertyValueNode::bodyParameterJsonRepresentationMap).collect(Collectors.toList()));

return representationMap;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/imperva/apiattacktool/tests/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ private void testEndpoint(HttpRequest httpRequest, HttpResponseValidator httpRes
try {
httpResponse = httpClient.execute(httpHost, httpRequest);
} catch (Exception anyException) {
TestReporter.log("Error connecting to target! " + anyException.getMessage());
TestReporter.log("Error connecting to target! " + anyException.getMessage());
TestReporter.log("");
Assert.fail(anyException.getMessage());
return;
}

int statusCode = httpResponse.getStatusLine().getStatusCode();
boolean isStatusCodeValid = httpResponseValidator.isValidHttpCode(statusCode);
TestReporter.log((isStatusCodeValid? " " : " ") +"Request was: " + httpRequest.toString() + ", Response status code: " + statusCode + (isStatusCodeValid? " " : " (UNEXPECTED)"));
TestReporter.log((isStatusCodeValid? "ok " : "not ok ") +"Request was: " + httpRequest.toString() + ", Response status code: " + statusCode + (isStatusCodeValid? " " : " (UNEXPECTED)"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change. Do the visual marks create any issues? Their intention was only to help see whether there were issues visually.
I suggest having both the text and the visual marks.

if (!isStatusCodeValid) {
TestReporter.log(httpResponseValidator.toString());
}
Expand Down