Change tests to expect new error format from pkg golang.org/x/oauth2

This commit is contained in:
Ryan Richard 2023-05-10 16:52:09 -07:00
parent bc9afc4554
commit 1e6e9e0c0e

View File

@ -1739,8 +1739,7 @@ func TestSupervisorLogin_Browser(t *testing.T) {
env.SupervisorUpstreamLDAP.TestUserPassword // password to present to server during login env.SupervisorUpstreamLDAP.TestUserPassword // password to present to server during login
}, },
requestAuthorization: requestAuthorizationUsingBrowserAuthcodeFlowLDAP, requestAuthorization: requestAuthorizationUsingBrowserAuthcodeFlowLDAP,
wantAuthcodeExchangeError: "oauth2: cannot fetch token: 401 Unauthorized\n" + wantAuthcodeExchangeError: `oauth2: "invalid_client" "Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method)."`,
`Response: {"error":"invalid_client","error_description":"Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method)."}`,
}, },
} }
@ -2239,12 +2238,7 @@ func testSupervisorLogin(
_, err = downstreamOAuth2Config.TokenSource(oidcHTTPClientContext, &oauth2.Token{RefreshToken: latestRefreshToken}).Token() _, err = downstreamOAuth2Config.TokenSource(oidcHTTPClientContext, &oauth2.Token{RefreshToken: latestRefreshToken}).Token()
// Should have got an error since the upstream refresh should have failed. // Should have got an error since the upstream refresh should have failed.
require.Error(t, err) require.Error(t, err)
require.Regexp(t, require.EqualError(t, err, `oauth2: "error" "Error during upstream refresh. Upstream refresh failed."`)
regexp.QuoteMeta("oauth2: cannot fetch token: 401 Unauthorized\n")+
regexp.QuoteMeta(`Response: {"error":"error","error_description":"Error during upstream refresh. Upstream refresh failed`)+
"[^']+",
err.Error(),
)
} }
} }