core/pkgs/build-support/fetchurl/tests.nix

26 lines
553 B
Nix
Raw Normal View History

2024-06-30 08:12:46 +00:00
{
testers,
fetchurl,
jq,
moreutils,
...
}:
{
2024-05-02 00:46:19 +00:00
# Tests that we can send custom headers with spaces in them
header =
2024-06-30 08:12:46 +00:00
let
headerValue = "Test '\" <- These are some quotes";
in
testers.invalidateFetcherByDrvHash fetchurl {
2024-05-02 00:46:19 +00:00
url = "https://httpbin.org/headers";
sha256 = builtins.hashString "sha256" (headerValue + "\n");
2024-06-30 08:12:46 +00:00
curlOptsList = [
"-H"
"Hello: ${headerValue}"
];
2024-05-02 00:46:19 +00:00
postFetch = ''
${jq}/bin/jq -r '.headers.Hello' $out | ${moreutils}/bin/sponge $out
'';
};
}