wsjtx: fix and enable strictDeps (#366619)
[NixPkgs.git] / nixos / tests / web-apps / peertube.nix
blobe260786458e4992bae41176ae91ace0d7506533d
1 import ../make-test-python.nix (
2   { pkgs, ... }:
3   {
4     name = "peertube";
5     meta.maintainers = with pkgs.lib.maintainers; [ izorkin ];
7     nodes = {
8       database = {
9         networking = {
10           interfaces.eth1 = {
11             ipv4.addresses = [
12               {
13                 address = "192.168.2.10";
14                 prefixLength = 24;
15               }
16             ];
17           };
18           firewall.allowedTCPPorts = [
19             5432
20             31638
21           ];
22         };
24         services.postgresql = {
25           enable = true;
26           enableTCPIP = true;
27           ensureDatabases = [ "peertube_test" ];
28           ensureUsers = [
29             {
30               name = "peertube_test";
31               ensureDBOwnership = true;
32             }
33           ];
34           authentication = ''
35             hostnossl peertube_test peertube_test 192.168.2.11/32 md5
36           '';
37           initialScript = pkgs.writeText "postgresql_init.sql" ''
38             CREATE ROLE peertube_test LOGIN PASSWORD '0gUN0C1mgST6czvjZ8T9';
39           '';
40         };
42         services.redis.servers.peertube = {
43           enable = true;
44           bind = "0.0.0.0";
45           requirePass = "turrQfaQwnanGbcsdhxy";
46           port = 31638;
47         };
48       };
50       server =
51         { pkgs, ... }:
52         {
53           environment = {
54             etc = {
55               "peertube/password-init-root".text = ''
56                 PT_INITIAL_ROOT_PASSWORD=zw4SqYVdcsXUfRX8aaFX
57               '';
58               "peertube/secrets-peertube".text = ''
59                 063d9c60d519597acef26003d5ecc32729083965d09181ef3949200cbe5f09ee
60               '';
61               "peertube/password-posgressql-db".text = ''
62                 0gUN0C1mgST6czvjZ8T9
63               '';
64               "peertube/password-redis-db".text = ''
65                 turrQfaQwnanGbcsdhxy
66               '';
67             };
68           };
70           networking = {
71             interfaces.eth1 = {
72               ipv4.addresses = [
73                 {
74                   address = "192.168.2.11";
75                   prefixLength = 24;
76                 }
77               ];
78             };
79             extraHosts = ''
80               192.168.2.11 peertube.local
81             '';
82             firewall.allowedTCPPorts = [ 9000 ];
83           };
85           services.peertube = {
86             enable = true;
87             localDomain = "peertube.local";
88             enableWebHttps = false;
90             serviceEnvironmentFile = "/etc/peertube/password-init-root";
92             secrets = {
93               secretsFile = "/etc/peertube/secrets-peertube";
94             };
96             database = {
97               host = "192.168.2.10";
98               name = "peertube_test";
99               user = "peertube_test";
100               passwordFile = "/etc/peertube/password-posgressql-db";
101             };
103             redis = {
104               host = "192.168.2.10";
105               port = 31638;
106               passwordFile = "/etc/peertube/password-redis-db";
107             };
109             settings = {
110               listen = {
111                 hostname = "0.0.0.0";
112               };
113               instance = {
114                 name = "PeerTube Test Server";
115               };
116             };
117           };
118         };
120       client = {
121         environment.systemPackages = [
122           pkgs.jq
123           pkgs.peertube.cli
124         ];
125         networking = {
126           interfaces.eth1 = {
127             ipv4.addresses = [
128               {
129                 address = "192.168.2.12";
130                 prefixLength = 24;
131               }
132             ];
133           };
134           extraHosts = ''
135             192.168.2.11 peertube.local
136           '';
137         };
138       };
140     };
142     testScript = ''
143       start_all()
145       database.wait_for_unit("postgresql.service")
146       database.wait_for_unit("redis-peertube.service")
148       database.wait_for_open_port(5432)
149       database.wait_for_open_port(31638)
151       server.wait_for_unit("peertube.service")
152       server.wait_for_open_port(9000)
154       # Check if PeerTube is running
155       client.succeed("curl --fail http://peertube.local:9000/api/v1/config/about | jq -r '.instance.name' | grep 'PeerTube\ Test\ Server'")
157       # Check PeerTube CLI version
158       client.succeed('peertube-cli auth add -u "http://peertube.local:9000" -U "root" --password "zw4SqYVdcsXUfRX8aaFX"')
159       client.succeed('peertube-cli auth list | grep "http://peertube.local:9000"')
160       client.succeed('peertube-cli auth del "http://peertube.local:9000"')
161       client.fail('peertube-cli auth list | grep "http://peertube.local:9000"')
163       client.shutdown()
164       server.shutdown()
165       database.shutdown()
166     '';
167   }