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"""
10############# File Definitions ###############################################
11File1 = "Need a cookie?"
12
13File1_rules = {
14    "Authentication"    : {
15        "Type"          : "Basic",
16        "User"          : "Pacman",
17        "Pass"          : "Omnomnom"
18    },
19    "ExpectHeader"      : {
20        "Authorization" : "Basic UGFjbWFuOk9tbm9tbm9t"
21    }
22}
23A_File = WgetFile ("File1", File1, rules=File1_rules)
24
25WGET_OPTIONS = "--auth-no-challenge --user=Pacman --password=Omnomnom"
26WGET_URLS = [["File1"]]
27
28Files = [[A_File]]
29
30ExpectedReturnCode = 0
31ExpectedDownloadedFiles = [A_File]
32
33################ Pre and Post Test Hooks #####################################
34pre_test = {
35    "ServerFiles"       : 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                pre_hook=pre_test,
48                test_params=test_options,
49                post_hook=post_test
50).begin ()
51
52exit (err)
53