Skip to content

Commit 85d1fde

Browse files
committed
fix tests
1 parent 1dab79f commit 85d1fde

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

coderd/externalauth/externalauth_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ func TestRefreshToken(t *testing.T) {
108108
_, err := config.RefreshToken(context.Background(), nil, database.ExternalAuthLink{
109109
OAuthExpiry: expired,
110110
})
111-
require.NoError(t, err)
111+
require.Error(t, err)
112+
require.True(t, externalauth.IsInvalidTokenError(err))
113+
require.Contains(t, err.Error(), "failure")
112114
})
113115

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

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

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

159164
_, err := config.RefreshToken(ctx, nil, link)
160-
require.ErrorContains(t, err, staticError)
165+
require.ErrorContains(t, err, "token failed to validate")
161166
require.True(t, externalauth.IsInvalidTokenError(err))
162167
require.True(t, validated, "token should have been attempted to be validated")
163168
})

0 commit comments

Comments
 (0)