about summary refs log tree commit diff
path: root/pkgs/build-support/fetchurl
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2022-06-30 19:49:54 +0200
committerSilvan Mosberger <contact@infinisil.com>2022-06-30 19:49:54 +0200
commit588439e1311c41a5779877d4d8ef603410b79cd4 (patch)
tree512cda1a52284704386066b821fb8f683b217313 /pkgs/build-support/fetchurl
parentb404704911f2e3d078d5d0287006bbe263167202 (diff)
fetchurl: Add curlOptsList test
Diffstat (limited to 'pkgs/build-support/fetchurl')
-rw-r--r--pkgs/build-support/fetchurl/tests.nix13
1 files changed, 13 insertions, 0 deletions
diff --git a/pkgs/build-support/fetchurl/tests.nix b/pkgs/build-support/fetchurl/tests.nix
new file mode 100644
index 0000000000000..fc7fb25e158ff
--- /dev/null
+++ b/pkgs/build-support/fetchurl/tests.nix
@@ -0,0 +1,13 @@
+{ invalidateFetcherByDrvHash, fetchurl, jq, moreutils, ... }: {
+  # Tests that we can send custom headers with spaces in them
+  header =
+    let headerValue = "Test '\" <- These are some quotes";
+    in invalidateFetcherByDrvHash fetchurl {
+      url = "https://httpbin.org/headers";
+      sha256 = builtins.hashString "sha256" (headerValue + "\n");
+      curlOptsList = [ "-H" "Hello: ${headerValue}" ];
+      postFetch = ''
+        ${jq}/bin/jq -r '.headers.Hello' $out | ${moreutils}/bin/sponge $out
+      '';
+    };
+}