Skip to content

Commit

Permalink
failing tests for auth middleware
Browse files Browse the repository at this point in the history
Signed-off-by: Arnav Gupta <[email protected]>
  • Loading branch information
championswimmer committed Nov 5, 2023
1 parent 34dbf74 commit eac007d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/routes/api/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ func TestUsersRoute_RegisterUserDuplicateFail(t *testing.T) {
assert.Equal(t, 409, resp.StatusCode)
}

func TestUsersRoute_GetUserInfoUnauthorized(t *testing.T) {
req := httptest.NewRequest("GET", "/api/v1/users/1", nil)
resp := lo.Must(app.Test(req))
assert.Equal(t, 401, resp.StatusCode)
}

func TestUsersRoute_GetUserInfoUnauthorizedInvalidJWT(t *testing.T) {
req := httptest.NewRequest("GET", "/api/v1/users/1", nil)
req.Header.Set("Authorization", "xxxxxxxx")
resp := lo.Must(app.Test(req))
assert.Equal(t, 401, resp.StatusCode)
}

func TestUsersRoute_GetUserInfo(t *testing.T) {
req := httptest.NewRequest("GET", "/api/v1/users/1", nil)
jwt := auth.CreateJWTFromUser(&models.User{ID: 1})
Expand Down

0 comments on commit eac007d

Please sign in to comment.