summaryrefslogtreecommitdiffstats
path: root/nixos/tests/age-plugin-tpm-decrypt.nix
blob: d46bc875be188e7ce26246d961eb96956f7208ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{ pkgs, lib, ... }:
{
  name = "age-plugin-tpm-decrypt";
  meta = with lib.maintainers; {
    maintainers = [
      sgo
      josh
    ];
  };

  nodes.machine =
    { pkgs, ... }:
    {
      virtualisation.tpm.enable = true;
      environment.systemPackages = with pkgs; [
        age
        age-plugin-tpm
      ];
    };

  testScript = ''
    machine.start()

    machine.succeed("age-plugin-tpm --generate --output identity.txt")
    machine.succeed("age-plugin-tpm --convert identity.txt --output recipient.txt")
    machine.succeed("echo -n 'Hello World' >data.txt")

    machine.succeed("age --encrypt --recipients-file recipient.txt --output data.age data.txt")
    data = machine.succeed("age --decrypt --identity identity.txt data.age")

    assert data == "Hello World"
  '';
}