Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_build_kerberos_with_kwargs(self):
transport = TransportHTTP("", auth="kerberos", username="user",
ssl=False, password="pass",
negotiate_delegate=True,
negotiate_hostname_override="host",
negotiate_send_cbt=False,
negotiate_service="HTTP")
session = transport._build_session()
assert isinstance(transport.encryption, WinRMEncryption)
assert transport.encryption.protocol == WinRMEncryption.SPNEGO
assert isinstance(session.auth, HTTPNegotiateAuth)
assert session.auth.auth_provider == "kerberos"
assert session.auth.delegate is True
assert session.auth.hostname_override == "host"
assert session.auth.password == "pass"
assert session.auth.send_cbt is False
assert session.auth.service == 'HTTP'
assert session.auth.username == "user"
assert session.auth.wrap_required is True
def test_build_credssp_no_kwargs(self):
credssp = pytest.importorskip("requests_credssp")
transport = TransportHTTP("", username="user", password="pass",
auth="credssp")
session = transport._build_session()
assert isinstance(transport.encryption, WinRMEncryption)
assert transport.encryption.protocol == WinRMEncryption.CREDSSP
assert isinstance(session.auth, credssp.HttpCredSSPAuth)
assert session.auth.auth_mechanism == 'auto'
assert session.auth.disable_tlsv1_2 is False
assert session.auth.minimum_version == 2
assert session.auth.password == 'pass'
assert session.auth.username == 'user'
def test_build_credssp_with_kwargs(self):
credssp = pytest.importorskip("requests_credssp")
transport = _TransportHTTP("", username="user", password="pass",
auth="credssp",
credssp_auth_mechanism="kerberos",
credssp_disable_tlsv1_2=True,
credssp_minimum_version=5)
session = transport._build_session()
assert isinstance(transport.encryption, WinRMEncryption)
assert transport.encryption.protocol == WinRMEncryption.CREDSSP
assert isinstance(session.auth, credssp.HttpCredSSPAuth)
assert session.auth.auth_mechanism == 'kerberos'
assert session.auth.disable_tlsv1_2 is True
assert session.auth.minimum_version == 5
assert session.auth.password == 'pass'
assert session.auth.username == 'user'
def test_build_credssp_no_kwargs(self):
credssp = pytest.importorskip("requests_credssp")
transport = _TransportHTTP("", username="user", password="pass",
auth="credssp")
session = transport._build_session()
assert isinstance(transport.encryption, WinRMEncryption)
assert transport.encryption.protocol == WinRMEncryption.CREDSSP
assert isinstance(session.auth, credssp.HttpCredSSPAuth)
assert session.auth.auth_mechanism == 'auto'
assert session.auth.disable_tlsv1_2 is False
assert session.auth.minimum_version == 2
assert session.auth.password == 'pass'
assert session.auth.username == 'user'
if not HAS_CREDSSP:
raise ImportError("Cannot use CredSSP auth as requests-credssp is "
"not installed: %s" % str(CREDSSP_IMP_ERR))
if self.username is None:
raise ValueError("For credssp auth, the username must be "
"specified")
if self.password is None:
raise ValueError("For credssp auth, the password must be "
"specified")
kwargs = self._get_auth_kwargs('credssp')
session.auth = HttpCredSSPAuth(username=self.username,
password=self.password,
**kwargs)
self.encryption = WinRMEncryption(
session.auth, WinRMEncryption.CREDSSP
)
def _build_auth_negotiate(self, session, auth_provider="auto"):
kwargs = self._get_auth_kwargs('negotiate')
session.auth = HTTPNegotiateAuth(username=self.username,
password=self.password,
auth_provider=auth_provider,
wrap_required=self.wrap_required,
**kwargs)
self.encryption = WinRMEncryption(
session.auth, WinRMEncryption.SPNEGO
)
if not HAS_CREDSSP:
raise ImportError("Cannot use CredSSP auth as requests-credssp is "
"not installed: %s" % str(CREDSSP_IMP_ERR))
if self.username is None:
raise ValueError("For credssp auth, the username must be "
"specified")
if self.password is None:
raise ValueError("For credssp auth, the password must be "
"specified")
kwargs = self._get_auth_kwargs('credssp')
session.auth = HttpCredSSPAuth(username=self.username,
password=self.password,
**kwargs)
self.encryption = WinRMEncryption(
session.auth, WinRMEncryption.CREDSSP
)
def _build_auth_negotiate(self, session, auth_provider="auto"):
kwargs = self._get_auth_kwargs('negotiate')
session.auth = HTTPNegotiateAuth(username=self.username,
password=self.password,
auth_provider=auth_provider,
wrap_required=self.wrap_required,
**kwargs)
self.encryption = WinRMEncryption(
session.auth, WinRMEncryption.SPNEGO
)
def _build_auth_negotiate(self, session, auth_provider="auto"):
kwargs = self._get_auth_kwargs('negotiate')
session.auth = HTTPNegotiateAuth(username=self.username,
password=self.password,
auth_provider=auth_provider,
wrap_required=self.wrap_required,
**kwargs)
self.encryption = WinRMEncryption(
session.auth, WinRMEncryption.SPNEGO
)