diff options
author | Tomas Antonio Lopez <entropy.overseer@entropic.network> | 2023-12-03 00:34:14 +0100 |
---|---|---|
committer | Tomas Antonio Lopez <entropy.overseer@entropic.network> | 2023-12-19 01:43:19 +0100 |
commit | effb6bd756dfff8c88d635f346415cea6f4ddf96 (patch) | |
tree | 0f0e9d12794efbe5194f200b6417bdd240f915f5 /nixos/tests/sourcehut | |
parent | 89278c9846a88d51ec00b0b1f044070deb93a79f (diff) |
nixosTests.sourcehut: configure Hut for direct API interaction
Diffstat (limited to 'nixos/tests/sourcehut')
-rw-r--r-- | nixos/tests/sourcehut/sourcehut.nix | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/nixos/tests/sourcehut/sourcehut.nix b/nixos/tests/sourcehut/sourcehut.nix index 20885efdfed0f..58a9c3262a73e 100644 --- a/nixos/tests/sourcehut/sourcehut.nix +++ b/nixos/tests/sourcehut/sourcehut.nix @@ -121,6 +121,7 @@ in }; environment.systemPackages = with pkgs; [ + hut # For interacting with the Sourcehut APIs via CLI (callPackage ./srht-gen-oauth-tok.nix { }) # To automatically generate OAuth tokens ]; }; @@ -129,6 +130,12 @@ in let userName = "nixos-test"; userPass = "AutoNixosTestPwd"; + hutConfig = pkgs.writeText "hut-config" '' + instance "${domain}" { + # Will be replaced at runtime with the generated token + access-token "OAUTH-TOKEN" + } + ''; in '' start_all() @@ -148,7 +155,9 @@ in ## Obtain a OAuth token to be used for querying APIs directly (_, token) = machine.execute("srht-gen-oauth-tok -i ${domain} -q ${userName} ${userPass}") - print(token) + token = token.strip().replace("/", r"\\/") # Escape slashes in token before passing it to sed + machine.execute("mkdir -p ~/.config/hut/") + machine.execute("sed s/OAUTH-TOKEN/" + token + "/ ${hutConfig} > ~/.config/hut/config") # Testing buildsrht machine.wait_for_unit("buildsrht.service") |