| 1 |
#!/usr/bin/env python3 |
| 2 |
from sys import exit |
| 3 |
from test.http_test import HTTPTest |
| 4 |
from misc.wget_file import WgetFile |
| 5 |
import os |
| 6 |
|
| 7 |
# This test caused wget up to 1.16 to crash |
| 8 |
#os.environ["LC_ALL"] = "en_US.UTF-8" |
| 9 |
|
| 10 |
urls = [ |
| 11 |
"File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory", |
| 12 |
"File formats/Images/SVG, Scalable Vector Graphics/html, W3C v1.2 rec (tiny)/directory/", |
| 13 |
"File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory/somefile.rng", |
| 14 |
"File%20formats/Images/SVG%2C%20Scalable%20Vector%20Graphics/html%2c%20W3C%20v1.2%20rec%20%28tiny%29/directory/somefile.rng", |
| 15 |
"File%20formats/Images/SVG%2C%20Scalable%20Vector%20Graphics/html%2c%20W3C%20v1.2%20rec%20%28tiny%29/directory/", |
| 16 |
"File%20formats/Images/SVG%2C%20Scalable%20Vector%20Graphics/html%2C%20W3C%20v1.2%20rec%20%28tiny%29/directory"] |
| 17 |
|
| 18 |
|
| 19 |
redirected = [ |
| 20 |
"File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory/" |
| 21 |
] |
| 22 |
|
| 23 |
############# File Definitions ############################################### |
| 24 |
Index = "" |
| 25 |
for i in urls: |
| 26 |
Index = Index + "<a href='/%s'></a>" % i |
| 27 |
|
| 28 |
File1 = "" |
| 29 |
|
| 30 |
def get_redirect(url): |
| 31 |
data = { |
| 32 |
"File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory" : |
| 33 |
"File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory/", |
| 34 |
"File%20formats/Images/SVG%2C%20Scalable%20Vector%20Graphics/html%2C%20W3C%20v1.2%20rec%20%28tiny%29/directory" : |
| 35 |
"File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory/" |
| 36 |
} |
| 37 |
dest = data.get(url) |
| 38 |
if dest: |
| 39 |
return {"Response" : 301, |
| 40 |
"SendHeader" : {"Location" : "/%s" % dest}} |
| 41 |
return None |
| 42 |
|
| 43 |
|
| 44 |
index_url = "File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/index.html" |
| 45 |
Index_File = WgetFile (index_url, Index) |
| 46 |
Files = ([Index_File] + [WgetFile(i, File1, rules=get_redirect(i)) for i in (redirected + urls)]) |
| 47 |
|
| 48 |
WGET_OPTIONS = "--recursive -e robots=off" |
| 49 |
|
| 50 |
WGET_URLS = [[index_url]] |
| 51 |
|
| 52 |
ExpectedReturnCode = 0 |
| 53 |
|
| 54 |
################ Pre and Post Test Hooks ##################################### |
| 55 |
pre_test = { |
| 56 |
"ServerFiles" : [Files] |
| 57 |
} |
| 58 |
test_options = { |
| 59 |
"WgetCommands" : WGET_OPTIONS, |
| 60 |
"Urls" : WGET_URLS |
| 61 |
} |
| 62 |
post_test = { |
| 63 |
"ExpectedRetcode" : ExpectedReturnCode, |
| 64 |
} |
| 65 |
|
| 66 |
err = HTTPTest ( |
| 67 |
pre_hook=pre_test, |
| 68 |
test_params=test_options, |
| 69 |
post_hook=post_test |
| 70 |
).begin () |
| 71 |
|
| 72 |
exit (err) |