From 76656098270ccdd90fbe87b79b60c444f35bed82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=E2=80=9CNiols=E2=80=9D=20Jeannerod?= Date: Fri, 20 Sep 2024 15:45:53 +0000 Subject: [PATCH] Use common options also in tests --- tests/mastodon-garage.nix | 7 +++---- tests/pixelfed-garage.nix | 10 ++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/mastodon-garage.nix b/tests/mastodon-garage.nix index c109ea18..672b70f4 100644 --- a/tests/mastodon-garage.nix +++ b/tests/mastodon-garage.nix @@ -57,7 +57,7 @@ pkgs.nixosTest { }; }; - testScript = '' + testScript = { nodes, ... }: '' import re import time @@ -95,8 +95,7 @@ pkgs.nixosTest { server.succeed("toot post --media $POST_MEDIA") with subtest("access garage"): - ## REVIEW: could we grab `config.fediversity.internal.garage.api.url` here in some way? - server.succeed("mc alias set garage http://s3.garage.localhost:3900 --api s3v4 --path off $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY") + server.succeed("mc alias set garage ${nodes.server.fediversity.internal.garage.api.url} --api s3v4 --path off $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY") server.succeed("mc ls garage/mastodon") with subtest("access image in garage"): @@ -122,7 +121,7 @@ pkgs.nixosTest { raise Exception("mastodon did not send a content security policy header") csp = csp_match.group(1) # the img-src content security policy should include the garage server - ## REVIEW: could we grab `config.fediversity.internal.garage.web.url` here in some way? + ## TODO: use `nodes.server.fediversity.internal.garage.api.url` same as above, but beware of escaping the regex. garage_csp = re.match(".*; img-src[^;]*web\.garage\.localhost:3902.*", csp) if garage_csp is None: raise Exception("Mastodon's content security policy does not include garage server. image will not be displayed properly on mastodon.") diff --git a/tests/pixelfed-garage.nix b/tests/pixelfed-garage.nix index 9bf2944e..b25bc66e 100644 --- a/tests/pixelfed-garage.nix +++ b/tests/pixelfed-garage.nix @@ -160,7 +160,7 @@ pkgs.nixosTest { }; }; - testScript = '' + testScript = { nodes, ... }: '' import re server.start() @@ -186,15 +186,14 @@ pkgs.nixosTest { raise Exception("cannot detect the uploaded image on pixelfed page.") with subtest("access garage"): - ## REVIEW: could we grab `config.fediversity.internal.garage.api.url` here in some way? - server.succeed("mc alias set garage http://s3.garage.localhost:3900 --api s3v4 --path off $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY") + server.succeed("mc alias set garage ${nodes.server.fediversity.internal.garage.api.url} --api s3v4 --path off $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY") server.succeed("mc ls garage/pixelfed") with subtest("access image in garage"): image = server.succeed("mc find garage --regex '\\.png' --ignore '*_thumb.png'") image = image.rstrip() if image == "": - raise Exception("image posted to mastodon did not get stored in garage") + raise Exception("image posted to Pixelfed did not get stored in garage") server.succeed(f"mc cat {image} >/garage-image.png") garage_image_hash = server.succeed("identify -quiet -format '%#' /garage-image.png") image_hash = server.succeed("identify -quiet -format '%#' $POST_MEDIA") @@ -203,8 +202,7 @@ pkgs.nixosTest { with subtest("Check that image comes from garage"): src = server.succeed("su - selenium -c 'selenium-script-get-src ${email} ${password}'") - ## REVIEW: could we grab `config.fediversity.internal.garage.web.url` here in some way? - if not src.startswith("http://pixelfed.web.garage.localhost:3902/"): + if not src.startswith("${nodes.server.fediversity.internal.garage.web.urlFor "pixelfed"}"): raise Exception("image does not come from garage") ''; }