fix: refresh all oauth links on external auth page (#11646)

* fix: refresh all oauth links on external auth page
This commit is contained in:
Steven Masley
2024-01-16 11:03:55 -06:00
committed by GitHub
parent d583acad00
commit 08b4eb3124
5 changed files with 85 additions and 11 deletions
+4
View File
@@ -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")
+11
View File
@@ -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 {