at 22.05-pre 3.0 kB view raw
1import ../make-test-python.nix { 2 name = "prosody-mysql"; 3 4 nodes = { 5 client = { nodes, pkgs, ... }: { 6 environment.systemPackages = [ 7 (pkgs.callPackage ./xmpp-sendmessage.nix { connectTo = nodes.server.config.networking.primaryIPAddress; }) 8 ]; 9 networking.extraHosts = '' 10 ${nodes.server.config.networking.primaryIPAddress} example.com 11 ${nodes.server.config.networking.primaryIPAddress} conference.example.com 12 ${nodes.server.config.networking.primaryIPAddress} uploads.example.com 13 ''; 14 }; 15 server = { config, pkgs, ... }: { 16 nixpkgs.overlays = [ 17 (self: super: { 18 prosody = super.prosody.override { 19 withDBI = true; 20 withExtraLibs = [ pkgs.luaPackages.luadbi-mysql ]; 21 }; 22 }) 23 ]; 24 networking.extraHosts = '' 25 ${config.networking.primaryIPAddress} example.com 26 ${config.networking.primaryIPAddress} conference.example.com 27 ${config.networking.primaryIPAddress} uploads.example.com 28 ''; 29 networking.firewall.enable = false; 30 services.prosody = { 31 enable = true; 32 # TODO: use a self-signed certificate 33 c2sRequireEncryption = false; 34 extraConfig = '' 35 storage = "sql" 36 sql = { 37 driver = "MySQL"; 38 database = "prosody"; 39 host = "mysql"; 40 port = 3306; 41 username = "prosody"; 42 password = "password123"; 43 }; 44 ''; 45 virtualHosts.test = { 46 domain = "example.com"; 47 enabled = true; 48 }; 49 muc = [ 50 { 51 domain = "conference.example.com"; 52 } 53 ]; 54 uploadHttp = { 55 domain = "uploads.example.com"; 56 }; 57 }; 58 }; 59 mysql = { config, pkgs, ... }: { 60 networking.firewall.enable = false; 61 services.mysql = { 62 enable = true; 63 initialScript = pkgs.writeText "mysql_init.sql" '' 64 CREATE DATABASE prosody; 65 CREATE USER 'prosody'@'server' IDENTIFIED BY 'password123'; 66 GRANT ALL PRIVILEGES ON prosody.* TO 'prosody'@'server'; 67 FLUSH PRIVILEGES; 68 ''; 69 package = pkgs.mariadb; 70 }; 71 }; 72 }; 73 74 testScript = { nodes, ... }: '' 75 mysql.wait_for_unit("mysql.service") 76 server.wait_for_unit("prosody.service") 77 server.succeed('prosodyctl status | grep "Prosody is running"') 78 79 # set password to 'nothunter2' (it's asked twice) 80 server.succeed("yes nothunter2 | prosodyctl adduser cthon98@example.com") 81 # set password to 'y' 82 server.succeed("yes | prosodyctl adduser azurediamond@example.com") 83 # correct password to 'hunter2' 84 server.succeed("yes hunter2 | prosodyctl passwd azurediamond@example.com") 85 86 client.succeed("send-message") 87 88 server.succeed("prosodyctl deluser cthon98@example.com") 89 server.succeed("prosodyctl deluser azurediamond@example.com") 90 ''; 91} 92