Skip to content

Commit

Permalink
fix(backend): Allow unauthorized requests to the Game Manifest API
Browse files Browse the repository at this point in the history
  • Loading branch information
barnslig committed Feb 5, 2022
1 parent d38b9b7 commit 81d8b84
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions backend/dpt_app/trails/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def inner(request: HttpRequest, *args, **kwargs):
request.player = request.game.player.get(bearer=bearer)

return func(request, *args, **kwargs)
except Player.DoesNotExist:
except (KeyError, Player.DoesNotExist):
raise PlayerNotAuthorized()

return inner
Expand All @@ -159,7 +159,6 @@ def serialize_game(game: Game):

@api.get("games/{str:gameId}", response=GameSchema, url_name="gameManifest")
@wrap_get_game
@wrap_get_player
def get_game(request: HttpRequest, gameId: str):
return serialize_game(request.game)

Expand Down
18 changes: 18 additions & 0 deletions backend/dpt_app/trails/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,24 @@ def test_game_clock_duration_when_value_zero(self):
self.assertEqual(self.param.value_at(duration_when_zero), 0)


class GameApiTest(GameTestCase):
def test_get(self):
url = reverse("api-1.0.0:gameManifest", args=(self.game.slug,))
res = self.client.get(url)

self.assertEqual(res.status_code, 200)
self.assertEqual(res.json(), {
"data": {
"type": "game",
"id": self.game.slug,
"attributes": {
"hasMessages": self.game.hasMessages,
"hasUserParameterScope": self.game.hasUserParameterScope
}
}
})


class PlayerApiTest(GameTestCase):
def test_put(self):
bearer = "Bearer test54321"
Expand Down

0 comments on commit 81d8b84

Please sign in to comment.