Skip to content

Commit

Permalink
removing bits of code to allow the original requested new session pay…
Browse files Browse the repository at this point in the history
…load to be forwarded to the node

There's some black magic in grid, where a registered nodes capabilities would get munged with a new session request that was forwarded to the node.

Don't care about removing stuff related to grid v1, that's no longer supported.

This has no affect on grid customizers, beforeSession / beforeCommand still process as they did... but now all of the request is available without it being munged.

This enables users to pass the 'Required Capabilities' in the new session request and it will actually come through.
  • Loading branch information
lukeis committed Oct 14, 2016
1 parent b6068ae commit 95698ce
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,6 @@ public Map<String, Object> extractDesiredCapability() {
throw new RuntimeException("Error");
}

@Override
public String getNewSessionRequestedCapability(TestSession session) {
try {
String body = getBody();
String[] pieces = body.split("&");
StringBuilder builder = new StringBuilder();

for (String piece : pieces) {
if (piece.startsWith("1=")) {
piece = URLDecoder.decode(piece, "UTF-8");
String parts[] = piece.split("1=");
piece =
(String) BrowserNameUtils.parseGrid2Environment(piece).get(CapabilityType.BROWSER_NAME);
}
builder.append(piece).append("&");
}
return builder.toString();
} catch (UnsupportedEncodingException ignore) {

}
throw new NewSessionException("Error with the request ");

}

@Override
public String getBody() {
String postBody = super.getBody();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ public RequestHandler(SeleniumBasedRequest request, HttpServletResponse respons
public void forwardNewSessionRequestAndUpdateRegistry(TestSession session)
throws NewSessionException {
try {
String content = request.getNewSessionRequestedCapability(session);
getRequest().setBody(content);
session.forward(getRequest(), getResponse(), true);
} catch (IOException e) {
//log.warning("Error forwarding the request " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ public Registry getRegistry() {
*/
public abstract Map<String, Object> extractDesiredCapability();

// TODO freynaud remove the TestSession parameter.The listener can modify the
// original request instead.
public abstract String getNewSessionRequestedCapability(TestSession session);

public RequestType getRequestType() {
return type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,4 @@ public Map<String, Object> extractDesiredCapability() {
throw new GridException("Cannot extract a capabilities from the request: " + json, e);
}
}

@Override
public String getNewSessionRequestedCapability(TestSession session) {
JsonObject c = new JsonObject();
c.add("desiredCapabilities",
new BeanToJsonConverter().convertObject(session.getRequestedCapabilities()));
return new Gson().toJson(c);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ public void prepareANodePointingToANonExistingFirefox() throws Exception {

remote = GridTestHelper.getRemoteWithoutCapabilities(hub.getUrl(), GridRole.NODE);

DesiredCapabilities firefox = DesiredCapabilities.firefox();
firefox.setCapability(FirefoxDriver.BINARY, WRONG_PATH);
remote.addBrowser(firefox, 1);
remote.addBrowser(DesiredCapabilities.firefox(), 1);

remote.setRemoteServer(new SeleniumServer(remote.getConfiguration()));
remote.startRemoteServer();
Expand All @@ -91,6 +89,7 @@ public void serverCrashesStartingFirefox() throws MalformedURLException {
WebDriverException exception = null;
try {
DesiredCapabilities ff = DesiredCapabilities.firefox();
ff.setCapability(FirefoxDriver.BINARY, WRONG_PATH);
new RemoteWebDriver(hub.getWebDriverHubRequestURL(), ff);
} catch (WebDriverException expected) {
exception = expected;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,6 @@ private SeleniumBasedRequest getNewRequest(Map<String, Object> desiredCapability
HttpServletRequest httpreq = mock(HttpServletRequest.class);
return new SeleniumBasedRequest(httpreq, registry, RequestType.START_SESSION, desiredCapability) {

public String getNewSessionRequestedCapability(TestSession session) {
return null;
}

public ExternalSessionKey extractSession() {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ public static SeleniumBasedRequest createMockedRequest(Registry registry,
HttpServletRequest request = mock(HttpServletRequest.class);
return new SeleniumBasedRequest(request, registry, type, desiredCapability) {

@Override
public String getNewSessionRequestedCapability(TestSession session) {
return null;
}

@Override
public ExternalSessionKey extractSession() {
return null;
Expand Down

0 comments on commit 95698ce

Please sign in to comment.