From dab12bc2b84604599ff446efc721207815a0688f Mon Sep 17 00:00:00 2001 From: Taeer Bar-Yam Date: Thu, 18 Jul 2024 06:44:13 -0400 Subject: [PATCH] interactive test is working --- garage.nix | 33 ++++++----- tests/fediversity.png | Bin 5640 -> 0 bytes tests/green.png | Bin 0 -> 692 bytes tests/mastodon-garage.nix | 112 +++++++++++++++++++++++++++++++------- 4 files changed, 110 insertions(+), 35 deletions(-) delete mode 100644 tests/fediversity.png create mode 100644 tests/green.png diff --git a/garage.nix b/garage.nix index 2c47ec9..3de3709 100644 --- a/garage.nix +++ b/garage.nix @@ -38,7 +38,8 @@ let ${optionalString corsRules.enable '' garage bucket allow --read --write --owner ${bucketArg} --key tmp - aws --endpoint http://s3.garage.localhost:3900 s3api put-bucket-cors --bucket ${bucketArg} --cors-configuration ${corsRulesJSON} + # TODO: endpoin-url should not be hard-coded + aws --region ${cfg.settings.s3_api.s3_region} --endpoint-url http://s3.garage.localhost:3900 s3api put-bucket-cors --bucket ${bucketArg} --cors-configuration ${corsRulesJSON} garage bucket deny --read --write --owner ${bucketArg} --key tmp ''} ''; @@ -124,21 +125,23 @@ in { }; config = { - virtualisation.diskSize = 2048; - virtualisation.forwardPorts = [ - { - from = "host"; - host.port = 3901; - guest.port = 3901; - } - { - from = "host"; - host.port = 3902; - guest.port = 3902; - } - ]; + virtualisation.vmVariant = { config, ... }: { + virtualisation.diskSize = 2048; + virtualisation.forwardPorts = [ + { + from = "host"; + host.port = 3901; + guest.port = 3901; + } + { + from = "host"; + host.port = 3902; + guest.port = 3902; + } + ]; - environment.systemPackages = [ pkgs.minio-client pkgs.awscli ]; + environment.systemPackages = [ pkgs.minio-client pkgs.awscli ]; + }; networking.firewall.allowedTCPPorts = [ 3901 3902 ]; services.garage = { diff --git a/tests/fediversity.png b/tests/fediversity.png deleted file mode 100644 index 24881fb4a0321f00a18d2c85d5859f9a04f6a108..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5640 zcmV+j7We5=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%3xSse~{^hrBywv-yN`Ox*(2s8&qg$FhLW52AZmrJ#k!AJ7#3$iP zWhNk<=uIrgYZ9XPaw$&bQIQ}QgOqGjTUXXJ?a9awR3vk7abGxHo1=l5f7m%oou!+t#+)ggGYH6*qOoJr4yS z*xAw7)(2Q4NF{F`S9Y3&&9PuV1qA22`zDvoS^ILw7_|1C7zPliaCsyX52LQMpg$^P+Rn!Wp}{FAT~y@OsBjdR zh4&OS!|@So4U?~}m8w&Lfv#$)^@;2O!9*&Ttxlq%tsQ zOst(~>v7mY=4gEI)FyDur-tbz04*HocC+S89@oxckAa4;~y( zx_aWz+zt0pHY`u^sW|G(k&^b<=b zWHa~3d|u(u{N~re{}0Nyhb0yr^5#-+I46Gmrv$6hZimIsEbbrgyKKSObpF89d!NEz z9XO-@a_clPTPC(`joq)OEqlW_-TJ_V$%?Z#X|rZ>wK9FEbGtu$-Mja0uRm|{`!}Q1>7wQtOSe1$Mhj~XOJv$jVN)>&&^HED`9XhN=++J%E?Kp-qUngH$fOokq}0s z4w$jjVH%hbqySU{6w#ajQXIKS/garage-image.webp") + garage_image_hash = server.succeed("identify -quiet -format '%#' /garage-image.webp") + image_hash = server.succeed("identify -quiet -format '%#' $POST_MEDIA") + assert garage_image_hash == image_hash + + with subtest("Content security policy allows garage images"): + headers = server.succeed("xh -h http://masstodon.localhost:55001/public/local") + csp_match = re.match('^Content-Security-Policy: (.*)$', headers, re.M) + assert csp_match is not None + csp = csp_match.group(1) + # the content security policy should include the garage server + garage_csp = re.match(".*web\.garage\.localhost:3902.*", csp) + assert garage_csp is not None + + with subtest("image displays"): + server.succeed("selenium-script") + server.copy_from_vm("/mastodon-screenshot.png", "") + displayed_colors = server.succeed("convert /mastodon-screenshot.png -define histogram:unique-colors=true -format %c histogram:info:") + # check that the green image displayed somewhere + re.match(".*#00FF00.*", displayed_colors, re.S) ''; }