mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: refresh all oauth links on external auth page (#11646)
* fix: refresh all oauth links on external auth page
This commit is contained in:
@@ -336,6 +336,10 @@ func ExpectJSONMime(res *http.Response) error {
|
||||
|
||||
// ReadBodyAsError reads the response as a codersdk.Response, and
|
||||
// wraps it in a codersdk.Error type for easy marshaling.
|
||||
//
|
||||
// This will always return an error, so only call it if the response failed
|
||||
// your expectations. Usually via status code checking.
|
||||
// nolint:staticcheck
|
||||
func ReadBodyAsError(res *http.Response) error {
|
||||
if res == nil {
|
||||
return xerrors.Errorf("no body returned")
|
||||
|
||||
@@ -283,6 +283,17 @@ func Test_readBodyAsError(t *testing.T) {
|
||||
assert.Equal(t, unexpectedJSON, sdkErr.Response.Detail)
|
||||
},
|
||||
},
|
||||
{
|
||||
// Even status code 200 should be considered an error if this function
|
||||
// is called. There are parts of the code that require this function
|
||||
// to always return an error.
|
||||
name: "OKResp",
|
||||
req: nil,
|
||||
res: newResponse(http.StatusOK, jsonCT, marshal(map[string]any{})),
|
||||
assert: func(t *testing.T, err error) {
|
||||
require.Error(t, err)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range tests {
|
||||
|
||||
Reference in New Issue
Block a user