chore(tests): Move truncation to when key files in integration tests are read instead of when they are written

This commit is contained in:
David Niehues
2025-08-22 16:46:19 +02:00
parent 15f2153b1b
commit 8ee0619c08

View File

@@ -38,10 +38,10 @@ let
# The trailing line break that is generated by `wg genkey` and `wg pubkey` breaks the script rp-key-sync.nix to copy the preshared keys.
# We therefore remove the trailing spaces here.
privateKey = pkgs.runCommand "wg-private-${name}" { } ''
${pkgs.wireguard-tools}/bin/wg genkey | tr -d '\n' > $out
${pkgs.wireguard-tools}/bin/wg genkey > $out
'';
publicKey = pkgs.runCommand "wg-public-${name}" { } ''
cat ${privateKey} | ${pkgs.wireguard-tools}/bin/wg pubkey | tr -d '\n' > $out
cat ${privateKey} | ${pkgs.wireguard-tools}/bin/wg pubkey > $out
'';
in
{
@@ -73,8 +73,8 @@ let
{
peerA = {
innerIp = "10.100.0.1";
privateKey = builtins.readFile peerAWgKeys.privateKey;
publicKey = builtins.readFile peerAWgKeys.publicKey;
privateKey = lib.removeSuffix "\n" (builtins.readFile peerAWgKeys.privateKey);
publicKey = lib.removeSuffix "\n" (builtins.readFile peerAWgKeys.publicKey);
rosenpassConfig = builtins.toFile "peer-a.toml" (
''
public_key = "${rosenpassKeyFolder}/self.pk"
@@ -97,8 +97,8 @@ let
};
peerB = {
innerIp = "10.100.0.2";
privateKey = builtins.readFile peerBWgKeys.privateKey;
publicKey = builtins.readFile peerBWgKeys.publicKey;
privateKey = lib.removeSuffix "\n" (builtins.readFile peerBWgKeys.privateKey);
publicKey = lib.removeSuffix "\n" (builtins.readFile peerBWgKeys.publicKey);
rosenpassConfig = builtins.toFile "peer-b.toml" (
''
public_key = "${rosenpassKeyFolder}/self.pk"
@@ -124,8 +124,8 @@ let
# peerC is only defined if we are in a multiPeer context.
peerC = {
innerIp = "10.100.0.3";
privateKey = builtins.readFile peerCWgKeys.privateKey;
publicKey = builtins.readFile peerCWgKeys.publicKey;
privateKey = lib.removeSuffix "\n" (builtins.readFile peerCWgKeys.privateKey);
publicKey = lib.removeSuffix "\n" (builtins.readFile peerCWgKeys.publicKey);
rosenpassConfig = builtins.toFile "peer-c.toml" ''
public_key = "${rosenpassKeyFolder}/self.pk"
secret_key = "${rosenpassKeyFolder}/self.sk"