From d09d452ad561ec86f45aa90349655bd1438b971e Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 10 Jan 2017 12:37:37 +0100 Subject: [PATCH] Added test cases for PATH_INFO and percent_encoded_path_info for root url cases. Removed obsolete calls from TEST_EXECUTION_I . --- .../wsf/tests/server/test_execution_i.e | 20 ++++----- .../tests/src/test_wsf_request_script_url.e | 43 +++++++++++++++++++ 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/library/server/wsf/tests/server/test_execution_i.e b/library/server/wsf/tests/server/test_execution_i.e index 56537b06..46397a89 100644 --- a/library/server/wsf/tests/server/test_execution_i.e +++ b/library/server/wsf/tests/server/test_execution_i.e @@ -127,7 +127,7 @@ feature -- Execution new_file (req: WSF_REQUEST; a_suffix: STRING): detachable FILE local - dp, p, fp: FILE_NAME + dp, p, fp: PATH d: DIRECTORY i: INTEGER f: detachable FILE @@ -135,7 +135,7 @@ feature -- Execution do if retried = 0 then create dp.make_from_string ("logs") - create d.make (dp.string) + create d.make_with_path (dp) if not d.exists then d.recursive_create_dir end @@ -147,29 +147,25 @@ feature -- Execution from i := 0 - create fp.make_from_string (dp.string) if p.is_empty then - fp.set_file_name (p.string + a_suffix) + fp := dp.extended (a_suffix) else - fp.set_file_name (p.string + "-" + a_suffix) + fp := dp.extended_path (p).appended ("-" + a_suffix) end - create {PLAIN_TEXT_FILE} f.make (fp.string) + create {PLAIN_TEXT_FILE} f.make_with_path (fp) until not f.exists loop i := i + 1 - create fp.make_from_string (dp.string) if p.is_empty then - fp.set_file_name (p.string + i.out + "-" + a_suffix) + fp := dp.extended (i.out + "-" + a_suffix) else - fp.set_file_name (p.string + "_" + i.out + "-" + a_suffix) + fp := dp.extended_path (p).appended ("_" + i.out + "-" + a_suffix) end - - f.make (fp.string) + f.make_with_path (fp) end f.open_write elseif retried < 5 then - -- Eventually another request created the file at the same time .. f := new_file (req, a_suffix) else diff --git a/library/server/wsf/tests/src/test_wsf_request_script_url.e b/library/server/wsf/tests/src/test_wsf_request_script_url.e index da0e07e7..2b1295e6 100644 --- a/library/server/wsf/tests/src/test_wsf_request_script_url.e +++ b/library/server/wsf/tests/src/test_wsf_request_script_url.e @@ -48,6 +48,8 @@ feature -- Tests ) s := req.script_url ("/new/path/") assert ("script_url (/new/path/) = %""+s+"%" but should be %"/foo/bar/new/path/%"", s.same_string ("/foo/bar/new/path/")) + assert ("valid path info", req.path_info.same_string_general ("/test/home")) + assert ("valid path info", req.percent_encoded_path_info.same_string_general ("/test/home")) end test_script_url_2 @@ -84,7 +86,48 @@ feature -- Tests ) s := req.script_url ("/new/path/") assert ("script_url (/new/path/) = %""+s+"%" but should be %"/intranet/collab/cms/new/path/%"", s.same_string ("/intranet/collab/cms/new/path/")) + assert ("path_info", req.path_info.same_string_general ("/home")) + assert ("percent_encoded_path_info", req.percent_encoded_path_info.same_string_general ("/home")) + end + test_script_url_4 + local + req: WSF_REQUEST + s: READABLE_STRING_8 + do + --| Case #3 + req := new_request (<< + ["REQUEST_METHOD", "GET"], + ["QUERY_STRING", ""], + ["REQUEST_URI", "/support/"], + ["SCRIPT_NAME", "/support/esa_api.exe"], + ["PATH_INFO", ""] + >> + ) + s := req.script_url ("/new/path/") + assert ("script_url (/new/path/) = %""+s+"%" but should be %"/support/new/path/%"", s.same_string ("/support/new/path/")) + assert ("path_info", req.path_info.same_string_general ("")) + assert ("percent_encoded_path_info", req.percent_encoded_path_info.same_string_general ("")) + end + + test_script_url_5 + local + req: WSF_REQUEST + s: READABLE_STRING_8 + do + --| Case #3 + req := new_request (<< + ["REQUEST_METHOD", "GET"], + ["QUERY_STRING", ""], + ["REQUEST_URI", "/support/"], + ["SCRIPT_NAME", "/support/esa_api.exe"], + ["PATH_INFO", "/"] + >> + ) + s := req.script_url ("/new/path/") + assert ("script_url (/new/path/) = %""+s+"%" but should be %"/support/new/path/%"", s.same_string ("/support/new/path/")) + assert ("path_info", req.path_info.same_string_general ("/")) + assert ("percent_encoded_path_info", req.percent_encoded_path_info.same_string_general ("/")) end feature {NONE} -- Implementation