Skip to content

Commit e68fdbf

Browse files
committed
Correct unit tests
1 parent 7ad069e commit e68fdbf

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

coderd/coderd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ func New(options *Options) (http.Handler, func()) {
293293
r.Route("/workspaces/{workspace}", func(r chi.Router) {
294294
r.Use(
295295
apiKeyMiddleware,
296+
authRolesMiddleware,
296297
httpmw.ExtractWorkspaceParam(options.Database),
297298
)
298299
r.Get("/", api.workspace)

coderd/organizations_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ func TestOrganizationByUserAndName(t *testing.T) {
3030
_, err := client.OrganizationByName(context.Background(), codersdk.Me, "nothing")
3131
var apiErr *codersdk.Error
3232
require.ErrorAs(t, err, &apiErr)
33-
require.Equal(t, http.StatusNotFound, apiErr.StatusCode())
33+
require.Equal(t, http.StatusForbidden, apiErr.StatusCode())
3434
})
3535

3636
t.Run("NoMember", func(t *testing.T) {
3737
t.Parallel()
3838
client := coderdtest.New(t, nil)
3939
first := coderdtest.CreateFirstUser(t, client)
4040
other := coderdtest.CreateAnotherUser(t, client, first.OrganizationID)
41-
org, err := other.CreateOrganization(context.Background(), codersdk.Me, codersdk.CreateOrganizationRequest{
41+
org, err := client.CreateOrganization(context.Background(), codersdk.Me, codersdk.CreateOrganizationRequest{
4242
Name: "another",
4343
})
4444
require.NoError(t, err)
45-
_, err = client.OrganizationByName(context.Background(), codersdk.Me, org.Name)
45+
_, err = other.OrganizationByName(context.Background(), codersdk.Me, org.Name)
4646
var apiErr *codersdk.Error
4747
require.ErrorAs(t, err, &apiErr)
48-
require.Equal(t, http.StatusUnauthorized, apiErr.StatusCode())
48+
require.Equal(t, http.StatusForbidden, apiErr.StatusCode())
4949
})
5050

5151
t.Run("Valid", func(t *testing.T) {

coderd/users_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func TestPostUsers(t *testing.T) {
187187
})
188188
var apiErr *codersdk.Error
189189
require.ErrorAs(t, err, &apiErr)
190-
require.Equal(t, http.StatusUnauthorized, apiErr.StatusCode())
190+
require.Equal(t, http.StatusForbidden, apiErr.StatusCode())
191191
})
192192

193193
t.Run("Create", func(t *testing.T) {

coderd/workspaces_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func TestWorkspaceByOwnerAndName(t *testing.T) {
158158
_, err := client.WorkspaceByOwnerAndName(context.Background(), user.OrganizationID, codersdk.Me, "something")
159159
var apiErr *codersdk.Error
160160
require.ErrorAs(t, err, &apiErr)
161-
require.Equal(t, http.StatusNotFound, apiErr.StatusCode())
161+
require.Equal(t, http.StatusForbidden, apiErr.StatusCode())
162162
})
163163
t.Run("Get", func(t *testing.T) {
164164
t.Parallel()

0 commit comments

Comments
 (0)