Skip to content

Commit

Permalink
fixup! Change 404 errors for aliases to 403s
Browse files Browse the repository at this point in the history
  • Loading branch information
talanknight committed Mar 26, 2024
1 parent b37e872 commit 3c5bfe8
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions internal/tests/api/targets/target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,13 +675,23 @@ func TestCrud(t *testing.T) {

_, err = tarClient.Delete(tc.Context(), c.id)
assert.NoError(err)
}

_, err = tarClient.Delete(tc.Context(), c.id)
t.Run("deleting unknown target is not found", func(t *testing.T) {
_, err = tarClient.Delete(tc.Context(), tar.Item.Id)
assert.Error(err)
apiErr := api.AsServerError(err)
assert.NotNil(apiErr)
assert.EqualValues(http.StatusNotFound, apiErr.Response().StatusCode())
}
})

t.Run("deleting unknown alias is forbidden", func(t *testing.T) {
_, err = tarClient.Delete(tc.Context(), al.GetValue())
assert.Error(err)
apiErr := api.AsServerError(err)
assert.NotNil(apiErr)
assert.EqualValues(http.StatusForbidden, apiErr.Response().StatusCode())
})
}

func TestSet_Errors(t *testing.T) {
Expand Down Expand Up @@ -739,7 +749,7 @@ func TestSet_Errors(t *testing.T) {
require.Error(err)
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
assert.EqualValues(http.StatusNotFound, apiErr.Response().StatusCode())
assert.EqualValues(http.StatusForbidden, apiErr.Response().StatusCode())

// reading by alias with no destination id should fail
rw := db.New(tc.DbConn())
Expand All @@ -748,7 +758,7 @@ func TestSet_Errors(t *testing.T) {
require.Error(err)
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
assert.EqualValues(http.StatusNotFound, apiErr.Response().StatusCode())
assert.EqualValues(http.StatusForbidden, apiErr.Response().StatusCode())
}

func TestCreateTarget_WhitespaceInAddress(t *testing.T) {
Expand Down

0 comments on commit 3c5bfe8

Please sign in to comment.