Exemplo n.º 1
0
    def test_history_is_preserved(self):
        for auth_type in self.auth_types:
            res = httpx.get(
                url=self.test_server_url + auth_type,
                auth=httpx_ntlm.HttpNtlmAuth(self.test_server_username,
                                             self.test_server_password),
            )

            self.assertEqual(len(res.history), 2)
Exemplo n.º 2
0
def send_request(url, username, password):
    """
    Sends a request to the url with the credentials specified. Returns the final response
    """
    session = httpx.Client(auth=httpx_ntlm.HttpNtlmAuth(username, password),
                           verify=False)
    response = session.get(url)

    return response
Exemplo n.º 3
0
    def test_httpx_ntlm(self):
        for auth_type in self.auth_types:
            res = httpx.get(
                url=self.test_server_url + auth_type,
                auth=httpx_ntlm.HttpNtlmAuth(self.test_server_username,
                                             self.test_server_password),
            )

            self.assertEqual(res.status_code,
                             200,
                             msg="auth_type " + auth_type)
Exemplo n.º 4
0
    def test_username_parse_no_domain(self):
        test_user = "******"
        expected_domain = ""
        expected_user = "******"

        context = httpx_ntlm.HttpNtlmAuth(test_user, "pass")

        actual_domain = context.domain
        actual_user = context.username

        assert actual_domain == expected_domain
        assert actual_user == expected_user
Exemplo n.º 5
0
    def test_username_parse_backslash(self):
        test_user = "******"
        expected_domain = "DOMAIN"
        expected_user = "******"

        context = httpx_ntlm.HttpNtlmAuth(test_user, "pass")

        actual_domain = context.domain
        actual_user = context.username

        assert actual_domain == expected_domain
        assert actual_user == expected_user
Exemplo n.º 6
0
    def test_username_parse_at(self):
        test_user = "******"
        # UPN format should not be split, since "stuff after @" not always == domain
        # (eg, email address with alt UPN suffix)
        expected_domain = ""
        expected_user = "******"

        context = httpx_ntlm.HttpNtlmAuth(test_user, "pass")

        actual_domain = context.domain
        actual_user = context.username

        assert actual_domain == expected_domain
        assert actual_user == expected_user