From 9bca42857a280d8c4fc83efd1884ceaf96b6e3d0 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:12:56 +0200 Subject: [PATCH] nixos/tests/printing: test cases for domain socket only config Add two new vm tests for the printing configuration that test `listenAddresses = []`, i.e., the situation where cups only listens on the unix domain socket `/run/cups/cups.sock`. This helps catching bugs like this: https://github.com/OpenPrinting/cups/issues/985 https://github.com/NixOS/nixpkgs/pull/337748 --- nixos/tests/all-tests.nix | 6 ++++-- nixos/tests/printing.nix | 6 ++++-- pkgs/misc/cups/default.nix | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index dd6519ff9361..78915a8c1db3 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -827,8 +827,10 @@ in { predictable-interface-names = handleTest ./predictable-interface-names.nix {}; pretalx = runTest ./web-apps/pretalx.nix; pretix = runTest ./web-apps/pretix.nix; - printing-socket = handleTest ./printing.nix { socket = true; }; - printing-service = handleTest ./printing.nix { socket = false; }; + printing-socket = handleTest ./printing.nix { socket = true; listenTcp = true; }; + printing-service = handleTest ./printing.nix { socket = false; listenTcp = true; }; + printing-socket-notcp = handleTest ./printing.nix { socket = true; listenTcp = false; }; + printing-service-notcp = handleTest ./printing.nix { socket = false; listenTcp = false; }; private-gpt = handleTest ./private-gpt.nix {}; privatebin = runTest ./privatebin.nix; privoxy = handleTest ./privoxy.nix {}; diff --git a/nixos/tests/printing.nix b/nixos/tests/printing.nix index c612345e9583..5f719a5d97c1 100644 --- a/nixos/tests/printing.nix +++ b/nixos/tests/printing.nix @@ -3,6 +3,7 @@ import ./make-test-python.nix ( { pkgs , socket ? true # whether to use socket activation +, listenTcp ? true # whether to open port 631 on client , ... }: @@ -39,9 +40,10 @@ in }]; }; - nodes.client = { ... }: { + nodes.client = { lib, ... }: { services.printing.enable = true; services.printing.startWhenNeeded = socket; + services.printing.listenAddresses = lib.mkIf (!listenTcp) []; # Add printer to the client as well, via IPP. hardware.printers.ensurePrinters = [{ name = "DeskjetRemote"; @@ -67,7 +69,7 @@ in assert "/var/run/cups/cups.sock" in client.succeed("lpstat -H") with subtest("HTTP server is available too"): - client.succeed("curl --fail http://localhost:631/") + ${lib.optionalString listenTcp ''client.succeed("curl --fail http://localhost:631/")''} client.succeed(f"curl --fail http://{server.name}:631/") server.fail(f"curl --fail --connect-timeout 2 http://{client.name}:631/") diff --git a/pkgs/misc/cups/default.nix b/pkgs/misc/cups/default.nix index 566632d74d78..085ecdbed827 100644 --- a/pkgs/misc/cups/default.nix +++ b/pkgs/misc/cups/default.nix @@ -141,6 +141,8 @@ stdenv.mkDerivation rec { cups-pdf printing-service printing-socket + printing-service-notcp + printing-socket-notcp ; };