about summary refs log tree commit diff
path: root/nixos/tests/ydotool.nix
diff options
context:
space:
mode:
authorVictor Engmark <victor@engmark.name>2024-06-04 20:04:49 +1200
committerVictor Engmark <victor@engmark.name>2024-06-14 10:07:28 +1200
commit408406c2ff06f30c52106dc2a6b93ab6ca691d1e (patch)
treeb0150779ba2cfb13edbac6035ef5a54c26bfc314 /nixos/tests/ydotool.nix
parent7203cf8e3de95c683ac7b021e85414ce2f9c6611 (diff)
nixos/ydotool: Make group configurable
Allows users to refer to `config.programs.ydotool.group` rather than
hard-coding "ydotool".

Allows users to override the group name for whatever reason.

This closes #317013.

Co-authored-by: Cosima Neidahl <opna2608@protonmail.com>
Diffstat (limited to 'nixos/tests/ydotool.nix')
-rw-r--r--nixos/tests/ydotool.nix43
1 files changed, 43 insertions, 0 deletions
diff --git a/nixos/tests/ydotool.nix b/nixos/tests/ydotool.nix
index b7ee7aced2b7c..45e3d27adeb49 100644
--- a/nixos/tests/ydotool.nix
+++ b/nixos/tests/ydotool.nix
@@ -138,4 +138,47 @@ in
       quantenzitrone
     ];
   };
+
+  customGroup =
+    let
+      name = "customGroup";
+      nodeName = "${name}Node";
+      insideGroupUsername = "ydotool-user";
+      outsideGroupUsername = "other-user";
+      groupName = "custom-group";
+    in
+    makeTest {
+      inherit name;
+
+      nodes."${nodeName}" = {
+        programs.ydotool = {
+          enable = true;
+          group = groupName;
+        };
+
+        users.users = {
+          "${insideGroupUsername}" = {
+            isNormalUser = true;
+            extraGroups = [ groupName ];
+          };
+          "${outsideGroupUsername}".isNormalUser = true;
+        };
+      };
+
+      testScript = ''
+        start_all()
+
+        # Wait for service to start
+        ${nodeName}.wait_for_unit("multi-user.target")
+        ${nodeName}.wait_for_unit("ydotoold.service")
+
+        # Verify that user with the configured group can use the service
+        ${nodeName}.succeed("sudo --login --user=${insideGroupUsername} ydotool type 'Hello, World!'")
+
+        # Verify that user without the configured group can't use the service
+        ${nodeName}.fail("sudo --login --user=${outsideGroupUsername} ydotool type 'Hello, World!'")
+      '';
+
+      meta.maintainers = with lib.maintainers; [ l0b0 ];
+    };
 }