Skip to content

Commit

Permalink
Feature/ids9941 301 return v2 (#155)
Browse files Browse the repository at this point in the history
* added override from 200 to 301 http return code

* fixed tests

* fixed tests

* fixed tests

* moved override to base class

* passed local tests

* updated unit test back after fix

* experiment

* run_test "cws-ui/configuration" 200

* 200

---------

Co-authored-by: Brent J Knickerbocker <[email protected]>
  • Loading branch information
brentjk and Brent J Knickerbocker authored Jul 20, 2023
1 parent 1231077 commit 35d7958
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public void doFilter(

log.trace("doFilter path " + req.getContextPath());



if (log.isTraceEnabled()) {
log.trace("PATH = " + path);
Enumeration<String> reqHeaderNames = req.getHeaderNames();
Expand All @@ -91,6 +93,8 @@ public void doFilter(
}
}



// If skipping resource...
//
if (isSecurityExemptResource(path)) {
Expand All @@ -108,6 +112,7 @@ public void doFilter(
// FIXME: add similar logic as above to redirect Camunda login pages..

chain.doFilter(request, resp); // continue onwards with chain
statusOverride(resp);
return;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public void doFilter(
return;
}



// If skipping resource...
//
if (isSecurityExemptResource(path)) {
Expand All @@ -75,6 +77,7 @@ public void doFilter(
// FIXME: add similar logic as above to redirect Camunda login pages..

chain.doFilter(request, resp); // continue onwards with chain
statusOverride(resp);
return;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,13 @@ else if (path.toLowerCase().endsWith("/logout")) {

return false; // DON'T skip
}


// Simple override of http return for redirect code when http request is valid
protected void statusOverride(HttpServletResponse resp){
if (resp.getStatus() == 200){
resp.setStatus(301);
}
}

protected void logRequestInfo(HttpServletRequest req) {
// Log all of the headers
Expand Down
2 changes: 1 addition & 1 deletion cws-test/src/test/java/jpl/cws/test/RestGetTaskTest2.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void httpbinTest() {
task.execute(execution);

assertTrue("TaskResult httpStatusCode variable unexpected value",
execution.getVariable(VAR_PREFIX + "httpStatusCode").equals("200"));
execution.getVariable(VAR_PREFIX + "httpStatusCode").equals("301"));
System.out.println("RESPONSE:\n" + execution.getVariable(VAR_PREFIX + "response"));
}
}
4 changes: 2 additions & 2 deletions cws-test/src/test/java/jpl/cws/test/RestPostTaskTest2.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void httpbinTest() {
task.execute(execution);

assertTrue("TaskResult httpStatusCode variable unexpected value",
execution.getVariable(VAR_PREFIX + "httpStatusCode").equals("200"));
execution.getVariable(VAR_PREFIX + "httpStatusCode").equals("301"));
}

@Test
Expand All @@ -36,7 +36,7 @@ public void httpbinBodyTest() {
task.execute(execution);

assertTrue("TaskResult httpStatusCode variable unexpected value",
execution.getVariable(VAR_PREFIX + "httpStatusCode").equals("200"));
execution.getVariable(VAR_PREFIX + "httpStatusCode").equals("301"));
System.out.println(execution.getVariable(VAR_PREFIX + "response"));
}

Expand Down

0 comments on commit 35d7958

Please sign in to comment.