summaryrefslogtreecommitdiff
path: root/tests/FundLab.Api.Tests/ApiTests.fs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/FundLab.Api.Tests/ApiTests.fs')
-rw-r--r--tests/FundLab.Api.Tests/ApiTests.fs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/FundLab.Api.Tests/ApiTests.fs b/tests/FundLab.Api.Tests/ApiTests.fs
new file mode 100644
index 0000000..a46d330
--- /dev/null
+++ b/tests/FundLab.Api.Tests/ApiTests.fs
@@ -0,0 +1,24 @@
+namespace FundLab.Api.Tests
+
+module ApiTests =
+
+ open Xunit
+ open FundLab.Api
+
+ [<Theory>]
+ [<InlineData("")>]
+ [<InlineData("Basic secret")>]
+ [<InlineData("Bearer wrong")>]
+ let ``missing or wrong bearer token is unauthorized`` header =
+ Assert.Equal(AuthDecision.Unauthorized, Authentication.authorize "secret" header)
+
+ [<Fact>]
+ let ``matching bearer token is authorized`` () =
+ Assert.Equal(AuthDecision.Authorized, Authentication.authorize "secret" "Bearer secret")
+
+ [<Fact>]
+ let ``health payload is non-sensitive`` () =
+ let payload = Health.payload "fund-lab-api"
+
+ Assert.Contains("\"status\":\"ok\"", payload)
+ Assert.DoesNotContain("secret", payload)