Add option to not send a Negotiate headers
[mod_auth_gssapi.git] / tests / t_basic_k5_fail_second.py
1 #!/usr/bin/python
2 # Copyright (C) 2015 - mod_auth_gssapi contributors, see COPYING for license.
3
4 import os
5 import requests
6 from requests.auth import HTTPBasicAuth
7
8
9 if __name__ == '__main__':
10     s = requests.Session()
11
12     url = 'http://%s:%s@%s/basic_auth_krb5/' % (os.environ['MAG_USER_NAME'],
13                                                 os.environ['MAG_USER_PASSWORD'],
14                                                 os.environ['NSS_WRAPPER_HOSTNAME'])
15     r = s.get(url)
16     if r.status_code != 200:
17         raise ValueError('Basic Auth: Failed Authentication')
18
19     url = 'http://%s:%s@%s/basic_auth_krb5/' % (os.environ['MAG_USER_NAME_2'],
20                                                 os.environ['MAG_USER_PASSWORD'],
21                                                 os.environ['NSS_WRAPPER_HOSTNAME'])
22     r = s.get(url)
23     if r.status_code == 200:
24         raise ValueError('Basic Auth: Got Success while expecting Error')
25
26     url = 'http://%s:%s@%s/basic_auth_krb5/' % (os.environ['MAG_USER_NAME_2'],
27                                                 os.environ['MAG_USER_PASSWORD_2'],
28                                                 os.environ['NSS_WRAPPER_HOSTNAME'])
29     r = s.get(url)
30     if r.status_code != 200:
31         raise ValueError('Basic Auth: Failed Authentication')
32
33     url = 'http://%s/basic_auth_krb5/' % os.environ['NSS_WRAPPER_HOSTNAME']
34     r = s.get(url)
35     if r.status_code == 200:
36         raise ValueError('Basic Auth: Got Success while expecting Error')