|
8 | 8 |
|
9 | 9 | users.users.nixos = { |
10 | 10 | isNormalUser = true; |
| 11 | + password = "somespecialpassword"; |
11 | 12 | openssh.authorizedKeys.keyFiles = [ ./modules/ssh-keys/ssh.pub ]; |
12 | 13 | extraGroups = [ "wheel" ]; |
13 | 14 | }; |
14 | 15 | security.sudo.enable = true; |
15 | | - security.sudo.wheelNeedsPassword = false; |
| 16 | + security.sudo.wheelNeedsPassword = true; |
16 | 17 | }; |
17 | 18 | }; |
18 | | - testScript = '' |
19 | | - start_all() |
20 | | - installer.succeed("echo super-secret > /tmp/disk-1.key") |
21 | | - output = installer.succeed(""" |
22 | | - nixos-anywhere \ |
23 | | - -i /root/.ssh/install_key \ |
24 | | - --debug \ |
25 | | - --kexec /etc/nixos-anywhere/kexec-installer.tar.gz \ |
26 | | - --phases kexec,disko \ |
27 | | - --disk-encryption-keys /tmp/disk-1.key /tmp/disk-1.key \ |
28 | | - --disk-encryption-keys /tmp/disk-2.key <(echo another-secret) \ |
29 | | - --store-paths /etc/nixos-anywhere/disko /etc/nixos-anywhere/system-to-install \ |
30 | | - nixos@installed >&2 |
31 | | - echo "disk-1.key: '$(ssh -i /root/.ssh/install_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ |
32 | | - root@installed cat /tmp/disk-1.key)'" |
33 | | - echo "disk-2.key: '$(ssh -i /root/.ssh/install_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ |
34 | | - root@installed cat /tmp/disk-2.key)'" |
35 | | - """) |
36 | | -
|
37 | | - assert "disk-1.key: 'super-secret'" in output, f"output does not contain expected values: {output}" |
38 | | - assert "disk-2.key: 'another-secret'" in output, f"output does not contain expected values: {output}" |
39 | | - ''; |
| 19 | + |
| 20 | + testScript = |
| 21 | + { nodes, ... }: |
| 22 | + '' |
| 23 | + start_all() |
| 24 | +
|
| 25 | + installer.succeed("echo super-secret > /tmp/disk-1.key") |
| 26 | + installer.wait_for_unit("getty.target") |
| 27 | + installer.wait_for_unit("multi-user.target") |
| 28 | + installer.wait_for_unit("default.target") |
| 29 | +
|
| 30 | + installer.wait_until_tty_matches("1",".*root.installer:.*") |
| 31 | + command="nixos-anywhere -i /root/.ssh/install_key --debug --kexec /etc/nixos-anywhere/kexec-installer.tar.gz --phases kexec,disko --disk-encryption-keys /tmp/disk-1.key /tmp/disk-1.key --disk-encryption-keys /tmp/disk-2.key <(echo another-secret) --store-paths /etc/nixos-anywhere/disko /etc/nixos-anywhere/system-to-install nixos@installed\n" |
| 32 | + installer.send_chars(command) |
| 33 | +
|
| 34 | +
|
| 35 | + installer.wait_until_tty_matches("1",".* password for nixos:.*") |
| 36 | + installer.send_chars("${nodes.installed.users.users.nixos.password}\n") |
| 37 | +
|
| 38 | + installer.wait_until_tty_matches("1",".*### Done! ###.*") |
| 39 | + installer.wait_until_tty_matches("1",".*root.installer:.*") |
| 40 | +
|
| 41 | + output = installer.succeed("""echo "disk-1.key: '$(ssh -i /root/.ssh/install_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@installed cat /tmp/disk-1.key)'" """) |
| 42 | + assert "disk-1.key: 'super-secret'" in output, f"output does not contain expected values: {output}" |
| 43 | +
|
| 44 | + output = installer.succeed("""echo "disk-2.key: '$(ssh -i /root/.ssh/install_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@installed cat /tmp/disk-2.key)'" """) |
| 45 | + assert "disk-2.key: 'another-secret'" in output, f"output does not contain expected values: {output}" |
| 46 | + ''; |
40 | 47 | } |
0 commit comments