python312Packages.homematicip: 1.1.2 -> 1.1.3 (#356780)
[NixPkgs.git] / nixos / tests / atticd.nix
blob4193d75d2a925c8552dd1b840c9a2088d40ba577
1 { lib, pkgs, ... }:
3 let
4   accessKey = "BKIKJAA5BMMU2RHO6IBB";
5   secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12";
7   minioCredentialsFile = pkgs.writeText "minio-credentials-full" ''
8     MINIO_ROOT_USER=${accessKey}
9     MINIO_ROOT_PASSWORD=${secretKey}
10   '';
11   environmentFile = pkgs.runCommand "atticd-env" { } ''
12     echo ATTIC_SERVER_TOKEN_RS256_SECRET_BASE64="$(${lib.getExe pkgs.openssl} genrsa -traditional 4096 | ${pkgs.coreutils}/bin/base64 -w0)" > $out
13   '';
17   name = "atticd";
19   nodes = {
20     local = {
21       services.atticd = {
22         enable = true;
24         inherit environmentFile;
25       };
27       environment.systemPackages = [
28         pkgs.attic-client
29       ];
30     };
32     s3 = {
33       services.atticd = {
34         enable = true;
35         settings = {
36           storage = {
37             type = "s3";
38             bucket = "attic";
39             region = "us-east-1";
40             endpoint = "http://127.0.0.1:9000";
42             credentials = {
43               access_key_id = accessKey;
44               secret_access_key = secretKey;
45             };
46           };
47         };
49         inherit environmentFile;
50       };
52       services.minio = {
53         enable = true;
54         rootCredentialsFile = minioCredentialsFile;
55       };
57       environment.systemPackages = [
58         pkgs.attic-client
59         pkgs.minio-client
60       ];
61     };
62   };
64   testScript = # python
65     ''
66       start_all()
68       with subtest("local storage push"):
69           local.wait_for_unit("atticd.service")
70           token = local.succeed("atticd-atticadm make-token --sub stop --validity 1y --create-cache '*' --pull '*' --push '*' --delete '*' --configure-cache '*' --configure-cache-retention '*'").strip()
72           local.succeed(f"attic login local http://localhost:8080 {token}")
73           local.succeed("attic cache create test-cache")
74           local.succeed("attic push test-cache ${environmentFile}")
76       with subtest("s3 storage push"):
77           s3.wait_for_unit("atticd.service")
78           s3.wait_for_unit("minio.service")
79           s3.wait_for_open_port(9000)
80           s3.succeed(
81               "mc config host add minio "
82               + "http://localhost:9000 "
83               + "${accessKey} ${secretKey} --api s3v4",
84               "mc mb minio/attic",
85           )
86           token = s3.succeed("atticd-atticadm make-token --sub stop --validity 1y --create-cache '*' --pull '*' --push '*' --delete '*' --configure-cache '*' --configure-cache-retention '*'").strip()
88           s3.succeed(f"attic login s3 http://localhost:8080 {token}")
89           s3.succeed("attic cache create test-cache")
90           s3.succeed("attic push test-cache ${environmentFile}")
91     '';