Skip to content

Commit

Permalink
[grid] Reverting change, all requests should include content type
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Sep 4, 2020
1 parent 0d3ce73 commit 8764831
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public class NetworkOptions {

private final Config config;
// These are commonly used by process which can't set various headers.
// Checks are skipped when the session already exists
private final Set<String> SKIP_CHECKS_ON = ImmutableSet.of("/status", "/readyz", "\\/session\\/(.*)");
private final Set<String> SKIP_CHECKS_ON = ImmutableSet.of("/status", "/readyz");

public NetworkOptions(Config config) {
this.config = Require.nonNull("Config", config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public HttpHandler apply(HttpHandler httpHandler) {
Require.nonNull("Next handler", httpHandler);

return req -> {
if (skipChecksOn.stream().anyMatch(s -> req.getUri().matches(s))) {
if (skipChecksOn.contains(req.getUri())) {
return httpHandler.execute(req);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.HttpResponse;

import java.util.UUID;

import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR;
import static java.net.HttpURLConnection.HTTP_OK;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -56,15 +54,6 @@ public void shouldAllowRequestsWithNoContentTypeWhenSkipCheckOnMatches() {
assertThat(res.getStatus()).isEqualTo(HTTP_OK);
}

@Test
public void shouldAllowRequestsWithNoContentTypeWhenSkipCheckOnMatchesRegex() {
HttpResponse res = new EnsureSpecCompliantHeaders(ImmutableList.of(), ImmutableSet.of("\\/paipa\\/(.*)"))
.apply(alwaysOk)
.execute(new HttpRequest(POST, String.format("/paipa/%s", UUID.randomUUID().toString())));

assertThat(res.getStatus()).isEqualTo(HTTP_OK);
}

@Test
public void requestsWithAnOriginHeaderShouldBeBlocked() {
HttpResponse res = new EnsureSpecCompliantHeaders(ImmutableList.of(), ImmutableSet.of())
Expand Down

0 comments on commit 8764831

Please sign in to comment.