vuls: init at 0.27.0 (#348530)
[NixPkgs.git] / nixos / tests / frp.nix
blob717e8718721cec71a342357bb00495e2c8558355
1 import ./make-test-python.nix ({ pkgs, lib, ... }: {
2   name = "frp";
3   meta.maintainers = with lib.maintainers; [ zaldnoay ];
4   nodes = {
5     frps = {
6       networking = {
7         useNetworkd = true;
8         useDHCP = false;
9         firewall.enable = false;
10       };
12       systemd.network.networks."01-eth1" = {
13         name = "eth1";
14         networkConfig.Address = "10.0.0.1/24";
15       };
17       services.frp = {
18         enable = true;
19         role = "server";
20         settings = {
21           bindPort = 7000;
22           vhostHTTPPort = 80;
23         };
24       };
25     };
28     frpc = {
29       networking = {
30         useNetworkd = true;
31         useDHCP = false;
32       };
34       systemd.network.networks."01-eth1" = {
35         name = "eth1";
36         networkConfig.Address = "10.0.0.2/24";
37       };
39       services.httpd = {
40         enable = true;
41         adminAddr = "admin@example.com";
42         virtualHosts."test-appication" =
43         let
44           testdir = pkgs.writeTextDir "web/index.php" "<?php phpinfo();";
45         in
46         {
47           documentRoot = "${testdir}/web";
48           locations."/" = {
49             index = "index.php index.html";
50           };
51         };
52         phpPackage = pkgs.php81;
53         enablePHP = true;
54       };
56       services.frp = {
57         enable = true;
58         role = "client";
59         settings = {
60           serverAddr = "10.0.0.1";
61           serverPort = 7000;
62           proxies = [
63             {
64               name = "web";
65               type = "http";
66               localPort = 80;
67               customDomains = [ "10.0.0.1" ];
68             }
69           ];
70         };
71       };
72     };
73   };
75   testScript = ''
76     start_all()
77     frps.wait_for_unit("frp.service")
78     frps.wait_for_open_port(80)
79     frpc.wait_for_unit("frp.service")
80     response = frpc.succeed("curl -fvvv -s http://127.0.0.1/")
81     assert "PHP Version ${pkgs.php81.version}" in response, "PHP version not detected"
82     response = frpc.succeed("curl -fvvv -s http://10.0.0.1/")
83     assert "PHP Version ${pkgs.php81.version}" in response, "PHP version not detected"
84   '';