From 02661233b93b9d005797018220d5f65d5a156bad Mon Sep 17 00:00:00 2001 From: cmcmarrow Date: Tue, 3 Oct 2023 12:13:04 -0500 Subject: [PATCH] auth user --- tests/pytests/functional/auth/__init__.py | 0 tests/pytests/functional/auth/auth.py | 17 +++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/pytests/functional/auth/__init__.py create mode 100644 tests/pytests/functional/auth/auth.py diff --git a/tests/pytests/functional/auth/__init__.py b/tests/pytests/functional/auth/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/pytests/functional/auth/auth.py b/tests/pytests/functional/auth/auth.py new file mode 100644 index 000000000000..d2edb8a74c0e --- /dev/null +++ b/tests/pytests/functional/auth/auth.py @@ -0,0 +1,17 @@ +import salt.utils.user +from salt import auth + + +def test_user_is_sudo(): + assert auth.AuthUser("bob").is_sudo() is False + assert auth.AuthUser("sudo_bob").is_sudo() is True + + +def test_user_is_running_user(): + current_user = salt.utils.user.get_user() + assert auth.AuthUser(salt.utils.user.get_user() + "1").is_running_user() is False + assert auth.AuthUser(current_user).is_running_user() is True + + +def test_user_sudo_name(): + assert auth.AuthUser("sudo_bob").sudo_name() == "bob"