Example #1
0
# robots = """
# User-agent: *
# Disallow: /dummy.txt
# """

log = """\
REASON\tU_URL\tU_SCHEME\tU_HOST\tU_PORT\tU_PATH\tU_PARAMS\tU_QUERY\tU_FRAGMENT\tP_URL\tP_SCHEME\tP_HOST\tP_PORT\tP_PATH\tP_PARAMS\tP_QUERY\tP_FRAGMENT
BLACKLIST\thttp%3A//localhost%3A{{port}}/index.html\tSCHEME_HTTP\tlocalhost\t{{port}}\tindex.html\t\t\t\thttp%3A//localhost%3A{{port}}/secondpage.html\tSCHEME_HTTP\tlocalhost\t{{port}}\tsecondpage.html\t\t\t
ROBOTS\thttp%3A//localhost%3A{{port}}/dummy.txt\tSCHEME_HTTP\tlocalhost\t{{port}}\tdummy.txt\t\t\t\thttp%3A//localhost%3A{{port}}/thirdpage.html\tSCHEME_HTTP\tlocalhost\t{{port}}\tthirdpage.html\t\t\t
SPANNEDHOST\thttp%3A//no.such.domain/\tSCHEME_HTTP\tno.such.domain\t80\t\t\t\t\thttp%3A//localhost%3A{{port}}/thirdpage.html\tSCHEME_HTTP\tlocalhost\t{{port}}\tthirdpage.html\t\t\t
"""

dummyfile = "Don't care."

index_html = WgetFile("index.html", mainpage)
secondpage_html = WgetFile("secondpage.html", secondpage)
thirdpage_html = WgetFile("thirdpage.html", thirdpage)
# robots_txt = WgetFile ("robots.txt", robots)
dummy_txt = WgetFile("dummy.txt", dummyfile)
log_csv = WgetFile("log.csv", log)

WGET_OPTIONS = "-nd -r --rejected-log log.csv"
WGET_URLS = [["index.html"]]

# Files = [[index_html, secondpage_html, thirdpage_html, robots_txt, dummy_txt]]
Files = [[index_html, secondpage_html, thirdpage_html, dummy_txt]]

ExpectedReturnCode = 0
# ExpectedDownloadedFiles = [index_html, secondpage_html, thirdpage_html, robots_txt, log_csv]
ExpectedDownloadedFiles = [
"""
TEST_NAME = "Auth no challenge in URL"
############# File Definitions ###############################################
File1 = "Need a cookie?"

File1_rules = {
    "Authentication": {
        "Type": "Basic",
        "User": "******",
        "Pass": "******"
    },
    "ExpectHeader": {
        "Authorization": "Basic UGFjbWFuOk9tbm9tbm9t"
    }
}
A_File = WgetFile("File1", File1, rules=File1_rules)

WGET_OPTIONS = "--auth-no-challenge http://Pacman:Omnomnom@localhost:{{port}}/File1"
WGET_URLS = [[]]

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
File2_down = WgetFile ("dir/File2", File2)
File2_nono = WgetFile ("File2_lowPref", File2_lowPref)

# rejected by libmetalink
File3_orig = WgetFile ("File3", File3)
File3_nono = WgetFile ("File3_lowPref", File3_lowPref)

File4_orig = WgetFile ("File4", File4)
File4_down = WgetFile ("dir/File4", File4)
File4_nono = WgetFile ("File4_lowPref", File4_lowPref)

File5_orig = WgetFile ("File5", File5)
File5_down = WgetFile ("dir/File5", File5)
File5_nono = WgetFile ("File5_lowPref", File5_lowPref)

MetaFile1 = WgetFile ("test1.metalink", MetaXml1)
MetaFile1_down = WgetFile ("newname.metalink", MetaXml1)

MetaFile2 = WgetFile ("test2.metalink", MetaXml2)

WGET_OPTIONS = "--trust-server-names --metalink-over-http --metalink-index=2"
WGET_URLS = [["main.metalink"]]

RequestList = [[
    "HEAD /main.metalink",
    "GET /404",
    "GET /wrong_file",
    "GET /test1.metalink",
    "GET /File1",
    "GET /File2",
    "GET /File4",
Example #4
0
from sys import exit
from test.http_test import HTTPTest
from test.base_test import HTTPS, SKIP_TEST
from misc.wget_file import WgetFile
import os
"""
    This test ensures that Wget can download files from HTTPS Servers
"""
if os.getenv('SSL_TESTS') is None:
    exit(SKIP_TEST)

############# File Definitions ###############################################
File1 = "Would you like some Tea?"
File2 = "With lemon or cream?"

A_File = WgetFile("File1", File1)
B_File = WgetFile("File2", File2)

CAFILE = os.path.abspath(
    os.path.join(os.getenv('srcdir', '.'), 'certs', 'ca-cert.pem'))
CRLFILE = os.path.abspath(
    os.path.join(os.getenv('srcdir', '.'), 'certs', 'server-crl.pem'))
WGET_OPTIONS = "--crl-file " + CRLFILE + " --ca-certificate=" + CAFILE
WGET_URLS = [["File1", "File2"]]

Files = [[A_File, B_File]]

Servers = [HTTPS]

ExpectedReturnCode = 5
Example #5
0
    "RejectHeader"      : {
        "Authorization" : "Basic U2F1cm9uOlRoZUV5ZQ=="
    }
}
File2_rules = {
    "Authentication"    : {
        "Type"          : "Both_inline",
        "User"          : "Sauron",
        "Pass"          : "TheEye"
    },
    "SendHeader"        : {
        "Content-Disposition"  : "Attachment; filename=newfile"
    }
}

A_File = WgetFile ("File1", File1, rules=File1_rules)
B_File = WgetFile ("File2", File2, rules=File2_rules)
C_File = WgetFile ("File3", File3)

WGET_OPTIONS = "--content-disposition --user=Sauron --password=TheEye"
WGET_URLS = [["File1", "File2"]]

Servers = [HTTP]

Files = [[A_File, B_File]]
Existing_Files = [C_File]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [A_File, WgetFile ("newfile", File2), C_File]

################ Pre and Post Test Hooks #####################################
Example #6
0
#!/usr/bin/env python3
from sys import exit
from test.http_test import HTTPTest
from test.base_test import HTTP, HTTPS
from misc.wget_file import WgetFile
"""
    This is a Prototype Test File.
    Ideally this File should be copied and edited to write new tests.
"""
############# File Definitions ###############################################
File2 = "Would you like some Tea?"

File1_rules = {"Response": 301, "SendHeader": {"Location": "/File2.txt"}}

# /File1.txt is only a redirect, and so has no file content.
File1_File = WgetFile("File1.txt", "", rules=File1_rules)
# File1_Retrieved is what will be retrieved for URL /File1.txt.
File1_Retrieved = WgetFile("File1.txt", File2)
File2_File = WgetFile("File2.txt", File2)

WGET_OPTIONS = ""
WGET_URLS = [["File1.txt"]]

Servers = [HTTP]

Files = [[File1_File, File2_File]]
Existing_Files = []

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [File1_Retrieved]
Example #7
0
from test.base_test import HTTP, HTTPS
from misc.wget_file import WgetFile
"""
    Basic test of --recursive.
"""
############# File Definitions ###############################################
File1 = """<html><body>
<a href=\"/a/File2.html\">text</a>
<a href=\"/b/File3.html\">text</a>
</body></html>"""
File2 = "With lemon or cream?"
File3 = "Surely you're joking Mr. Feynman"

File1_rules = {"Response": 301, "SendHeader": {"Location": "/b/File1.html"}}

File1_File = WgetFile("a/File1.html", "", rules=File1_rules)
File1_Redirected = WgetFile("b/File1.html", File1)
File1_Retrieved = WgetFile("a/File1.html", File1)
File2_File = WgetFile("a/File2.html", File2)
File3_File = WgetFile("b/File3.html", File3)

WGET_OPTIONS = "--recursive --no-host-directories --include-directories=a"
WGET_URLS = [["a/File1.html"]]

Servers = [HTTP]

Files = [[File1_Redirected, File1_File, File2_File, File3_File]]
Existing_Files = []

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [File1_Retrieved, File2_File]
from sys import exit
from test.http_test import HTTPTest
from test.base_test import HTTP, HTTPS
from misc.wget_file import WgetFile
"""
    Basic test of --recursive.
"""
############# File Definitions ###############################################
File1 = """<html><body>
<a href=\"/a/File2.html\">text</a>
<a href=\"/b/File3.html\">text</a>
</body></html>"""
File2 = "With lemon or cream?"
File3 = "Surely you're joking Mr. Feynman"

File1_File = WgetFile("a/File1.html", File1)
File2_File = WgetFile("a/File2.html", File2)
File3_File = WgetFile("b/File3.html", File3)

WGET_OPTIONS = "--recursive --no-host-directories"
WGET_URLS = [["a/File1.html"]]

Servers = [HTTP]

Files = [[File1_File, File2_File, File3_File]]
Existing_Files = []

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [File1_File, File2_File, File3_File]
Request_List = [[
    "GET /a/File1.html", "GET /robots.txt", "GET /a/File2.html",
"""
TEST_NAME = "Authentication with Content Disposition"
############# File Definitions ###############################################
File1 = "Need a cookie?"

File1_rules = {
    "Authentication": {
        "Type": "Basic",
        "User": "******",
        "Pass": "******"
    },
    "SendHeader": {
        "Content-Disposition": "Attachment; filename=Arch"
    }
}
A_File = WgetFile("File1", File1, rules=File1_rules)

WGET_OPTIONS = "--user=Pacman --password=Omnomnom --content-disposition"
WGET_URLS = [["File1"]]

Files = [[A_File]]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [WgetFile("Arch", File1)]

################ Pre and Post Test Hooks #####################################
pre_test = {"ServerFiles": Files}
test_options = {"WgetCommands": WGET_OPTIONS, "Urls": WGET_URLS}
post_test = {
    "ExpectedFiles": ExpectedDownloadedFiles,
    "ExpectedRetcode": ExpectedReturnCode
Example #10
0
#!/usr/bin/env python3
from sys import exit
from test.http_test import HTTPTest
from misc.wget_file import WgetFile

"""
    This test ensures that Wget correctly handles responses to HEAD requests
    and does not actually download any data
"""
############# File Definitions ###############################################
File1 = "You shall not pass!"

A_File = WgetFile ("File1", File1)

WGET_OPTIONS = "--method=HEAD"
WGET_URLS = [["File1"]]

Files = [[A_File]]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = []

################ Pre and Post Test Hooks #####################################
pre_test = {
    "ServerFiles"       : Files,
}
test_options = {
    "WgetCommands"      : WGET_OPTIONS,
    "Urls"              : WGET_URLS
}
post_test = {
Example #11
0
#!/usr/bin/env python3
from sys import exit
from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
    Simple test for HTTP POST Requests usiong the --method command
"""
############# File Definitions ###############################################
File1 = """A reader lives a thousand lives before he dies, said Jojen.
The man who never reads lives only one"""

File1_response = """A reader lives a thousand lives before he dies, said Jojen.
The man who never reads lives only one
TestMessage"""

A_File = WgetFile("File1", File1)

WGET_OPTIONS = "--method=post --body-data=TestMessage"
WGET_URLS = [["File1"]]

Files = [[A_File]]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [WgetFile("File1", File1_response)]

################ Pre and Post Test Hooks #####################################
pre_test = {"ServerFiles": Files}
test_options = {"WgetCommands": WGET_OPTIONS, "Urls": WGET_URLS}
post_test = {
    "ExpectedFiles": ExpectedDownloadedFiles,
    "ExpectedRetcode": ExpectedReturnCode
Example #12
0
"""

############# File Definitions ###############################################
bad = "Ouch!"
bad_sha256 = b64encode(hashlib.sha256(
    bad.encode('UTF-8')).digest()).decode('ascii')

LinkHeaders = [
    "<http://{{SRV_HOST}}:{{SRV_PORT}}/wrong_file>; rel=duplicate; pri=1"
]
DigestHeader = "SHA-256=bad_base64,SHA-256={{BAD_HASH}}"

# This will be filled as soon as we know server hostname and port
MetaHTTPRules = {'SendHeader': {}}

MetaHTTP = WgetFile("main.metalink", rules=MetaHTTPRules)

wrong_file = WgetFile("wrong_file", bad)
wrong_file_down = WgetFile("main.metalink", bad)

WGET_OPTIONS = "--metalink-over-http"
WGET_URLS = [["main.metalink"]]

RequestList = [["HEAD /main.metalink", "GET /wrong_file"]]

Files = [[MetaHTTP, wrong_file]]
Existing_Files = []

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [wrong_file_down]
Example #13
0
<body>
	<a href="../b/y.html"></a>
</body>
</html>
"""

error_FileContent = '404 page content'
error_FileRules = {
    'Response': 404,
    'SendHeader': {
        'Content-Length': len(error_FileContent),
        'Content-Type': 'text/plain',
    }
}

a_x_File = WgetFile("a/x.html", a_x_FileContent)
# robots_File = WgetFile ("robots.txt", '')
error_File = WgetFile("b/y.html", error_FileContent, rules=error_FileRules)

B_File = WgetFile("a/x.html", a_x_LocalFileContent)

WGET_OPTIONS = "--no-host-directories -r -l2 --convert-links --content-on-error"
WGET_URLS = [["a/x.html"]]

# Files = [[a_x_File, robots_File, error_File]]

ExpectedReturnCode = 8
# ExpectedDownloadedFiles = [B_File, robots_File, error_File]

################ Pre and Post Test Hooks #####################################
pre_test = {"ServerFiles": Files}
Example #14
0
#!/usr/bin/env python3
from sys import exit
from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
    This test ensures that Wget correctly handles the -O command for output
    filenames.
"""
############# File Definitions ###############################################
File1 = "Test Contents."

A_File = WgetFile("File1", File1)

WGET_OPTIONS = "-O NewFile.txt"
WGET_URLS = [["File1"]]

Files = [[A_File]]
ExistingFiles = [A_File]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [WgetFile("NewFile.txt", File1)]

################ 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(pre_hook=pre_test,
      </verification>
      <resources>
        <url type="http" preference="35">http://{{SRV_HOST}}:{{SRV_PORT}}/wrong_file</url>
        <url type="http" preference="40">http://{{SRV_HOST}}:{{SRV_PORT}}/404</url>
        <url type="http" preference="25">http://{{SRV_HOST}}:{{SRV_PORT}}/File5_lowPref</url>
        <url type="http" preference="30">http://{{SRV_HOST}}:{{SRV_PORT}}/File5</url>
      </resources>
    </file>
  </files>
</metalink>
"""

# This will be filled as soon as we know server hostname and port
MetaHTTPRules = {'SendHeader' : {}}

MetaHTTP = WgetFile ("main.metalink", rules=MetaHTTPRules)
MetaHTTP_down = WgetFile ("newname.metalink", MetaXml)

wrong_file = WgetFile ("wrong_file", bad)

File1_orig = WgetFile ("File1", File1)
File1_down = WgetFile ("dir/File1", File1)
File1_nono = WgetFile ("File1_lowPref", File1_lowPref)

File2_orig = WgetFile ("File2", File2)
File2_down = WgetFile ("dir/File2", File2)
File2_nono = WgetFile ("File2_lowPref", File2_lowPref)

# rejected by libmetalink
File3_orig = WgetFile ("File3", File3)
File3_nono = WgetFile ("File3_lowPref", File3_lowPref)
Example #16
0
"""
This test ensures that Wget keeps reserved characters in URLs in non-UTF-8 charsets.
"""
# This bug only happened with ASCII charset,
# so we need to set LC_ALL="C" in order to reproduce it.
environ["LC_ALL"] = "C"

TEST_NAME = "URLs with reserved characters"
######### File Definitions #########
RequestList = [[
    "HEAD /base.html", "GET /base.html", "GET /robots.txt", "HEAD /a%2Bb.html",
    "GET /a%2Bb.html"
]]
A_File_Name = "base.html"
B_File_Name = "a%2Bb.html"
A_File = WgetFile(A_File_Name, "<a href=\"a%2Bb.html\">")
B_File = WgetFile(B_File_Name, "this is file B")

WGET_OPTIONS = " --spider -r"
WGET_URLS = [[A_File_Name]]

Files = [[A_File, B_File]]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = []

######### Pre and Post Test Hooks #########
pre_test = {"ServerFiles": Files}
test_options = {"WgetCommands": WGET_OPTIONS, "Urls": WGET_URLS}
post_test = {
    "ExpectedFiles": ExpectedDownloadedFiles,
Example #17
0
    </file>
  </files>
</metalink>
"""

LinkHeaders = [
    # This file has the lowest priority, and should go last
    "<http://{{SRV_HOST}}:{{SRV_PORT}}/test1.metalink>; rel=describedby; pri=2; type=\"application/metalink4+xml\"",
    # This file has the highest priority, and should go first
    "<http://{{SRV_HOST}}:{{SRV_PORT}}/test2.metalink>; rel=describedby; pri=1; type=\"application/metalink4+xml\""
]

# This will be filled as soon as we know server hostname and port
MetaHTTPRules = {'SendHeader' : {}}

MetaHTTP = WgetFile ("main.metalink", rules=MetaHTTPRules)

wrong_file = WgetFile ("wrong_file", bad)

File1_orig = WgetFile ("File1", File1)
File1_down = WgetFile ("dir/File1", File1)
File1_nono = WgetFile ("File1_lowPref", File1_lowPref)

File2_orig = WgetFile ("File2", File2)
File2_down = WgetFile ("dir/File2", File2)
File2_nono = WgetFile ("File2_lowPref", File2_lowPref)

# rejected by libmetalink
File3_orig = WgetFile ("File3", File3)
File3_nono = WgetFile ("File3_lowPref", File3_lowPref)
Example #18
0
#!/usr/bin/env python3
from sys import exit
from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
    Test Wget's response when the file requested already exists on disk with
    a filesize greater than or equal to the requested file.
"""
############# File Definitions ###############################################
File1 = "abababababababababababababababababababababababababababababababababab"
File2 = "ababababababababababababababababababab"

A_File = WgetFile("File1", File1)
B_File = WgetFile("File1", File1)

C_File = WgetFile("File2", File1)
D_File = WgetFile("File2", File2)

E_File = WgetFile("File3", File1)

WGET_OPTIONS = "-c"
WGET_URLS = [["File1", "File2", "File3"]]

Files = [[A_File, C_File, E_File]]
Existing_Files = [B_File, D_File]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [A_File, C_File, E_File]

################ Pre and Post Test Hooks #####################################
pre_test = {"ServerFiles": Files, "LocalFiles": Existing_Files}
Example #19
0
    "<http://{{SRV_HOST}}:{{SRV_PORT}}/File1>; pri=1; pref",
    # invalid rel
    "<http://{{SRV_HOST}}:{{SRV_PORT}}/File1>; rel=strange; pri=4",
    # This file should be picked first, because it has the lowest pri among preferred.
    "<http://{{SRV_HOST}}:{{SRV_PORT}}/File1_try1_corrupted>; rel=duplicate; geo=su; pri=4; pref",
    # This file should NOT be picked third due to preferred location set to 'uk'
    "<http://{{SRV_HOST}}:{{SRV_PORT}}/File1_badgeo>; rel =duplicate;pri=5",
    # This file should be picked as third try, and it should succeed
    "<http://{{SRV_HOST}}:{{SRV_PORT}}/File1_try3_ok>; rel=duplicate; pri=5;geo=uk"
]
DigestHeader = "SHA-256={{FILE1_HASH}}"

# This will be filled as soon as we know server hostname and port
MetaFileRules = {'SendHeader': {}}

FileOkServer = WgetFile("File1_try3_ok", File1)
FileBadPref = WgetFile("File1_lowPref", File1_lowPref)
FileBadHash = WgetFile("File1_try1_corrupted", File1_corrupted)
MetaFile = WgetFile("test.meta", rules=MetaFileRules)
# In case of Metalink over HTTP, the local file name is
# derived from the URL suffix.
FileOkLocal = WgetFile("test.meta", File1)
SigFile = WgetFile("Sig.asc", Signature)
FileNoMeta = WgetFile("File2", File2)

WGET_OPTIONS = "--metalink-over-http --preferred-location=uk"
WGET_URLS = [["test.meta", "File2"]]

Files = [[
    FileOkServer, FileBadPref, FileBadHash, MetaFile, SigFile, FileNoMeta
]]
############# File Definitions ###############################################
File1 = """All that is gold does not glitter,
        Not all those who wander are lost;
        The old that is strong does not wither,
        Deep roots are not reached by the frost.
        From the ashes a fire shall be woken,
        A light from the shadows shall spring;
        Renewed shall be blade that was broken,
        The crownless again shall be king."""

File1_rules = {
    "SendHeader": {
        "Content-Disposition": "Attachment; filename=JRR.Tolkein"
    }
}
A_File = WgetFile("LOTR", File1, rules=File1_rules)

WGET_OPTIONS = "--content-disposition"
WGET_URLS = [["LOTR"]]

Files = [[A_File]]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [WgetFile("JRR.Tolkein", File1)]

################ Pre and Post Test Hooks #####################################
pre_test = {"ServerFiles": Files}
test_options = {"WgetCommands": WGET_OPTIONS, "Urls": WGET_URLS}
post_test = {
    "ExpectedFiles": ExpectedDownloadedFiles,
    "ExpectedRetcode": ExpectedReturnCode
Example #21
0
"""
    Simple test for HTTP Conditional-GET Requests using the -N command
"""
TEST_NAME = "HTTP Conditional-GET Requests"
############# File Definitions ###############################################
# Keep same length !
Cont1 = """THIS IS 1 FILE"""
Cont2 = """THIS IS 2 FILE"""
Cont3 = """THIS IS 3 FILE"""
Cont4 = """THIS IS 4 FILE"""

# Local Wget files

# These have same timestamp as remote files
UpToDate_Local_File1 = WgetFile("UpToDateFile1",
                                Cont1,
                                timestamp="1995-01-01 00:00:00")
UpToDate_Local_File2 = WgetFile("UpToDateFile2",
                                Cont1,
                                timestamp="1995-01-01 00:00:00")
UpToDate_Local_File3 = WgetFile("UpToDateFile3",
                                Cont1,
                                timestamp="1995-01-01 00:00:00")

# This is newer than remote (expected same behaviour as for above files)
Newer_Local_File = WgetFile("NewerFile",
                            Cont1,
                            timestamp="1995-02-02 02:02:02")

# This is older than remote - should be clobbered
Outdated_Local_File = WgetFile("UpdatedFile",
Example #22
0
    # we want the current time as an integer,
    # not as a floating point
    curtime = int(time.time())
    max_age = "123456"

    f = open(path, "w")

    f.write("# dummy comment\n")
    f.write(host + "\t" + str(port) + "\t0\t" + str(curtime) + "\t" + max_age +
            "\n")
    f.close()


File_Name = "hw"
File_Content = "Hello, world!"
File = WgetFile(File_Name, File_Content)

Hsts_File_Path = hsts_database_path()

CAFILE = os.path.abspath(
    os.path.join(os.getenv('srcdir', '.'), 'certs', 'ca-cert.pem'))

WGET_OPTIONS = "--hsts-file=" + Hsts_File_Path + " --ca-certificate=" + CAFILE
WGET_URLS = [[File_Name]]

Files = [[File]]
Servers = [HTTPS]
Requests = ["http"]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [File]
Example #23
0
        "Set-Cookie":
        "sess-id=0213; path=/; ExPIRes=Sun, 06 Nov 2001 12:32:43 GMT"
    },
    "ExpectHeader": {
        "Cookie": "new-sess=N; sess-id=0213"
    }
}
File4_rules = {
    "RejectHeader": {
        "Cookie": "sess-id=0213"
    },
    "ExpectHeader": {
        "Cookie": "new-sess=N"
    }
}
A_File = WgetFile("File1", File1, rules=File1_rules)
B_File = WgetFile("File2", File2, rules=File2_rules)
C_File = WgetFile("File3", File3, rules=File3_rules)
D_File = WgetFile("File4", File4, rules=File4_rules)

WGET_OPTIONS = ""
WGET_URLS = [["File1", "File2", "File3", "File4"]]

Files = [[A_File, B_File, C_File, D_File]]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [A_File, B_File, C_File, D_File]

################ Pre and Post Test Hooks #####################################
pre_test = {"ServerFiles": Files}
test_options = {"WgetCommands": WGET_OPTIONS, "Urls": WGET_URLS}
Example #24
0
User = "******"
Password = "******"

File1_rules = {
    "Authentication": {
        "Type": "Basic",
        "User": User,
        "Pass": Password
    }
}
File2_rules = {"ExpectHeader": {"Authorization": "Basic U2F1cm9uOlRoZUV5ZQ=="}}

Netrc = "machine localhost\n\tlogin {0}\n\tpassword {1}".format(User, Password)

A_File = WgetFile("File1", File1, rules=File1_rules)
B_File = WgetFile("File2", File2, rules=File2_rules)
Netrc_File = WgetFile(".netrc", Netrc)

WGET_OPTIONS = "--user={0}".format(User)
WGET_URLS = [["File1", "File2"]]

Files = [[A_File, B_File]]
LocalFiles = [Netrc_File]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [A_File, B_File, Netrc_File]

################ Pre and Post Test Hooks #####################################
pre_test = {"ServerFiles": Files, "LocalFiles": LocalFiles}
test_options = {"WgetCommands": WGET_OPTIONS, "Urls": WGET_URLS}
Example #25
0
<body>
	<a href="../b/y.html"></a>
</body>
</html>
"""

error_FileContent = '404 page content'
error_FileRules = {
    'Response': 404,
    'SendHeader': {
        'Content-Length': len(error_FileContent),
        'Content-Type': 'text/plain',
    }
}

a_x_File = WgetFile("a/x.html", a_x_FileContent)
robots_File = WgetFile("robots.txt", '')
error_File = WgetFile("b/y.html", error_FileContent, rules=error_FileRules)

B_File = WgetFile("a/x.html", a_x_LocalFileContent)

WGET_OPTIONS = "--no-host-directories -r -l2 --convert-links --content-on-error"
WGET_URLS = [["a/x.html"]]

Files = [[a_x_File, robots_File, error_File]]

ExpectedReturnCode = 8
ExpectedDownloadedFiles = [B_File, robots_File, error_File]

################ Pre and Post Test Hooks #####################################
pre_test = {"ServerFiles": Files}
      </verification>
      <resources>
        <url type="http" preference="35">http://{{SRV_HOST}}:{{SRV_PORT}}/wrong_file</url>
        <url type="http" preference="40">http://{{SRV_HOST}}:{{SRV_PORT}}/404</url>
        <url type="http" preference="25">http://{{SRV_HOST}}:{{SRV_PORT}}/File5_lowPref</url>
        <url type="http" preference="30">http://{{SRV_HOST}}:{{SRV_PORT}}/File5</url>
      </resources>
    </file>
  </files>
</metalink>
"""

# This will be filled as soon as we know server hostname and port
MetaHTTPRules = {'SendHeader': {}}

MetaHTTP = WgetFile("main.metalink", rules=MetaHTTPRules)
MetaHTTP_down = WgetFile("newname.metalink", MetaXml)

wrong_file = WgetFile("wrong_file", bad)

File1_orig = WgetFile("File1", File1)
File1_down = WgetFile("dir/File1", File1)
File1_nono = WgetFile("File1_lowPref", File1_lowPref)

File2_orig = WgetFile("File2", File2)
File2_down = WgetFile("dir/File2", File2)
File2_nono = WgetFile("File2_lowPref", File2_lowPref)

# rejected by libmetalink
File3_orig = WgetFile("File3", File3)
File3_nono = WgetFile("File3_lowPref", File3_lowPref)
Example #27
0
from misc.wget_file import WgetFile
"""
    This test ensures that Wget parses the Content-Disposition header
    correctly and creates the appropriate file when the said filename exists.
"""
############# File Definitions ###############################################
File1 = "Teapot"
File2 = "The Teapot Protocol"

# use upper case 'I' to provoke Wget failure with turkish locale
File2_rules = {
    "SendHeader": {
        "Content-DIsposition": "Attachment; FILENAME=HTTP.Teapot"
    }
}
A_File = WgetFile("HTTP.Teapot", File1)
B_File = WgetFile("File2", File2, rules=File2_rules)

WGET_OPTIONS = "--content-disposition"
WGET_URLS = [["File2"]]

Files = [[B_File]]
Existing_Files = [A_File]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [WgetFile("HTTP.Teapot.1", File2), A_File]

################ Pre and Post Test Hooks #####################################
pre_test = {"ServerFiles": Files, "LocalFiles": Existing_Files}
test_options = {"WgetCommands": WGET_OPTIONS, "Urls": WGET_URLS}
post_test = {
Example #28
0
    Also, we ensure that Wget saves the host after a successful auth and
    doesn't wait for a challenge the second time.
"""
############# File Definitions ###############################################
File1 = "I am an invisble man."
File2 = "I too am an invisible man."

File1_rules = {
    "Authentication": {
        "Type": "Basic",
        "User": "******",
        "Pass": "******"
    }
}
File2_rules = {"ExpectHeader": {"Authorization": "Basic U2F1cm9uOlRoZUV5ZQ=="}}
A_File = WgetFile("File1", File1, rules=File1_rules)
B_File = WgetFile("File2", File2, rules=File2_rules)

WGET_OPTIONS = "--user=Sauron --password=TheEye"
WGET_URLS = [["File1", "File2"]]

Files = [[A_File, B_File]]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [A_File, B_File]

################ Pre and Post Test Hooks #####################################
pre_test = {"ServerFiles": Files}
test_options = {"WgetCommands": WGET_OPTIONS, "Urls": WGET_URLS}
post_test = {
    "ExpectedFiles": ExpectedDownloadedFiles,
Example #29
0
  <files>
    <file name="File1">
      <verification>
        <hash type="sha256">{{FILE1_HASH}}</hash>
      </verification>
      <resources>
        <url type="http" preference="40">http://broken.example/File1</url>
        <url type="http" preference="25">http://{{SRV_HOST}}:{{SRV_PORT}}/File1_lowPref</url>
        <url type="http" preference="30">http://{{SRV_HOST}}:{{SRV_PORT}}/File1</url>
      </resources>
    </file>
  </files>
</metalink>
"""

A_File = WgetFile ("File1", File1)
B_File = WgetFile ("File1_lowPref", File1_lowPref)
MetaFile = WgetFile ("test.meta4", MetaXml)

WGET_OPTIONS = "--input-metalink test.meta4"
WGET_URLS = [[]]

Files = [[A_File, B_File]]
Existing_Files = [MetaFile]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [A_File, MetaFile]

################ Pre and Post Test Hooks #####################################
pre_test = {
    "ServerFiles"       : Files,
Example #30
0
def get_redirect(url):
    data = {
        "File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory":
        "File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory/",
        "File%20formats/Images/SVG%2C%20Scalable%20Vector%20Graphics/html%2C%20W3C%20v1.2%20rec%20%28tiny%29/directory":
        "File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory/"
    }
    dest = data.get(url)
    if dest:
        return {"Response": 301, "SendHeader": {"Location": "/%s" % dest}}
    return None


index_url = "File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/index.html"
Index_File = WgetFile(index_url, Index)
Files = (
    [Index_File] +
    [WgetFile(i, File1, rules=get_redirect(i)) for i in (redirected + urls)])

WGET_OPTIONS = "--recursive -e robots=off"

WGET_URLS = [[index_url]]

ExpectedReturnCode = 0

################ Pre and Post Test Hooks #####################################
pre_test = {"ServerFiles": [Files]}
test_options = {"WgetCommands": WGET_OPTIONS, "Urls": WGET_URLS}
post_test = {
    "ExpectedRetcode": ExpectedReturnCode,
#!/usr/bin/env python3
from sys import exit
from test.http_test import HTTPTest
from test.base_test import HTTP
from misc.wget_file import WgetFile
import os
"""
    This test ensures that Wget complains about missing scheme
"""
############# File Definitions ###############################################
A_File = WgetFile("bar", 'Content')

# put the URL into 'options' to avoid prepending scheme/localhost/port
WGET_OPTIONS = "/foo/bar"
WGET_URLS = [[]]

Files = [[A_File]]

ExpectedReturnCode = 1
ExpectedDownloadedFiles = []

################ Pre and Post Test Hooks #####################################
pre_test = {
    "ServerFiles": Files,
}
test_options = {"WgetCommands": WGET_OPTIONS, "Urls": WGET_URLS}
post_test = {
    "ExpectedFiles": ExpectedDownloadedFiles,
    "ExpectedRetcode": ExpectedReturnCode
}