requests_kerberos.OPTIONAL

Here are the examples of the python api requests_kerberos.OPTIONAL taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

Example 1

Project: requests-kerberos Source File: test_requests_kerberos.py
    def test_handle_response_200_mutual_auth_optional_hard_failure(self):
        with patch(kerberos_module_name+'.authGSSClientStep', clientStep_error):

            response_ok = requests.Response()
            response_ok.url = "http://www.example.org/"
            response_ok.status_code = 200
            response_ok.headers = {
                'www-authenticate': 'negotiate servertoken',
                'authorization': 'Negotiate GSSRESPONSE'}

            auth = requests_kerberos.HTTPKerberosAuth(
                requests_kerberos.OPTIONAL)
            auth.context = {"www.example.org": "CTX"}

            self.assertRaises(requests_kerberos.MutualAuthenticationError,
                              auth.handle_response,
                              response_ok)

            clientStep_error.assert_called_with("CTX", "servertoken")

Example 2

Project: requests-kerberos Source File: test_requests_kerberos.py
    def test_handle_response_200_mutual_auth_optional_soft_failure(self):
        with patch(kerberos_module_name+'.authGSSClientStep', clientStep_error):

            response_ok = requests.Response()
            response_ok.url = "http://www.example.org/"
            response_ok.status_code = 200

            auth = requests_kerberos.HTTPKerberosAuth(
                requests_kerberos.OPTIONAL)
            auth.context = {"www.example.org": "CTX"}

            r = auth.handle_response(response_ok)

            self.assertEqual(r, response_ok)

            self.assertFalse(clientStep_error.called)

Example 3

Project: keystoneauth Source File: __init__.py
def _requests_auth():
    # NOTE(jamielennox): request_kerberos.OPTIONAL allows the plugin to accept
    # unencrypted error messages where we can't verify the origin of the error
    # because we aren't authenticated.
    return requests_kerberos.HTTPKerberosAuth(
        mutual_authentication=requests_kerberos.OPTIONAL)

Example 4

Project: requests-kerberos Source File: test_requests_kerberos.py
    def test_handle_response_500_mutual_auth_optional_failure(self):
        with patch(kerberos_module_name+'.authGSSClientStep', clientStep_error):

            response_500 = requests.Response()
            response_500.url = "http://www.example.org/"
            response_500.status_code = 500
            response_500.headers = {}
            response_500.request = "REQUEST"
            response_500.connection = "CONNECTION"
            response_500._content = "CONTENT"
            response_500.encoding = "ENCODING"
            response_500.raw = "RAW"
            response_500.cookies = "COOKIES"

            auth = requests_kerberos.HTTPKerberosAuth(
                requests_kerberos.OPTIONAL)
            auth.context = {"www.example.org": "CTX"}

            r = auth.handle_response(response_500)

            self.assertEqual(r, response_500)

            self.assertFalse(clientStep_error.called)