summaryrefslogtreecommitdiff
path: root/tests/FundLab.Api.Tests/ApiTests.fs
blob: a46d3305bee3c5ac4e1181b50dbc090b12d3a7b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)