nixos/tests/sharkey: init

This commit is contained in:
Ruby Iris Juric 2025-05-28 14:39:51 +10:00
parent 11d8fbb0b6
commit 01971a6323
No known key found for this signature in database
3 changed files with 59 additions and 0 deletions

View File

@ -1277,6 +1277,7 @@ in
sgt-puzzles = runTest ./sgt-puzzles.nix;
shadow = runTest ./shadow.nix;
shadowsocks = handleTest ./shadowsocks { };
sharkey = runTest ./web-apps/sharkey.nix;
shattered-pixel-dungeon = runTest ./shattered-pixel-dungeon.nix;
shiori = runTest ./shiori.nix;
signal-desktop = runTest ./signal-desktop.nix;

View File

@ -0,0 +1,55 @@
{ lib, ... }:
let
meilisearchKey = "TESTKEY-naXRkVX7nhvLaGOmGGuicDKxZAj0khEaoOZPeEZafv8w9j8V6aKb0NVdXRChL5kR";
in
{
name = "sharkey";
nodes.machine =
{ pkgs, ... }:
{
services.sharkey = {
enable = true;
setupMeilisearch = true;
environmentFiles = [ "/run/secrets/sharkey-env" ];
settings = {
url = "http://exampleurl.invalid";
meilisearch.index = "exampleurl_invalid";
};
};
services.meilisearch.masterKeyEnvironmentFile = pkgs.writeText "meilisearch-key" ''
MEILI_MASTER_KEY=${meilisearchKey}
'';
};
testScript =
let
createIndexPayload = builtins.toJSON {
description = "Sharkey API key";
actions = [ "*" ];
indexes = [ "exampleurl_invalid---notes" ];
expiresAt = null;
};
in
''
import json
with subtest("Setting up Meilisearch API key and index"):
machine.wait_for_unit("meilisearch.service")
machine.wait_for_open_port(7700)
json_body = '${createIndexPayload}'
create_index_result = json.loads(machine.succeed(f"curl -s -X POST 'http://localhost:7700/keys' -H 'Content-Type: application/json' -H 'Authorization: Bearer ${meilisearchKey}' --data-binary '{json_body}'"))
machine.succeed(f"mkdir /run/secrets; echo 'MK_CONFIG_MEILISEARCH_APIKEY={create_index_result["key"]}' > /run/secrets/sharkey-env")
with subtest("Testing Sharkey is running and listening to HTTP requests"):
machine.systemctl("restart sharkey")
machine.wait_for_open_port(3000)
machine.succeed("curl --fail http://localhost:3000")
'';
meta.maintainers = with lib.maintainers; [ srxl ];
}

View File

@ -2,6 +2,7 @@
stdenv,
lib,
fetchFromGitLab,
nixosTests,
bash,
cairo,
cctools,
@ -151,6 +152,8 @@ stdenv.mkDerivation (finalAttrs: {
runHook postFixup
'';
passthru.tests.sharkey = nixosTests.sharkey;
meta = {
description = "Sharkish microblogging platform";
homepage = "https://joinsharkey.org";