vuls: init at 0.27.0
[NixPkgs.git] / nixos / tests / evcc.nix
blob7ebdc6a6f5ab983053db2bd3474e1a50b60c8885
1 import ./make-test-python.nix ({ pkgs, lib, ...} :
4   name = "evcc";
5   meta.maintainers = with lib.maintainers; [ hexa ];
7   nodes = {
8     machine = { config, ... }: {
9       services.evcc = {
10         enable = true;
11         settings = {
12           network = {
13             schema = "http";
14             host = "localhost";
15             port = 7070;
16           };
18           log = "info";
20           site = {
21             title = "NixOS Test";
22             meters = {
23               grid = "grid";
24               pv = "pv";
25             };
26           };
28           meters = [ {
29             type = "custom";
30             name = "grid";
31             power = {
32               source = "script";
33               cmd = "/bin/sh -c 'echo -4500'";
34             };
35           } {
36             type = "custom";
37             name = "pv";
38             power = {
39               source = "script";
40               cmd = "/bin/sh -c 'echo 7500'";
41             };
42           } ];
44           chargers = [ {
45             name = "dummy-charger";
46             type = "custom";
47             status = {
48               source = "script";
49               cmd = "/bin/sh -c 'echo charger status A'";
50             };
51             enabled = {
52               source = "script";
53               cmd = "/bin/sh -c 'echo charger enabled state false'";
54             };
55             enable = {
56               source = "script";
57               cmd = "/bin/sh -c 'echo set charger enabled state true'";
58             };
59             maxcurrent = {
60               source = "script";
61               cmd = "/bin/sh -c 'echo set charger max current 7200'";
62             };
63           } ];
65           loadpoints = [ {
66             title = "Dummy";
67             charger = "dummy-charger";
68           } ];
69         };
70       };
71     };
72   };
74   testScript = ''
75     start_all()
77     machine.wait_for_unit("evcc.service")
78     machine.wait_for_open_port(7070)
80     with subtest("Check package version propagates into frontend"):
81         machine.fail(
82             "curl --fail http://localhost:7070 | grep '0.0.1-alpha'"
83         )
84         machine.succeed(
85             "curl --fail http://localhost:7070 | grep '${pkgs.evcc.version}'"
86         )
88     with subtest("Check journal for errors"):
89         _, output = machine.execute("journalctl -o cat -u evcc.service")
90         assert "FATAL" not in output
92     with subtest("Check systemd hardening"):
93         _, output = machine.execute("systemd-analyze security evcc.service | grep -v '✓'")
94         machine.log(output)
95   '';