Skip to content

Commit

Permalink
Basics of mock k2 server for test
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Jan 23, 2024
1 parent 5dffca3 commit 5c08f2b
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 26 deletions.
18 changes: 18 additions & 0 deletions modules/kolide-launcher/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ in
Initial autoupdater subprocess delay.
'';
};

insecureTransport = mkOption {
type = types.bool;
default = false;
description = ''
Do not use TLS for transport layer.
'';
};

insecureTLS = mkOption {
type = types.bool;
default = false;
description = ''
Do not verify TLS certs for outgoing connections.
'';
};
};

config = mkIf cfg.enable {
Expand All @@ -87,6 +103,8 @@ in
--enroll_secret_path ${cfg.enrollSecretDirectory}/secret \
--update_channel ${cfg.updateChannel} \
--transport jsonrpc \
--insecure ${cfg.insecureTLS} \
--insecure_transport ${cfg.insecureTransport} \
--autoupdate \
--autoupdate_interval ${cfg.autoupdateInterval} \
--autoupdater_initial_delay ${cfg.autoupdaterInitialDelay}
Expand Down
78 changes: 52 additions & 26 deletions tests/kolide-launcher.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,57 @@ in
pkgs.nixosTest {
name = "kolide-launcher";

nodes.machine = { config, pkgs, ... }: {
imports = [
flake.nixosModules.kolide-launcher
];

users.users.alice = {
isNormalUser = true;
description = "Alice Test";
password = "alicetest";
uid = 1000;
};
nodes = {
machine = { config, pkgs, ... }: {
imports = [
flake.nixosModules.kolide-launcher
];

users.users.alice = {
isNormalUser = true;
description = "Alice Test";
password = "alicetest";
uid = 1000;
};

services.xserver.enable = true;
services.xserver.displayManager = {
lightdm.enable = true;
autoLogin = {
enable = true;
user = "alice";
services.xserver.enable = true;
services.xserver.displayManager = {
lightdm.enable = true;
autoLogin = {
enable = true;
user = "alice";
};
};
};
services.xserver.desktopManager.mate.enable = true;
services.xserver.desktopManager.mate.debug = true;
services.xserver.desktopManager.mate.enable = true;
services.xserver.desktopManager.mate.debug = true;

# This just quiets some log spam we don't care about
hardware.pulseaudio.enable = true;

# This just quiets some log spam we don't care about
hardware.pulseaudio.enable = true;
services.kolide-launcher.enable = true;
services.kolide-launcher.kolideHostname = "app.kolide.test:80";
services.kolide-launcher.insecureTransport = true;
services.kolide-launcher.insecureTLS = true;

services.kolide-launcher.enable = true;
services.kolide-launcher.kolideHostname = "k2device-preprod.kolide.com";
system.stateVersion = "23.11";
};

system.stateVersion = "23.11";
k2server = { config, pkgs, ... }: {
networking.firewall.allowedTCPPorts = [ 80 ];

services.nginx = {
enable = true;
virtualHosts."app.kolide.test" = {
locations = {
"/" = {
return = ''200 "{}"'';
};
};
addSSL = false;
default = true;
};
};
};
};

enableOCR = true;
Expand All @@ -54,6 +75,11 @@ pkgs.nixosTest {
in
''
if "${ci}":
# Wait for mock k2 server to be online
k2server.start()
k2server.wait_for_unit("nginx.service")
# Start VM for test launcher installation
machine.start()
with subtest("log in to MATE"):
Expand Down Expand Up @@ -90,7 +116,7 @@ pkgs.nixosTest {
machine.wait_for_file("/var/kolide-k2/k2device.kolide.com/menu.json")
machine.screenshot("test-screen4.png")
with subtest("launcher doctor + flare"):
with subtest("launcher flare"):
_, launcher_find_stdout = machine.execute("ls /nix/store | grep kolide-launcher-")
machine.execute("/nix/store/" + launcher_find_stdout.strip() + "/bin/launcher flare --save local")
Expand Down

0 comments on commit 5c08f2b

Please sign in to comment.