예제 #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
    "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

MetaHTTP.content = MetaXml

MetaHTTPRules["SendHeader"] = {
    'Content-Type': 'application/metalink4+xml',
    'Content-Disposition': 'filename="newname.metalink"'
}

err = http_test.begin()

exit(err)
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
MetaFile1_down.content = MetaXml1

MetaXml2 = MetaXml2.replace('{{BAD_HASH}}', bad_sha256)
MetaXml2 = MetaXml2.replace('{{SRV_HOST}}', srv_host)
MetaXml2 = MetaXml2.replace('{{SRV_PORT}}', str (srv_port))
MetaFile2.content = MetaXml2

# Helper function for hostname, port and digest substitution
def SubstituteServerInfo (text, host, port):
    text = text.replace('{{SRV_HOST}}', host)
    text = text.replace('{{SRV_PORT}}', str (port))
    return text

MetaHTTPRules["SendHeader"] = {
        'Link': [ SubstituteServerInfo (LinkHeader, srv_host, srv_port)
                    for LinkHeader in LinkHeaders ]
}

err = http_test.begin ()

exit (err)
예제 #4
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)
예제 #5
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)