summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2023-05-22 11:56:00 -0400
committerJeff Forcier <jeff@bitprophet.org>2023-05-22 12:22:05 -0400
commit58652fce5328b52c4a2118ffe851acddc8b35eb3 (patch)
tree9f0374a94a08b157aeb8a543d29656c4b2342c7d
parentd5e3d1b9694522e49bb2c1e131deaa302626be11 (diff)
Test AuthResult
-rw-r--r--tests/auth.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auth.py b/tests/auth.py
index 4c901c75..bd81578a 100644
--- a/tests/auth.py
+++ b/tests/auth.py
@@ -11,7 +11,9 @@ from pytest import raises
from paramiko import (
AgentKey,
AuthenticationException,
+ AuthResult,
AuthSource,
+ AuthStrategy,
BadAuthenticationType,
DSSKey,
InMemoryPrivateKey,
@@ -23,6 +25,7 @@ from paramiko import (
RSAKey,
SSHException,
ServiceRequestingTransport,
+ SourceResult,
)
from ._util import (
@@ -450,5 +453,44 @@ class AuthSource_:
)
+class AuthResult_:
+ def setup_method(self):
+ self.strat = AuthStrategy(None)
+
+ def acts_like_list_with_strategy_attribute(self):
+ with raises(TypeError):
+ AuthResult()
+ # kwarg works by itself
+ AuthResult(strategy=self.strat)
+ # or can be given as posarg w/ regular list() args after
+ result = AuthResult(self.strat, [1, 2, 3])
+ assert result.strategy is self.strat
+ assert result == [1, 2, 3]
+ assert isinstance(result, list)
+
+ def repr_is_list_repr_untouched(self):
+ result = AuthResult(self.strat, [1, 2, 3])
+ assert repr(result) == "[1, 2, 3]"
+
+ class dunder_str:
+ def is_multiline_display_of_sourceresult_tuples(self):
+ result = AuthResult(self.strat)
+ result.append(SourceResult("foo", "bar"))
+ result.append(SourceResult("biz", "baz"))
+ assert str(result) == "foo -> bar\nbiz -> baz"
+
+ def shows_str_not_repr_of_auth_source_and_result(self):
+ result = AuthResult(self.strat)
+ result.append(
+ SourceResult(NoneAuth("foo"), ["password", "pubkey"])
+ )
+ assert str(result) == "NoneAuth() -> ['password', 'pubkey']"
+
+ def empty_list_result_values_show_success_string(self):
+ result = AuthResult(self.strat)
+ result.append(SourceResult(NoneAuth("foo"), []))
+ assert str(result) == "NoneAuth() -> success"
+
+
class AuthStrategy_:
pass