nixpkgs/nixos/tests/gns3-server.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.8 KiB
Nix
Raw Normal View History

2023-10-22 21:04:25 +00:00
import ./make-test-python.nix (
{ pkgs, lib, ... }:
{
name = "gns3-server";
meta.maintainers = [ lib.maintainers.anthonyroussel ];
nodes.machine =
{ ... }:
let
tls-cert = pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -days 365 \
-subj '/CN=localhost'
install -D -t $out key.pem cert.pem
'';
in
{
services.gns3-server = {
enable = true;
auth = {
2023-10-22 21:04:25 +00:00
enable = true;
user = "user";
passwordFile = pkgs.writeText "gns3-auth-password-file" "password";
};
ssl = {
2023-10-22 21:04:25 +00:00
enable = true;
certFile = "${tls-cert}/cert.pem";
keyFile = "${tls-cert}/key.pem";
};
2023-10-22 21:04:25 +00:00
dynamips.enable = true;
ubridge.enable = true;
vpcs.enable = true;
};
security.pki.certificateFiles = [ "${tls-cert}/cert.pem" ];
};
testScript =
let
createProject = pkgs.writeText "createProject.json" (
builtins.toJSON {
name = "test_project";
}
);
in
''
start_all()
machine.wait_for_unit("gns3-server.service")
machine.wait_for_open_port(3080)
with subtest("server is listening"):
machine.succeed("curl -sSfL -u user:password https://localhost:3080/v2/version")
with subtest("create dummy project"):
machine.succeed("curl -sSfL -u user:password https://localhost:3080/v2/projects -d @${createProject}")
with subtest("logging works"):
log_path = "/var/log/gns3/server.log"
machine.wait_for_file(log_path)
'';
}
)