Agent: Fix identity logic in AggregatingCredentialsStore
This commit is contained in:
parent
9edfe6979b
commit
7c920cced3
|
@ -26,9 +26,11 @@ class AggregatingCredentialsStore(ICredentialsStore):
|
|||
|
||||
def add_credentials(self, credentials_to_add: Iterable[Credentials]):
|
||||
for credentials in credentials_to_add:
|
||||
self._stored_credentials.setdefault("exploit_user_list", set()).add(
|
||||
credentials.identity.username
|
||||
)
|
||||
identity = credentials.identity
|
||||
if identity and identity.credential_type is CredentialComponentType.USERNAME:
|
||||
self._stored_credentials.setdefault("exploit_user_list", set()).add(
|
||||
identity.username
|
||||
)
|
||||
|
||||
secret = credentials.secret
|
||||
|
||||
|
|
|
@ -38,6 +38,10 @@ TEST_CREDENTIALS = [
|
|||
identity=Username("user3"),
|
||||
secret=SSHKeypair(public_key="some_public_key_1", private_key="some_private_key_1"),
|
||||
),
|
||||
Credentials(
|
||||
identity=None,
|
||||
secret=Password("super_secret"),
|
||||
),
|
||||
]
|
||||
|
||||
SSH_KEYS_CREDENTIALS = [
|
||||
|
@ -93,6 +97,7 @@ def test_add_credentials_to_store(aggregating_credentials_store):
|
|||
"abcdefg",
|
||||
"password",
|
||||
"root",
|
||||
"super_secret",
|
||||
]
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue