Skip to content

Commit 9372502

Browse files
committed
Add unit tests
1 parent c6fef46 commit 9372502

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

coderd/httpmw/organizationparam_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,5 +208,24 @@ func TestOrganizationParam(t *testing.T) {
208208
res = rw.Result()
209209
defer res.Body.Close()
210210
require.Equal(t, http.StatusOK, res.StatusCode, "by name")
211+
212+
// Try by 'default'
213+
chi.RouteContext(r.Context()).URLParams.Add("organization", codersdk.DefaultOrganization)
214+
chi.RouteContext(r.Context()).URLParams.Add("user", user.ID.String())
215+
rtr.ServeHTTP(rw, r)
216+
res = rw.Result()
217+
defer res.Body.Close()
218+
require.Equal(t, http.StatusOK, res.StatusCode, "by default keyword")
219+
220+
// Try by legacy
221+
// TODO: This can be removed when legacy nil uuids are no longer supported.
222+
// This is a temporary measure to ensure as legacy provisioners use
223+
// nil uuids as the org id and expect the default org.
224+
chi.RouteContext(r.Context()).URLParams.Add("organization", uuid.Nil.String())
225+
chi.RouteContext(r.Context()).URLParams.Add("user", user.ID.String())
226+
rtr.ServeHTTP(rw, r)
227+
res = rw.Result()
228+
defer res.Body.Close()
229+
require.Equal(t, http.StatusOK, res.StatusCode, "by default keyword")
211230
})
212231
}

0 commit comments

Comments
 (0)