Debian Codegraph @

testenv/Test-cookie-401.py

raw
1 #!/usr/bin/env python3
2 from sys import exit
3 from test.http_test import HTTPTest
4 from misc.wget_file import WgetFile
5
6 """
7 This test ensures that Wget stores the cookie even in the event of a
8 401 Unauthorized Response
9 """
10 ############# File Definitions ###############################################
11 File1 = """All happy families are alike;
12 Each unhappy family is unhappy in its own way"""
13 File2 = "Anyone for chocochip cookies?"
14
15 File1_rules = {
16 "SendHeader" : {
17 "Set-Cookie" : "sess-id=0213; path=/"
18 },
19 "Response" : 401
20 }
21 File2_rules = {
22 "ExpectHeader" : {
23 "Cookie" : "sess-id=0213"
24 },
25 }
26
27 A_File = WgetFile ("File1", File1, rules=File1_rules)
28 B_File = WgetFile ("File2", File2, rules=File2_rules)
29
30 WGET_OPTIONS = ""
31 WGET_URLS = [["File1", "File2"]]
32
33 Files = [[A_File, B_File]]
34
35 ExpectedReturnCode = 6
36 ExpectedDownloadedFiles = [B_File]
37
38 ################ Pre and Post Test Hooks #####################################
39 pre_test = {
40 "ServerFiles" : Files
41 }
42 test_options = {
43 "WgetCommands" : WGET_OPTIONS,
44 "Urls" : WGET_URLS
45 }
46 post_test = {
47 "ExpectedFiles" : ExpectedDownloadedFiles,
48 "ExpectedRetcode" : ExpectedReturnCode
49 }
50
51 err = HTTPTest (
52 pre_hook=pre_test,
53 test_params=test_options,
54 post_hook=post_test
55 ).begin ()
56
57 exit (err)