···
environment.systemPackages = [ pkgs.openssl ];
7
-
in import ./make-test.nix {
7
+
in import ./make-test-python.nix {
nodes.generation1 = { pkgs, config, ... }: {
···
node = "generation${toString gen}";
in nodes.${node}.config.security.dhparams.params.${name}.path;
69
-
assertParamBits = gen: name: bits: let
70
-
path = getParamPath gen name;
72
-
$machine->nest('check bit size of ${path}', sub {
73
-
my $out = $machine->succeed('openssl dhparam -in ${path} -text');
74
-
$out =~ /^\s*DH Parameters:\s+\((\d+)\s+bit\)\s*$/m;
75
-
die "bit size should be ${toString bits} but it is $1 instead."
76
-
if $1 != ${toString bits};
switchToGeneration = gen: let
node = "generation${toString gen}";
inherit (nodes.${node}.config.system.build) toplevel;
switchCmd = "${toplevel}/bin/switch-to-configuration test";
85
-
$machine->nest('switch to generation ${toString gen}', sub {
86
-
$machine->succeed('${switchCmd}');
87
-
$main::machine = ''$${node};
74
+
with machine.nested("switch to generation ${toString gen}"):
92
-
my $machine = $generation1;
85
+
def assert_param_bits(path, bits):
86
+
with machine.nested(f"check bit size of {path}"):
87
+
output = machine.succeed(f"openssl dhparam -in {path} -text")
88
+
pattern = re.compile(r"^\s*DH Parameters:\s+\((\d+)\s+bit\)\s*$", re.M)
89
+
match = pattern.match(output)
91
+
raise Exception("bla")
92
+
if match[1] != str(bits):
93
+
raise Exception(f"bit size should be {bits} but it is {match[1]} instead.")
94
-
$machine->waitForUnit('multi-user.target');
96
+
machine = generation1
96
-
subtest "verify startup order", sub {
97
-
$machine->succeed('systemctl is-active foo.service');
98
+
machine.wait_for_unit("multi-user.target")
100
-
subtest "check bit sizes of dhparam files", sub {
101
-
${assertParamBits 1 "foo" 16}
102
-
${assertParamBits 1 "bar" 17}
100
+
with subtest("verify startup order"):
101
+
machine.succeed("systemctl is-active foo.service")
103
+
with subtest("check bit sizes of dhparam files"):
104
+
assert_param_bits("${getParamPath 1 "foo"}", 16)
105
+
assert_param_bits("${getParamPath 1 "bar"}", 17)
107
-
subtest "check whether bit size has changed", sub {
108
-
${assertParamBits 2 "foo" 18}
109
+
with subtest("check whether bit size has changed"):
110
+
assert_param_bits("${getParamPath 2 "foo"}", 18)
111
-
subtest "ensure that dhparams file for 'bar' was deleted", sub {
112
-
$machine->fail('test -e ${getParamPath 1 "bar"}');
112
+
with subtest("ensure that dhparams file for 'bar' was deleted"):
113
+
machine.fail("test -e ${getParamPath 1 "bar"}")
117
-
subtest "ensure that 'security.dhparams.path' has been deleted", sub {
119
-
'test -e ${nodes.generation3.config.security.dhparams.path}'
117
+
with subtest("ensure that 'security.dhparams.path' has been deleted"):
118
+
machine.fail("test -e ${nodes.generation3.config.security.dhparams.path}")
125
-
subtest "check bit sizes dhparam files", sub {
126
-
${assertParamBits 4 "foo2" 18}
127
-
${assertParamBits 4 "bar2" 19}
122
+
with subtest("check bit sizes dhparam files"):
124
+
"${getParamPath 4 "foo2"}", 18
127
+
"${getParamPath 4 "bar2"}", 19
130
-
subtest "check whether dhparam files are in the Nix store", sub {
132
-
'expr match ${getParamPath 4 "foo2"} ${builtins.storeDir}',
133
-
'expr match ${getParamPath 4 "bar2"} ${builtins.storeDir}',
130
+
with subtest("check whether dhparam files are in the Nix store"):
132
+
"expr match ${getParamPath 4 "foo2"} ${builtins.storeDir}",
133
+
"expr match ${getParamPath 4 "bar2"} ${builtins.storeDir}",
139
-
subtest "check whether defaultBitSize works as intended", sub {
140
-
${assertParamBits 5 "foo3" 30}
141
-
${assertParamBits 5 "bar3" 30}
138
+
with subtest("check whether defaultBitSize works as intended"):
139
+
assert_param_bits("${getParamPath 5 "foo3"}", 30)
140
+
assert_param_bits("${getParamPath 5 "bar3"}", 30)