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