Skip to content

Commit

Permalink
Fix copy/paste error. Test httpOnly rather than secure
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Aug 22, 2024
1 parent 985a640 commit 7dcc49c
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -720,12 +720,12 @@ public void getHttpOnlyTest(@SuppressWarnings("unused") HttpServletRequest reque
Cookie testCookie = new Cookie("name1", "value1");

boolean expectedResult = false;
boolean result = testCookie.getSecure();
boolean result = testCookie.isHttpOnly();

response.addCookie(testCookie);
if (result != expectedResult) {
passed = false;
pw.println("getSecure() returned an incorrect result");
pw.println("isHttpOnly() returned an incorrect result");
pw.println("Expected = " + expectedResult + " ");
pw.println("Actual = |" + result + "| ");
} else {
Expand All @@ -741,12 +741,12 @@ public void getAttributeHttpOnlyTest(@SuppressWarnings("unused") HttpServletRequ
boolean passed = false;
Cookie testCookie = new Cookie("name1", "value1");

String result = testCookie.getAttribute("secure");
String result = testCookie.getAttribute("httponly");

response.addCookie(testCookie);
if (result != null) {
passed = false;
pw.println("getAttribute(\"Secure\") returned non-null result");
pw.println("getAttribute(\"HttpOnly\") returned non-null result");
pw.println("Actual = |" + result + "| ");
} else {
passed = true;
Expand All @@ -762,13 +762,13 @@ public void setHttpOnlyTest(@SuppressWarnings("unused") HttpServletRequest reque
Cookie testCookie = new Cookie("name1", "value1");

boolean expectedResult = true;
testCookie.setSecure(expectedResult);
boolean result = testCookie.getSecure();
testCookie.setHttpOnly(expectedResult);
boolean result = testCookie.isHttpOnly();

response.addCookie(testCookie);
if (result != expectedResult) {
passed = false;
pw.println("getSecure() returned an incorrect result ");
pw.println("isHttpOnly() returned an incorrect result ");
pw.println("Expected = " + expectedResult + " ");
pw.println("Actual = |" + result + "| ");
} else {
Expand All @@ -785,13 +785,13 @@ public void setAttributeHttpOnlyTest(@SuppressWarnings("unused") HttpServletRequ
Cookie testCookie = new Cookie("name1", "value1");

boolean expectedResult = true;
testCookie.setAttribute("secure", EMPTY_STRING);
boolean result = testCookie.getSecure();
testCookie.setAttribute("httponly", EMPTY_STRING);
boolean result = testCookie.isHttpOnly();

response.addCookie(testCookie);
if (result != expectedResult) {
passed = false;
pw.println("getSecure() returned an incorrect result ");
pw.println("isHttpOnly() returned an incorrect result ");
pw.println("Expected = " + expectedResult + " ");
pw.println("Actual = |" + result + "| ");
} else {
Expand All @@ -808,13 +808,13 @@ public void setAttributeHttpOnlyInvalidTest(@SuppressWarnings("unused") HttpServ
Cookie testCookie = new Cookie("name1", "value1");

boolean expectedResult = false;
testCookie.setAttribute("secure", "other");
boolean result = testCookie.getSecure();
testCookie.setAttribute("httponly", "other");
boolean result = testCookie.isHttpOnly();

response.addCookie(testCookie);
if (result != expectedResult) {
passed = false;
pw.println("getSecure() returned an incorrect result ");
pw.println("isHttpOnly() returned an incorrect result ");
pw.println("Expected = " + expectedResult + " ");
pw.println("Actual = |" + result + "| ");
} else {
Expand Down

0 comments on commit 7dcc49c

Please sign in to comment.