Skip to content

Commit

Permalink
chore: extra cover on higher level test
Browse files Browse the repository at this point in the history
  • Loading branch information
papey committed Oct 30, 2024
1 parent 3b76695 commit 8916fab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions neurow/test/jwt_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ defmodule JwtHelper do
conn |> put_req_header(header_key, "Bearer #{jwt_token}")
end

def put_jwt_token_in_req_header_internal_api(conn, issuer \\ "test_issuer1") do
def put_jwt_token_in_req_header_internal_api(conn, issuer \\ "test_issuer1", header_key \\ "authorization") do
conn
|> put_req_header(
"authorization",
header_key,
"Bearer #{compute_jwt_token_in_req_header_internal_api(issuer)}"
)
|> put_req_header("content-type", "application/json")
Expand Down
15 changes: 14 additions & 1 deletion neurow/test/neurow/internal_api/endpoint_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Neurow.InternalApi.EndpointTest do
assert call.status == 200
end

test "other routes requires a JWT token" do
test "other routes requires a JWT sent in authorization header" do
conn = conn(:get, "/foo")
call = Neurow.InternalApi.Endpoint.call(conn, [])
assert call.status == 403
Expand All @@ -31,6 +31,19 @@ defmodule Neurow.InternalApi.EndpointTest do
assert call.status == 404
end

test "other routes requires a JWT sent in x-interservice-authorization header" do
conn = conn(:get, "/foo")
call = Neurow.InternalApi.Endpoint.call(conn, [])
assert call.status == 403

conn =
conn(:get, "/foo")
|> put_jwt_token_in_req_header_internal_api("test_issuer1", "x-interservice-authorization")

call = Neurow.InternalApi.Endpoint.call(conn, [])
assert call.status == 404
end

describe "POST /v1/subscribe" do
test "returns a 403 if called without a JWT token" do
body =
Expand Down

0 comments on commit 8916fab

Please sign in to comment.