summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2023-05-22 12:06:49 -0400
committerJeff Forcier <jeff@bitprophet.org>2023-05-22 12:22:05 -0400
commit6937139bb4741d9e363b5e416018439ba2a43e45 (patch)
tree747f686ffec438d2f7776dba9fc187dce29a41e2
parent58652fce5328b52c4a2118ffe851acddc8b35eb3 (diff)
Test AuthFailure
-rw-r--r--paramiko/__init__.py1
-rw-r--r--tests/auth.py19
-rw-r--r--tests/test_util.py1
3 files changed, 21 insertions, 0 deletions
diff --git a/paramiko/__init__.py b/paramiko/__init__.py
index aa1463e7..476062ef 100644
--- a/paramiko/__init__.py
+++ b/paramiko/__init__.py
@@ -33,6 +33,7 @@ from paramiko.client import (
)
from paramiko.auth_handler import AuthHandler
from paramiko.auth_strategy import (
+ AuthFailure,
AuthStrategy,
AuthResult,
AuthSource,
diff --git a/tests/auth.py b/tests/auth.py
index bd81578a..4ede3240 100644
--- a/tests/auth.py
+++ b/tests/auth.py
@@ -11,6 +11,7 @@ from pytest import raises
from paramiko import (
AgentKey,
AuthenticationException,
+ AuthFailure,
AuthResult,
AuthSource,
AuthStrategy,
@@ -492,5 +493,23 @@ class AuthResult_:
assert str(result) == "NoneAuth() -> success"
+class AuthFailure_:
+ def is_an_AuthenticationException(self):
+ assert isinstance(AuthFailure(None), AuthenticationException)
+
+ def init_requires_result(self):
+ with raises(TypeError):
+ AuthFailure()
+ result = AuthResult(None)
+ fail = AuthFailure(result=result)
+ assert fail.result is result
+
+ def str_is_newline_plus_result_str(self):
+ result = AuthResult(None)
+ result.append(SourceResult(NoneAuth("foo"), Exception("onoz")))
+ fail = AuthFailure(result)
+ assert str(fail) == "\nNoneAuth() -> onoz"
+
+
class AuthStrategy_:
pass
diff --git a/tests/test_util.py b/tests/test_util.py
index 060e6249..a2a8224e 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -49,6 +49,7 @@ class UtilTest(unittest.TestCase):
"Agent",
"AgentKey",
"AuthenticationException",
+ "AuthFailure",
"AuthHandler",
"AuthResult",
"AuthSource",