diff --git a/tests/default.nix b/tests/default.nix index aa14fc24..3997ac6c 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -26,7 +26,9 @@ import nmt { mbsync = ./modules/programs/mbsync.nix; texlive-minimal = ./modules/programs/texlive-minimal.nix; xresources = ./modules/xresources.nix; - } // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { + } + // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { i3-keybindings = ./modules/services/window-managers/i3-keybindings.nix; - }; + } + // import ./modules/programs/ssh; } diff --git a/tests/modules/programs/ssh/default-config-expected.conf b/tests/modules/programs/ssh/default-config-expected.conf new file mode 100644 index 00000000..55748ea6 --- /dev/null +++ b/tests/modules/programs/ssh/default-config-expected.conf @@ -0,0 +1,15 @@ + + + + +Host * + ForwardAgent no + Compression no + ServerAliveInterval 0 + HashKnownHosts no + UserKnownHostsFile ~/.ssh/known_hosts + ControlMaster no + ControlPath ~/.ssh/master-%r@%n:%p + ControlPersist no + + diff --git a/tests/modules/programs/ssh/default-config.nix b/tests/modules/programs/ssh/default-config.nix new file mode 100644 index 00000000..e43ee3dc --- /dev/null +++ b/tests/modules/programs/ssh/default-config.nix @@ -0,0 +1,16 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.ssh = { + enable = true; + }; + + nmt.script = '' + assertFileExists home-files/.ssh/config + assertFileContent home-files/.ssh/config ${./default-config-expected.conf} + ''; + }; +} diff --git a/tests/modules/programs/ssh/default.nix b/tests/modules/programs/ssh/default.nix new file mode 100644 index 00000000..d385e4ee --- /dev/null +++ b/tests/modules/programs/ssh/default.nix @@ -0,0 +1,4 @@ +{ + ssh-defaults = ./default-config.nix; + ssh-match-blocks = ./match-blocks-attrs.nix; +} diff --git a/tests/modules/programs/ssh/match-blocks-attrs-expected.conf b/tests/modules/programs/ssh/match-blocks-attrs-expected.conf new file mode 100644 index 00000000..76bbe2e3 --- /dev/null +++ b/tests/modules/programs/ssh/match-blocks-attrs-expected.conf @@ -0,0 +1,25 @@ + + +Host * !github.com + Port 516 + IdentityFile file1 + IdentityFile file2 + +Host abc + ProxyJump jump-host + +Host xyz + ServerAliveInterval 60 + IdentityFile file + +Host * + ForwardAgent no + Compression no + ServerAliveInterval 0 + HashKnownHosts no + UserKnownHostsFile ~/.ssh/known_hosts + ControlMaster no + ControlPath ~/.ssh/master-%r@%n:%p + ControlPersist no + + diff --git a/tests/modules/programs/ssh/match-blocks-attrs.nix b/tests/modules/programs/ssh/match-blocks-attrs.nix new file mode 100644 index 00000000..cb554db2 --- /dev/null +++ b/tests/modules/programs/ssh/match-blocks-attrs.nix @@ -0,0 +1,34 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.ssh = { + enable = true; + matchBlocks = { + abc = { + identityFile = null; + proxyJump = "jump-host"; + }; + + xyz = { + identityFile = "file"; + serverAliveInterval = 60; + }; + + "* !github.com" = { + identityFile = ["file1" "file2"]; + port = 516; + }; + }; + }; + + nmt.script = '' + assertFileExists home-files/.ssh/config + assertFileContent \ + home-files/.ssh/config \ + ${./match-blocks-attrs-expected.conf} + ''; + }; +}