예제 #1
0
    def http_test (self, command_line, expected_retcode):

        pre_test = {
            "ServerFiles"     : self.ServerFiles, # list of WgetFile objects as [[]]
            "LocalFiles"      : self.LocalFiles,  # list of WgetFile objects as []
        }

        test_options = {
            "WgetCommands"    : command_line, # Wget cli
            "Urls"            : [[]],         # Wget urls
        }

        post_test = {
            "ExpectedFiles"   : self.ExpectedFiles, # list of WgetFile objects as []
            "ExpectedRetcode" : expected_retcode,   # Wget return status code
        }

        http_test = HTTPTest (
            pre_hook=pre_test,
            test_params=test_options,
            post_hook=post_test,
        )

        http_test.server_setup()
        # Get and use dynamic server sockname
        srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname ()

        self.set_srv (srv_host, srv_port)

        err = http_test.begin ()

        return err
예제 #2
0
    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,
}

err = HTTPTest(name=TEST_NAME,
               pre_hook=pre_test,
               test_params=test_options,
               post_hook=post_test).begin()

exit(err)
예제 #3
0
        "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,
    "ExpectedRetcode": ExpectedReturnCode
}

err = HTTPTest(pre_hook=pre_test,
               test_params=test_options,
               post_hook=post_test).begin()

exit(err)
ExpectedReturnCode = 0
ExpectedDownloadedFiles = [
    MetaHTTP_down, File1_down, File2_down, File4_down, File5_down
]

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

http_test = HTTPTest(pre_hook=pre_test,
                     test_params=test_options,
                     post_hook=post_test)

http_test.server_setup()
### Get and use dynamic server sockname
srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname()

MetaXml = MetaXml.replace('{{FILE1_HASH}}', File1_sha256)
MetaXml = MetaXml.replace('{{FILE2_HASH}}', File2_sha256)
MetaXml = MetaXml.replace('{{FILE3_HASH}}', File3_sha256)
MetaXml = MetaXml.replace('{{FILE4_HASH}}', File4_sha256)
MetaXml = MetaXml.replace('{{FILE5_HASH}}', File5_sha256)
MetaXml = MetaXml.replace('{{SRV_HOST}}', srv_host)
MetaXml = MetaXml.replace('{{SRV_PORT}}', str(srv_port))
MetaHTTP_down.content = MetaXml
예제 #5
0
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

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

err = HTTPTest(pre_hook=pre_test,
               test_params=test_options,
               post_hook=post_test,
               protocols=Servers).begin()

exit(err)
    "ServerFiles"       : Files,
    "LocalFiles"        : Existing_Files
}
test_options = {
    "WgetCommands"      : WGET_OPTIONS,
    "Urls"              : WGET_URLS
}
post_test = {
    "ExpectedFiles"     : ExpectedDownloadedFiles,
    "ExpectedRetcode"   : ExpectedReturnCode,
    "FilesCrawled"      : RequestList
}

http_test = HTTPTest (
                pre_hook=pre_test,
                test_params=test_options,
                post_hook=post_test
)

http_test.server_setup()
### Get and use dynamic server sockname
srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname ()

MetaXml1 = MetaXml1.replace('{{FILE1_HASH}}', File1_sha256)
MetaXml1 = MetaXml1.replace('{{FILE2_HASH}}', File2_sha256)
MetaXml1 = MetaXml1.replace('{{FILE3_HASH}}', File3_sha256)
MetaXml1 = MetaXml1.replace('{{FILE4_HASH}}', File4_sha256)
MetaXml1 = MetaXml1.replace('{{FILE5_HASH}}', File5_sha256)
MetaXml1 = MetaXml1.replace('{{SRV_HOST}}', srv_host)
MetaXml1 = MetaXml1.replace('{{SRV_PORT}}', str (srv_port))
MetaFile1.content = MetaXml1
예제 #7
0
Files = [[File]]
Servers = [HTTPS]
Requests = ["http"]

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [File]

pre_test = {"ServerFiles": Files, "Domains": ["localhost"]}
post_test = {
    "ExpectedFiles": ExpectedDownloadedFiles,
    "ExpectedRetCode": ExpectedReturnCode,
}
test_options = {"WgetCommands": WGET_OPTIONS, "Urls": WGET_URLS}

test = HTTPTest(pre_hook=pre_test,
                post_hook=post_test,
                test_params=test_options,
                protocols=Servers,
                req_protocols=Requests)

# start the web server and create the temporary HSTS database
test.setup()
create_hsts_database(Hsts_File_Path, 'localhost', test.port)

err = test.begin()

# remove the temporary HSTS database
os.unlink(hsts_database_path())
exit(err)
예제 #8
0
pre_test = {
    "ServerFiles"       : Files,
    "LocalFiles"        : Existing_Files
}
test_options = {
    "WgetCommands"      : WGET_OPTIONS,
    "Urls"              : WGET_URLS
}
post_test = {
    "ExpectedFiles"     : ExpectedDownloadedFiles,
    "ExpectedRetcode"   : ExpectedReturnCode
}

http_test = HTTPTest (
                name=TEST_NAME,
                pre_hook=pre_test,
                test_params=test_options,
                post_hook=post_test,
)

http_test.server_setup()
### Get and use dynamic server sockname
srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname ()

MetaXml = re.sub (r'{{FILE1_HASH}}', File1_sha256, MetaXml)
MetaXml = re.sub (r'{{SRV_HOST}}', srv_host, MetaXml)
MetaXml = re.sub (r'{{SRV_PORT}}', str (srv_port), MetaXml)
MetaFile.content = MetaXml

err = http_test.begin ()

exit (err)
예제 #9
0
post_test_not_working = {
    "ExpectedRetcode"   : ExpectedReturnCodeNotWorking
}

# Case #1:
# - Requested domain matches exactly the domain definition in no_proxy.
# - Domain definition in no_proxy is NOT dot-prefixed
# Expected result: proxy settings don't apply and files are downloaded.
pre_case_1 = {
    "ServerFiles"       : Files,
    "Domains"           : ["working1.localhost"]
}

err_case_1 = HTTPTest (
    pre_hook=pre_case_1,
    test_params=test_options,
    post_hook=post_test_working,
    protocols=Servers
).begin ()

# Case #2:
# - Requested domain is sub-domain of a domain definition in no_proxy.
# - Domain definition in no_proxy is NOT dot-prefixed
# Expected result: proxy settings don't apply and files are downloaded.
pre_case_2 = {
    "ServerFiles"       : Files,
    "Domains"           : ["www.working1.localhost"]
}

err_case_2 = HTTPTest (
    pre_hook=pre_case_2,
    test_params=test_options,
예제 #10
0
파일: Test-hsts.py 프로젝트: AOSC-Dev/wget
        "ServerFiles"   : Files,
        "Domains"       : ["localhost"]
}
post_test = {
        "ExpectedFiles"     : ExpectedDownloadedFiles,
        "ExpectedRetCode"   : ExpectedReturnCode,
}
test_options = {
        "WgetCommands"  : WGET_OPTIONS,
        "Urls"          : WGET_URLS
}

test = HTTPTest(
        name = TEST_NAME,
        pre_hook = pre_test,
        post_hook = post_test,
        test_params = test_options,
        protocols = Servers,
        req_protocols = Requests
)

# start the web server and create the temporary HSTS database
test.setup()
create_hsts_database(Hsts_File_Path, 'localhost', test.port)

err = test.begin()

# remove the temporary HSTS database
os.unlink(hsts_database_path())
exit(err)