Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix header forwarding test #1263

Merged
merged 6 commits into from
Jan 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions nixops/logical.nix
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,23 @@ in
pkgs.lib.mkMerge
[ prelude

# Same as `prelude.dhall-lang.org` except requires a header named
# `Test` to be present to authorize requests. This is used to test
# support for header forwarding for the test suite.
{ locations."/".extraConfig = ''
if ($http_test = "") {
return 403;
}
'';
# This is used to test support for header forwarding for the
# test suite.
{ locations = {
"/foo".extraConfig = ''
if ($http_test = "") {
return 403;
}
Gabriella439 marked this conversation as resolved.
Show resolved Hide resolved
return 200 './bar';
'';

"/bar".extraConfig = ''
if ($http_test = "") {
return 403;
}
return 200 'True';
'';
};
}

# A random string to test caching behavior
Expand Down
14 changes: 5 additions & 9 deletions tests/import/success/headerForwardingA.dhall
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{- This test verifies that header-forwarding works correctly for relative
imports within the same domain

`test.dhall-lang.org` is the same as `prelude.dhall-lang.org` except that
`test.dhall-lang.org` rejects all requests without a `Test` header.
`test.dhall-lang.org/foo` returns `./bar` and `test.dhall-lang.org/foo`
returns `True`, and both URLs reject all requests without a `Test` header.

This test requires that the initial import to
`https://test.dhall-lang.org/Bool/package.dhall` forwards the `Test` header
to the transitive relative imports of `https://test.dhall-lang.org/Bool/*` in
`https://test.dhall-lang.org/foo` forwards the `Test` header
to the transitive relative import of `https://test.dhall-lang.org/bar` in
order to succeed.

Note: You will need to update this test whenever the `Bool` package in the
Prelude changes (sorry)
-}
https://test.dhall-lang.org/Bool/package.dhall
using [ { mapKey = "Test", mapValue = "Example" } ]
https://test.dhall-lang.org/foo using (toMap { Test = "Example" })
19 changes: 1 addition & 18 deletions tests/import/success/headerForwardingB.dhall
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
{ and =
λ(_ : List Bool) →
List/fold Bool _ Bool (λ(_ : Bool) → λ(_ : Bool) → _@1 && _) True
, build = λ(_ : Type → _ → _@1 → _@2) → _ Bool True False
, even =
λ(_ : List Bool) →
List/fold Bool _ Bool (λ(_ : Bool) → λ(_ : Bool) → _@1 == _) True
, fold =
λ(_ : Bool) → λ(_ : Type) → λ(_ : _) → λ(_ : _@1) → if _@3 then _@1 else _
, not = λ(_ : Bool) → _ == False
, odd =
λ(_ : List Bool) →
List/fold Bool _ Bool (λ(_ : Bool) → λ(_ : Bool) → _@1 != _) False
, or =
λ(_ : List Bool) →
List/fold Bool _ Bool (λ(_ : Bool) → λ(_ : Bool) → _@1 || _) False
, show = λ(_ : Bool) → if _ then "True" else "False"
}
True