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 parses the Content-Disposition header 8 correctly and creates the appropriate file when the said filename exists. 9""" 10TEST_NAME = "Content Disposition Clobber" 11############# File Definitions ############################################### 12File1 = "Teapot" 13File2 = "The Teapot Protocol" 14 15File2_rules = { 16 "SendHeader" : { 17 "Content-Disposition" : "Attachment; filename=HTTP.Teapot" 18 } 19} 20A_File = WgetFile ("HTTP.Teapot", File1) 21B_File = WgetFile ("File2", File2, rules=File2_rules) 22 23WGET_OPTIONS = "--content-disposition" 24WGET_URLS = [["File2"]] 25 26Files = [[B_File]] 27Existing_Files = [A_File] 28 29ExpectedReturnCode = 0 30ExpectedDownloadedFiles = [WgetFile ("HTTP.Teapot.1", File2), A_File] 31 32################ Pre and Post Test Hooks ##################################### 33pre_test = { 34 "ServerFiles" : Files, 35 "LocalFiles" : Existing_Files 36} 37test_options = { 38 "WgetCommands" : WGET_OPTIONS, 39 "Urls" : WGET_URLS 40} 41post_test = { 42 "ExpectedFiles" : ExpectedDownloadedFiles, 43 "ExpectedRetcode" : ExpectedReturnCode 44} 45 46err = HTTPTest ( 47 name=TEST_NAME, 48 pre_hook=pre_test, 49 test_params=test_options, 50 post_hook=post_test 51).begin () 52 53exit (err) 54