fix: always attempt external auth refresh when fetching (#11762)

* fix: always attempt external auth refresh when fetching
* refactor validate to check expiry when considering "valid"
This commit is contained in:
Steven Masley
2024-01-25 10:54:56 -06:00
committed by GitHub
parent fd7f85bc5e
commit 0befc0826a
6 changed files with 148 additions and 99 deletions

View File

@ -1577,7 +1577,7 @@ func TestWorkspaceAgentExternalAuthListen(t *testing.T) {
},
ExternalAuthConfigs: []*externalauth.Config{
fake.ExternalAuthConfig(t, providerID, nil, func(cfg *externalauth.Config) {
cfg.Type = codersdk.EnhancedExternalAuthProviderGitHub.String()
cfg.Type = codersdk.EnhancedExternalAuthProviderGitLab.String()
}),
},
})
@ -1623,7 +1623,8 @@ func TestWorkspaceAgentExternalAuthListen(t *testing.T) {
ticks <- time.Now()
}
cancel()
// We expect only 1
// We expect only 1. One from the initial "Refresh" attempt, and the
// other should be skipped.
// In a failed test, you will likely see 9, as the last one
// gets canceled.
require.Equal(t, 1, validateCalls, "validate calls duplicated on same token")