-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix mime-types of displayed content in help servlet
- Loading branch information
Showing
6 changed files
with
126 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
java/server/test/org/openqa/grid/web/servlet/DisplayHelpHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you 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 org.openqa.grid.web.servlet; | ||
|
||
import static java.net.HttpURLConnection.HTTP_NOT_FOUND; | ||
import static java.net.HttpURLConnection.HTTP_OK; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.openqa.selenium.remote.http.HttpMethod.GET; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.openqa.grid.common.GridRole; | ||
import org.openqa.selenium.json.Json; | ||
import org.openqa.selenium.remote.http.HttpRequest; | ||
import org.openqa.selenium.remote.http.HttpResponse; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.servlet.ServletException; | ||
|
||
public class DisplayHelpHandlerTest { | ||
|
||
private DisplayHelpHandler handler; | ||
|
||
@Before | ||
public void setUp() { | ||
handler = new DisplayHelpHandler(new Json(), GridRole.NOT_GRID, "/wd/hub"); | ||
} | ||
|
||
@Test | ||
public void testGetHelpPageForStandalone() throws IOException { | ||
assertThat(handler.getHelperType()) | ||
.isEqualTo("Standalone"); | ||
|
||
HttpRequest request = new HttpRequest(GET, "/"); | ||
HttpResponse response = new HttpResponse(); | ||
handler.execute(request, response); | ||
assertThat(response.getStatus()).isEqualTo(HTTP_OK); | ||
|
||
String body = response.getContentString(); | ||
assertThat(body).isNotNull().contains( | ||
"Whoops! The URL specified routes to this help page.", | ||
"\"type\": \"Standalone\"", | ||
"\"consoleLink\": \"\\u002fwd\\u002fhub\""); | ||
} | ||
|
||
@Test | ||
public void testGetHelpPageAsset() throws IOException { | ||
HttpResponse response = new HttpResponse(); | ||
|
||
handler.execute(new HttpRequest(GET, "/assets/displayhelpservlet.css"), response); | ||
|
||
assertThat(response.getStatus()).isEqualTo(HTTP_OK); | ||
assertThat(response.getContentString()).isNotNull().contains("#help-heading #logo"); | ||
} | ||
|
||
@Test | ||
public void testNoSuchAsset() throws IOException { | ||
HttpResponse response = new HttpResponse(); | ||
|
||
handler.execute(new HttpRequest(GET, "/assets/foo.bar"), response); | ||
|
||
assertThat(response.getStatus()).isEqualTo(HTTP_NOT_FOUND); | ||
} | ||
|
||
@Test | ||
public void testAccessRoot() throws IOException { | ||
HttpResponse response = new HttpResponse(); | ||
|
||
handler.execute(new HttpRequest(GET, "/"), response); | ||
|
||
assertThat(response.getStatus()).isEqualTo(HTTP_OK); | ||
} | ||
|
||
} |
86 changes: 0 additions & 86 deletions
86
java/server/test/org/openqa/grid/web/servlet/DisplayHelpServletTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters