mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-21 13:10:33 +00:00
nixos/tests/initrd-ssh: port to python
This commit is contained in:
parent
336bffae6d
commit
9a7101c999
|
@ -1,4 +1,4 @@
|
||||||
import ../make-test.nix ({ lib, ... }:
|
import ../make-test-python.nix ({ lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "initrd-network-ssh";
|
name = "initrd-network-ssh";
|
||||||
|
@ -35,25 +35,31 @@ import ../make-test.nix ({ lib, ... }:
|
||||||
client =
|
client =
|
||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
{
|
{
|
||||||
environment.etc.knownHosts = {
|
environment.etc = {
|
||||||
text = concatStrings [
|
knownHosts = {
|
||||||
"server,"
|
text = concatStrings [
|
||||||
"${toString (head (splitString " " (
|
"server,"
|
||||||
toString (elemAt (splitString "\n" config.networking.extraHosts) 2)
|
"${toString (head (splitString " " (
|
||||||
)))} "
|
toString (elemAt (splitString "\n" config.networking.extraHosts) 2)
|
||||||
"${readFile ./dropbear.pub}"
|
)))} "
|
||||||
];
|
"${readFile ./dropbear.pub}"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
sshKey = {
|
||||||
|
source = ./openssh.priv; # dont use this anywhere else
|
||||||
|
mode = "0600";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
startAll;
|
start_all()
|
||||||
$client->waitForUnit("network.target");
|
client.wait_for_unit("network.target")
|
||||||
$client->copyFileFromHost("${./openssh.priv}","/etc/sshKey");
|
client.wait_until_succeeds("ping -c 1 server")
|
||||||
$client->succeed("chmod 0600 /etc/sshKey");
|
client.succeed(
|
||||||
$client->waitUntilSucceeds("ping -c 1 server");
|
"ssh -i /etc/sshKey -o UserKnownHostsFile=/etc/knownHosts server 'touch /fnord'"
|
||||||
$client->succeed("ssh -i /etc/sshKey -o UserKnownHostsFile=/etc/knownHosts server 'touch /fnord'");
|
)
|
||||||
$client->shutdown;
|
client.shutdown()
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue