Skip to content
/ nixpkgs Public
forked from NixOS/nixpkgs

Commit

Permalink
nixos/tests/printing: test cases for domain socket only config
Browse files Browse the repository at this point in the history
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:

OpenPrinting/cups#985
NixOS#337748
  • Loading branch information
Yarny0 committed Aug 29, 2024
1 parent 1412d93 commit 91466e5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,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 {};
privoxy = handleTest ./privoxy.nix {};
prometheus = handleTest ./prometheus {};
Expand Down
6 changes: 4 additions & 2 deletions nixos/tests/printing.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
, ...
}:

Expand Down Expand Up @@ -35,9 +36,10 @@ import ./make-test-python.nix (
}];
};

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";
Expand All @@ -63,7 +65,7 @@ import ./make-test-python.nix (
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/")
${pkgs.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/")
Expand Down
2 changes: 2 additions & 0 deletions pkgs/misc/cups/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ stdenv.mkDerivation rec {
cups-pdf
printing-service
printing-socket
printing-service-notcp
printing-socket-notcp
;
};

Expand Down

0 comments on commit 91466e5

Please sign in to comment.