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 Wget's Basic Authorization Negotiation. 8 Also, we ensure that Wget saves the host after a successfull auth and 9 doesn't wait for a challenge the second time. 10""" 11TEST_NAME = "Basic Authorization" 12############# File Definitions ############################################### 13File1 = "I am an invisble man." 14File2 = "I too am an invisible man." 15 16File1_rules = { 17 "Authentication" : { 18 "Type" : "Basic", 19 "User" : "Sauron", 20 "Pass" : "TheEye" 21 } 22} 23File2_rules = { 24 "ExpectHeader" : { 25 "Authorization" : "Basic U2F1cm9uOlRoZUV5ZQ==" 26 } 27} 28A_File = WgetFile ("File1", File1, rules=File1_rules) 29B_File = WgetFile ("File2", File2, rules=File2_rules) 30 31WGET_OPTIONS = "--user=Sauron --password=TheEye" 32WGET_URLS = [["File1", "File2"]] 33 34Files = [[A_File, B_File]] 35 36ExpectedReturnCode = 0 37ExpectedDownloadedFiles = [A_File, B_File] 38 39################ Pre and Post Test Hooks ##################################### 40pre_test = { 41 "ServerFiles" : Files 42} 43test_options = { 44 "WgetCommands" : WGET_OPTIONS, 45 "Urls" : WGET_URLS 46} 47post_test = { 48 "ExpectedFiles" : ExpectedDownloadedFiles, 49 "ExpectedRetcode" : ExpectedReturnCode 50} 51 52err = HTTPTest ( 53 name=TEST_NAME, 54 pre_hook=pre_test, 55 test_params=test_options, 56 post_hook=post_test 57).begin () 58 59exit (err) 60