Skip to content

Commit

Permalink
feat: create bad request case
Browse files Browse the repository at this point in the history
  • Loading branch information
1995parham committed Oct 23, 2024
1 parent adc6119 commit 16a454c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions internal/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,14 @@ func (suite *APITestSuite) TestToken() {
username string
action string
isSuperuser bool
sendHeader bool
}{
{username: "snapp-admin:" + token, action: "allow", isSuperuser: true},
{username: token, action: "allow", isSuperuser: true},
{username: "not-found:token", action: "deny", isSuperuser: false},
{username: "token", action: "deny", isSuperuser: false},
{username: "snapp-admin:token", action: "deny", isSuperuser: false},
{username: "snapp-admin:" + token, action: "allow", isSuperuser: true, sendHeader: true},
{username: token, action: "allow", isSuperuser: true, sendHeader: true},
{username: "not-found:token", action: "deny", isSuperuser: false, sendHeader: true},
{username: "token", action: "deny", isSuperuser: false, sendHeader: true},
{username: "snapp-admin:token", action: "deny", isSuperuser: false, sendHeader: true},
{username: "snapp-admin:" + token, action: "deny", isSuperuser: false, sendHeader: false},
}

for _, c := range cases {
Expand All @@ -179,7 +181,9 @@ func (suite *APITestSuite) TestToken() {
require.NoError(err)

req := httptest.NewRequest(http.MethodPost, "/v2/auth", bytes.NewReader(body))
req.Header.Add("Content-Type", "application/json")
if c.sendHeader {
req.Header.Add("Content-Type", "application/json")
}

resp, err := suite.app.Test(req)
require.NoError(err)
Expand Down

0 comments on commit 16a454c

Please sign in to comment.