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 returns the correct exit code when Basic
8    authentcation failes due to a username/password error.
9"""
10TEST_NAME = "Basic Authentication Failure"
11############# File Definitions ###############################################
12File1 = "I am an invisble man."
13
14File1_rules = {
15    "Authentication"    : {
16        "Type"          : "Basic",
17        "User"          : "Sauron",
18        "Pass"          : "TheEye"
19    }
20}
21A_File = WgetFile ("File1", File1, rules=File1_rules)
22
23WGET_OPTIONS = "--user=Sauron --password=Eye"
24WGET_URLS = [["File1"]]
25
26Files = [[A_File]]
27
28ExpectedReturnCode = 6
29ExpectedDownloadedFiles = []
30
31################ Pre and Post Test Hooks #####################################
32pre_test = {
33    "ServerFiles"       : Files
34}
35test_options = {
36    "WgetCommands"      : WGET_OPTIONS,
37    "Urls"              : WGET_URLS
38}
39post_test = {
40    "ExpectedFiles"     : ExpectedDownloadedFiles,
41    "ExpectedRetcode"   : ExpectedReturnCode
42}
43
44err = HTTPTest (
45                name=TEST_NAME,
46                pre_hook=pre_test,
47                test_params=test_options,
48                post_hook=post_test
49).begin ()
50
51exit (err)
52