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, when the
8    --auth-no-challenge command is used.
9"""
10TEST_NAME = "Auth No Challenge Command"
11############# File Definitions ###############################################
12File1 = "Need a cookie?"
13
14File1_rules = {
15    "Authentication"    : {
16        "Type"          : "Basic",
17        "User"          : "Pacman",
18        "Pass"          : "Omnomnom"
19    },
20    "ExpectHeader"      : {
21        "Authorization" : "Basic UGFjbWFuOk9tbm9tbm9t"
22    }
23}
24A_File = WgetFile ("File1", File1, rules=File1_rules)
25
26WGET_OPTIONS = "--auth-no-challenge --user=Pacman --password=Omnomnom"
27WGET_URLS = [["File1"]]
28
29Files = [[A_File]]
30
31ExpectedReturnCode = 0
32ExpectedDownloadedFiles = [A_File]
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