1#!/usr/bin/env python3
2from sys import exit
3from test.http_test import HTTPTest
4from misc.wget_file import WgetFile
5
6"""
7    This test ensures that Wget handles Content-Disposition correctly when
8    coupled with Authentication
9"""
10TEST_NAME = "Authentication with Content Disposition"
11############# File Definitions ###############################################
12File1 = "Need a cookie?"
13
14File1_rules = {
15    "Authentication"    : {
16        "Type"          : "Basic",
17        "User"          : "Pacman",
18        "Pass"          : "Omnomnom"
19    },
20    "SendHeader"        : {
21        "Content-Disposition" : "Attachment; filename=Arch"
22    }
23}
24A_File = WgetFile ("File1", File1, rules=File1_rules)
25
26WGET_OPTIONS = "--user=Pacman --password=Omnomnom --content-disposition"
27WGET_URLS = [["File1"]]
28
29Files = [[A_File]]
30
31ExpectedReturnCode = 0
32ExpectedDownloadedFiles = [WgetFile ("Arch", File1)]
33
34################ Pre and Post Test Hooks #####################################
35pre_test = {
36    "ServerFiles"       : Files
37}
38test_options = {
39    "WgetCommands"      : WGET_OPTIONS,
40    "Urls"              : WGET_URLS
41}
42post_test = {
43    "ExpectedFiles"     : ExpectedDownloadedFiles,
44    "ExpectedRetcode"   : ExpectedReturnCode
45}
46
47err = HTTPTest (
48                name=TEST_NAME,
49                pre_hook=pre_test,
50                test_params=test_options,
51                post_hook=post_test
52).begin ()
53
54exit (err)
55