nixos/movim: move to runTest
This commit is contained in:
		
							parent
							
								
									d00a5703d9
								
							
						
					
					
						commit
						585b1bbffa
					
				@ -803,7 +803,7 @@ in
 | 
			
		||||
  morty = handleTest ./morty.nix { };
 | 
			
		||||
  mosquitto = handleTest ./mosquitto.nix { };
 | 
			
		||||
  moosefs = handleTest ./moosefs.nix { };
 | 
			
		||||
  movim = discoverTests (import ./web-apps/movim { inherit handleTestOn; });
 | 
			
		||||
  movim = import ./web-apps/movim { inherit recurseIntoAttrs runTest; };
 | 
			
		||||
  mpd = handleTest ./mpd.nix { };
 | 
			
		||||
  mpv = handleTest ./mpv.nix { };
 | 
			
		||||
  mtp = handleTest ./mtp.nix { };
 | 
			
		||||
 | 
			
		||||
@ -1,15 +1,5 @@
 | 
			
		||||
{
 | 
			
		||||
  system ? builtins.currentSystem,
 | 
			
		||||
  handleTestOn,
 | 
			
		||||
}:
 | 
			
		||||
{ recurseIntoAttrs, runTest }:
 | 
			
		||||
 | 
			
		||||
let
 | 
			
		||||
  supportedSystems = [
 | 
			
		||||
    "x86_64-linux"
 | 
			
		||||
    "i686-linux"
 | 
			
		||||
    "aarch64-linux"
 | 
			
		||||
  ];
 | 
			
		||||
in
 | 
			
		||||
{
 | 
			
		||||
  prosody-nginx = handleTestOn supportedSystems ./prosody-nginx.nix { inherit system; };
 | 
			
		||||
recurseIntoAttrs {
 | 
			
		||||
  prosody-nginx = runTest ./prosody-nginx.nix;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,110 +1,115 @@
 | 
			
		||||
import ../../make-test-python.nix (
 | 
			
		||||
  { lib, pkgs, ... }:
 | 
			
		||||
{ lib, ... }:
 | 
			
		||||
 | 
			
		||||
  let
 | 
			
		||||
    movim = {
 | 
			
		||||
      domain = "movim.local";
 | 
			
		||||
      info = "No ToS in tests";
 | 
			
		||||
      description = "NixOS testing server";
 | 
			
		||||
let
 | 
			
		||||
  movim = {
 | 
			
		||||
    domain = "movim.local";
 | 
			
		||||
    port = 8080;
 | 
			
		||||
    info = "No ToS in tests";
 | 
			
		||||
    description = "NixOS testing server";
 | 
			
		||||
  };
 | 
			
		||||
  prosody = {
 | 
			
		||||
    domain = "prosody.local";
 | 
			
		||||
    admin = rec {
 | 
			
		||||
      JID = "${username}@${prosody.domain}";
 | 
			
		||||
      username = "romeo";
 | 
			
		||||
      password = "juliet";
 | 
			
		||||
    };
 | 
			
		||||
    prosody = {
 | 
			
		||||
      domain = "prosody.local";
 | 
			
		||||
      admin = rec {
 | 
			
		||||
        JID = "${username}@${prosody.domain}";
 | 
			
		||||
        username = "romeo";
 | 
			
		||||
        password = "juliet";
 | 
			
		||||
      };
 | 
			
		||||
    };
 | 
			
		||||
  in
 | 
			
		||||
  {
 | 
			
		||||
    name = "movim-prosody-nginx";
 | 
			
		||||
  };
 | 
			
		||||
in
 | 
			
		||||
{
 | 
			
		||||
  name = "movim-prosody-nginx";
 | 
			
		||||
 | 
			
		||||
    meta = {
 | 
			
		||||
      maintainers = with pkgs.lib.maintainers; [ toastal ];
 | 
			
		||||
    };
 | 
			
		||||
  meta = {
 | 
			
		||||
    maintainers = with lib.maintainers; [ toastal ];
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
    nodes = {
 | 
			
		||||
      server =
 | 
			
		||||
        { pkgs, ... }:
 | 
			
		||||
        {
 | 
			
		||||
          services.movim = {
 | 
			
		||||
            inherit (movim) domain;
 | 
			
		||||
            enable = true;
 | 
			
		||||
            verbose = true;
 | 
			
		||||
            podConfig = {
 | 
			
		||||
              inherit (movim) description info;
 | 
			
		||||
              xmppdomain = prosody.domain;
 | 
			
		||||
            };
 | 
			
		||||
            nginx = { };
 | 
			
		||||
  nodes = {
 | 
			
		||||
    server =
 | 
			
		||||
      { pkgs, ... }:
 | 
			
		||||
      {
 | 
			
		||||
        environment.systemPackages = [
 | 
			
		||||
          # For testing
 | 
			
		||||
          pkgs.websocat
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        services.movim = {
 | 
			
		||||
          inherit (movim) domain port;
 | 
			
		||||
          enable = true;
 | 
			
		||||
          verbose = true;
 | 
			
		||||
          podConfig = {
 | 
			
		||||
            inherit (movim) description info;
 | 
			
		||||
            xmppdomain = prosody.domain;
 | 
			
		||||
          };
 | 
			
		||||
          nginx = { };
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
          services.prosody = {
 | 
			
		||||
            enable = true;
 | 
			
		||||
            xmppComplianceSuite = false;
 | 
			
		||||
            disco_items = [
 | 
			
		||||
              {
 | 
			
		||||
                url = "upload.${prosody.domain}";
 | 
			
		||||
                description = "File Uploads";
 | 
			
		||||
              }
 | 
			
		||||
            ];
 | 
			
		||||
            virtualHosts."${prosody.domain}" = {
 | 
			
		||||
              inherit (prosody) domain;
 | 
			
		||||
              enabled = true;
 | 
			
		||||
              extraConfig = ''
 | 
			
		||||
                Component "pubsub.${prosody.domain}" "pubsub"
 | 
			
		||||
                    pubsub_max_items = 10000
 | 
			
		||||
                    expose_publisher = true
 | 
			
		||||
 | 
			
		||||
                Component "upload.${prosody.domain}" "http_file_share"
 | 
			
		||||
                    http_external_url = "http://upload.${prosody.domain}"
 | 
			
		||||
                    http_file_share_expires_after = 300 * 24 * 60 * 60
 | 
			
		||||
                    http_file_share_size_limit = 1024 * 1024 * 1024
 | 
			
		||||
                    http_file_share_daily_quota = 4 * 1024 * 1024 * 1024
 | 
			
		||||
              '';
 | 
			
		||||
            };
 | 
			
		||||
        services.prosody = {
 | 
			
		||||
          enable = true;
 | 
			
		||||
          xmppComplianceSuite = false;
 | 
			
		||||
          disco_items = [
 | 
			
		||||
            {
 | 
			
		||||
              url = "upload.${prosody.domain}";
 | 
			
		||||
              description = "File Uploads";
 | 
			
		||||
            }
 | 
			
		||||
          ];
 | 
			
		||||
          virtualHosts."${prosody.domain}" = {
 | 
			
		||||
            inherit (prosody) domain;
 | 
			
		||||
            enabled = true;
 | 
			
		||||
            extraConfig = ''
 | 
			
		||||
              pep_max_items = 10000
 | 
			
		||||
              Component "pubsub.${prosody.domain}" "pubsub"
 | 
			
		||||
                  pubsub_max_items = 10000
 | 
			
		||||
                  expose_publisher = true
 | 
			
		||||
 | 
			
		||||
              http_paths = {
 | 
			
		||||
                  file_share = "/";
 | 
			
		||||
              }
 | 
			
		||||
              Component "upload.${prosody.domain}" "http_file_share"
 | 
			
		||||
                  http_external_url = "http://upload.${prosody.domain}"
 | 
			
		||||
                  http_file_share_expires_after = 300 * 24 * 60 * 60
 | 
			
		||||
                  http_file_share_size_limit = 1024 * 1024 * 1024
 | 
			
		||||
                  http_file_share_daily_quota = 4 * 1024 * 1024 * 1024
 | 
			
		||||
            '';
 | 
			
		||||
          };
 | 
			
		||||
          extraConfig = ''
 | 
			
		||||
            pep_max_items = 10000
 | 
			
		||||
 | 
			
		||||
          networking.extraHosts = ''
 | 
			
		||||
            127.0.0.1 ${movim.domain}
 | 
			
		||||
            127.0.0.1 ${prosody.domain}
 | 
			
		||||
            http_paths = {
 | 
			
		||||
                file_share = "/";
 | 
			
		||||
            }
 | 
			
		||||
          '';
 | 
			
		||||
        };
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    testScript = # python
 | 
			
		||||
      ''
 | 
			
		||||
        server.wait_for_unit("phpfpm-movim.service")
 | 
			
		||||
        server.wait_for_unit("nginx.service")
 | 
			
		||||
        server.wait_for_open_port(80)
 | 
			
		||||
        networking.extraHosts = ''
 | 
			
		||||
          127.0.0.1 ${movim.domain}
 | 
			
		||||
          127.0.0.1 ${prosody.domain}
 | 
			
		||||
        '';
 | 
			
		||||
      };
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
        server.wait_for_unit("prosody.service")
 | 
			
		||||
        server.succeed('prosodyctl status | grep "Prosody is running"')
 | 
			
		||||
        server.succeed("prosodyctl register ${prosody.admin.username} ${prosody.domain} ${prosody.admin.password}")
 | 
			
		||||
  testScript = # python
 | 
			
		||||
    ''
 | 
			
		||||
      server.wait_for_unit("phpfpm-movim.service")
 | 
			
		||||
      server.wait_for_unit("nginx.service")
 | 
			
		||||
      server.wait_for_open_port(${builtins.toString movim.port})
 | 
			
		||||
      server.wait_for_open_port(80)
 | 
			
		||||
 | 
			
		||||
        server.wait_for_unit("movim.service")
 | 
			
		||||
      server.wait_for_unit("prosody.service")
 | 
			
		||||
      server.succeed('prosodyctl status | grep "Prosody is running"')
 | 
			
		||||
      server.succeed("prosodyctl register ${prosody.admin.username} ${prosody.domain} ${prosody.admin.password}")
 | 
			
		||||
 | 
			
		||||
        # Test unauthenticated
 | 
			
		||||
        server.fail("curl -L --fail-with-body --max-redirs 0 http://${movim.domain}/chat")
 | 
			
		||||
      server.wait_for_unit("movim.service")
 | 
			
		||||
 | 
			
		||||
        # Test basic Websocket
 | 
			
		||||
        server.succeed("echo \"\" | ${lib.getExe pkgs.websocat} 'ws://${movim.domain}/ws/?path=login&offset=0' --origin 'http://${movim.domain}'")
 | 
			
		||||
      # Test unauthenticated
 | 
			
		||||
      server.fail("curl -L --fail-with-body --max-redirs 0 http://${movim.domain}/chat")
 | 
			
		||||
 | 
			
		||||
        # Test login + create cookiejar
 | 
			
		||||
        login_html = server.succeed("curl --fail-with-body -c /tmp/cookies http://${movim.domain}/login")
 | 
			
		||||
        assert "${movim.description}" in login_html
 | 
			
		||||
        assert "${movim.info}" in login_html
 | 
			
		||||
      # Test basic Websocket
 | 
			
		||||
      server.succeed("echo | websocat --origin 'http://${movim.domain}' 'ws://${movim.domain}/ws/?path=login&offset=0'")
 | 
			
		||||
 | 
			
		||||
        # Test authentication POST
 | 
			
		||||
        server.succeed("curl --fail-with-body -b /tmp/cookies -X POST --data-urlencode 'username=${prosody.admin.JID}' --data-urlencode 'password=${prosody.admin.password}' http://${movim.domain}/login")
 | 
			
		||||
      # Test login + create cookiejar
 | 
			
		||||
      login_html = server.succeed("curl --fail-with-body -c /tmp/cookies http://${movim.domain}/login")
 | 
			
		||||
      assert "${movim.description}" in login_html
 | 
			
		||||
      assert "${movim.info}" in login_html
 | 
			
		||||
 | 
			
		||||
        server.succeed("curl -L --fail-with-body --max-redirs 1 -b /tmp/cookies http://${movim.domain}/chat")
 | 
			
		||||
      '';
 | 
			
		||||
  }
 | 
			
		||||
)
 | 
			
		||||
      # Test authentication POST
 | 
			
		||||
      server.succeed("curl --fail-with-body -b /tmp/cookies -X POST --data-urlencode 'username=${prosody.admin.JID}' --data-urlencode 'password=${prosody.admin.password}' http://${movim.domain}/login")
 | 
			
		||||
 | 
			
		||||
      server.succeed("curl -L --fail-with-body --max-redirs 1 -b /tmp/cookies http://${movim.domain}/chat")
 | 
			
		||||
    '';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user