Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tests/integration_tests/modules/test_set_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
they use a mixin to share their test definitions, because we can (of course)
only specify one user-data per instance.
"""
import crypt

import pytest
import yaml

Expand Down Expand Up @@ -162,9 +160,13 @@ def test_explicit_password_set_correctly(self, class_client):
shadow_users, _ = self._fetch_and_parse_etc_shadow(class_client)

fmt_and_salt = shadow_users["tom"].rsplit("$", 1)[0]
expected_value = crypt.crypt("mypassword123!", fmt_and_salt)

assert expected_value == shadow_users["tom"]
GEN_CRYPT_CONTENT = (
"import crypt\n"
f"print(crypt.crypt('mypassword123!', '{fmt_and_salt}'))\n"
)
class_client.write_to_file("/gen_crypt.py", GEN_CRYPT_CONTENT)
result = class_client.execute("python3 /gen_crypt.py")
assert result.stdout == shadow_users["tom"]

def test_shadow_expected_users(self, class_client):
"""Test that the right set of users is in /etc/shadow."""
Expand Down