From a251e0549734c8d4a1584a1c9bde3e3c84431162 Mon Sep 17 00:00:00 2001 From: Elita Lobo Date: Sat, 14 Mar 2015 16:46:25 +0530 Subject: [PATCH] Pots tests for restrict filename to python --- testenv/Makefile.am | 5 +++- testenv/Test-restrict-ascii.py | 56 ++++++++++++++++++++++++++++++++++++++ testenv/Test-restrict-lowercase.py | 55 +++++++++++++++++++++++++++++++++++++ testenv/Test-restrict-uppercase.py | 55 +++++++++++++++++++++++++++++++++++++ 4 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 testenv/Test-restrict-ascii.py create mode 100644 testenv/Test-restrict-lowercase.py create mode 100644 testenv/Test-restrict-uppercase.py diff --git a/testenv/Makefile.am b/testenv/Makefile.am index a4e0352..ebc0db3 100644 --- a/testenv/Makefile.am +++ b/testenv/Makefile.am @@ -53,7 +53,10 @@ if HAVE_PYTHON3 Test-Post.py \ Test-504.py \ Test--spider-r.py \ - Test-redirect-crash.py + Test-redirect-crash.py \ + Test-restrict-lowercase.py \ + Test-restrict-uppercase.py \ + Test-restrict-ascii.py # added test cases expected to fail here and under TESTS XFAIL_TESTS = diff --git a/testenv/Test-restrict-ascii.py b/testenv/Test-restrict-ascii.py new file mode 100644 index 0000000..ed245d3 --- /dev/null +++ b/testenv/Test-restrict-ascii.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +from sys import exit +from test.http_test import HTTPTest +from misc.wget_file import WgetFile +""" + Test if Wget escapes any byte in the filename whose value is outside the range of ASCII characters. +""" +TEST_NAME = "Restrict filename:ascii" +# "gnosis" in UTF-8 greek +gnosis = "%CE%B3%CE%BD%CF%89%CF%83%CE%B9%CF%82" +#################################### File Definitions ######################### + +mainpage = """ + + + Some Page Title + + +

+ Some text... +

+ + +""" +A_File = WgetFile(gnosis + ".html", mainpage) + +WGET_OPTIONS = "--restrict-file-names=ascii" +WGET_URLS = [[gnosis + ".html"]] + +Files = [[A_File]] + +ExpectedReturnCode = 0 +ExpectedDownloadedFiles = [A_File] + +######################### Pre and Post Test hooks ############################ +pre_test = { + "ServerFiles" :Files, +} +test_options = { + "WgetCommands" :WGET_OPTIONS, + "Urls" :WGET_URLS, +} +post_test = { + "ExpectedFiles" : ExpectedDownloadedFiles, + "ExpectedRetcode" : ExpectedReturnCode +} + +err = HTTPTest ( + name=TEST_NAME, + pre_hook=pre_test, + test_params=test_options, + post_hook=post_test +).begin () + +exit(err) + diff --git a/testenv/Test-restrict-lowercase.py b/testenv/Test-restrict-lowercase.py new file mode 100644 index 0000000..b718a58 --- /dev/null +++ b/testenv/Test-restrict-lowercase.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +from sys import exit +from test.http_test import HTTPTest +from misc.wget_file import WgetFile +""" + Test if Wget converts filename to lowercase. +""" +TEST_NAME = "Restrict filename:lowercase" +#################################### File Definitions ######################### + +mainpage = """ + + + Some Page Title + + +

+ Some text... +

+ + +""" +A_File = WgetFile("SomeFile.html", mainpage) +B_File = WgetFile("somefile.html", mainpage) + +WGET_OPTIONS = "--restrict-file-names=lowercase" +WGET_URLS = [[ "SomeFile.html"]] + +Files = [[A_File]] + +ExpectedReturnCode = 0 +ExpectedDownloadedFiles = [B_File] + +######################### Pre and Post Test hooks ############################ +pre_test = { + "ServerFiles" :Files, +} +test_options = { + "WgetCommands" :WGET_OPTIONS, + "Urls" :WGET_URLS, +} +post_test = { + "ExpectedFiles" : ExpectedDownloadedFiles, + "ExpectedRetcode" : ExpectedReturnCode +} + +err = HTTPTest ( + name=TEST_NAME, + pre_hook=pre_test, + test_params=test_options, + post_hook=post_test +).begin () + +exit(err) + diff --git a/testenv/Test-restrict-uppercase.py b/testenv/Test-restrict-uppercase.py new file mode 100644 index 0000000..7483a2a --- /dev/null +++ b/testenv/Test-restrict-uppercase.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +from sys import exit +from test.http_test import HTTPTest +from misc.wget_file import WgetFile +""" + Test if Wget converts filename to uppercase. +""" +TEST_NAME = "Restrict filename:uppercase" +#################################### File Definitions ######################### + +mainpage = """ + + + Some Page Title + + +

+ Some text... +

+ + +""" +A_File = WgetFile("SomeFile.html", mainpage) +B_File = WgetFile("SOMEFILE.HTML", mainpage) + +WGET_OPTIONS = "--restrict-file-names=uppercase" +WGET_URLS = [[ "SomeFile.html"]] + +Files = [[A_File]] + +ExpectedReturnCode = 0 +ExpectedDownloadedFiles = [B_File] + +######################### Pre and Post Test hooks ############################ +pre_test = { + "ServerFiles" :Files, +} +test_options = { + "WgetCommands" :WGET_OPTIONS, + "Urls" :WGET_URLS, +} +post_test = { + "ExpectedFiles" : ExpectedDownloadedFiles, + "ExpectedRetcode" : ExpectedReturnCode +} + +err = HTTPTest ( + name=TEST_NAME, + pre_hook=pre_test, + test_params=test_options, + post_hook=post_test +).begin () + +exit(err) + -- 2.1.4