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
This commit is contained in:
Yarny0 2024-08-29 15:12:56 +02:00
parent 2e48883fc4
commit 9bca42857a
3 changed files with 10 additions and 4 deletions

View File

@ -827,8 +827,10 @@ in {
predictable-interface-names = handleTest ./predictable-interface-names.nix {}; predictable-interface-names = handleTest ./predictable-interface-names.nix {};
pretalx = runTest ./web-apps/pretalx.nix; pretalx = runTest ./web-apps/pretalx.nix;
pretix = runTest ./web-apps/pretix.nix; pretix = runTest ./web-apps/pretix.nix;
printing-socket = handleTest ./printing.nix { socket = true; }; printing-socket = handleTest ./printing.nix { socket = true; listenTcp = true; };
printing-service = handleTest ./printing.nix { socket = false; }; 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 {}; private-gpt = handleTest ./private-gpt.nix {};
privatebin = runTest ./privatebin.nix; privatebin = runTest ./privatebin.nix;
privoxy = handleTest ./privoxy.nix {}; privoxy = handleTest ./privoxy.nix {};

View File

@ -3,6 +3,7 @@
import ./make-test-python.nix ( import ./make-test-python.nix (
{ pkgs { pkgs
, socket ? true # whether to use socket activation , 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.enable = true;
services.printing.startWhenNeeded = socket; services.printing.startWhenNeeded = socket;
services.printing.listenAddresses = lib.mkIf (!listenTcp) [];
# Add printer to the client as well, via IPP. # Add printer to the client as well, via IPP.
hardware.printers.ensurePrinters = [{ hardware.printers.ensurePrinters = [{
name = "DeskjetRemote"; name = "DeskjetRemote";
@ -67,7 +69,7 @@ in
assert "/var/run/cups/cups.sock" in client.succeed("lpstat -H") assert "/var/run/cups/cups.sock" in client.succeed("lpstat -H")
with subtest("HTTP server is available too"): 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/") client.succeed(f"curl --fail http://{server.name}:631/")
server.fail(f"curl --fail --connect-timeout 2 http://{client.name}:631/") server.fail(f"curl --fail --connect-timeout 2 http://{client.name}:631/")

View File

@ -141,6 +141,8 @@ stdenv.mkDerivation rec {
cups-pdf cups-pdf
printing-service printing-service
printing-socket printing-socket
printing-service-notcp
printing-socket-notcp
; ;
}; };