Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
Emyrk committed May 31, 2024
commit 85d1fde0b3647cdeb9df66c0b1cfcfbbc44372da
11 changes: 8 additions & 3 deletions coderd/externalauth/externalauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ func TestRefreshToken(t *testing.T) {
_, err := config.RefreshToken(context.Background(), nil, database.ExternalAuthLink{
OAuthExpiry: expired,
})
require.NoError(t, err)
require.Error(t, err)
require.True(t, externalauth.IsInvalidTokenError(err))
require.Contains(t, err.Error(), "failure")
})

t.Run("ValidateServerError", func(t *testing.T) {
Expand All @@ -132,7 +134,10 @@ func TestRefreshToken(t *testing.T) {

_, err := config.RefreshToken(ctx, nil, link)
require.ErrorContains(t, err, staticError)
require.True(t, externalauth.IsInvalidTokenError(err))
// Unsure if this should be the correct behavior. It's an invalid token because
// 'ValidateToken()' failed with a runtime error. This was the previous behavior,
// so not going to change it.
require.False(t, externalauth.IsInvalidTokenError(err))
require.True(t, validated, "token should have been attempted to be validated")
})

Expand All @@ -157,7 +162,7 @@ func TestRefreshToken(t *testing.T) {
link.OAuthExpiry = expired

_, err := config.RefreshToken(ctx, nil, link)
require.ErrorContains(t, err, staticError)
require.ErrorContains(t, err, "token failed to validate")
require.True(t, externalauth.IsInvalidTokenError(err))
require.True(t, validated, "token should have been attempted to be validated")
})
Expand Down