Commit 45487322 authored by IanShaw027's avatar IanShaw027
Browse files

test(auth): strengthen pending oauth legacy token assertions

parent 18481a10
...@@ -746,7 +746,11 @@ func TestExchangePendingOAuthCompletionExistingLoginWithSuggestedProfileSkipsAdo ...@@ -746,7 +746,11 @@ func TestExchangePendingOAuthCompletionExistingLoginWithSuggestedProfileSkipsAdo
}). }).
SetLocalFlowState(map[string]any{ SetLocalFlowState(map[string]any{
oauthCompletionResponseKey: map[string]any{ oauthCompletionResponseKey: map[string]any{
"redirect": "/dashboard", "access_token": "legacy-access-token",
"refresh_token": "legacy-refresh-token",
"expires_in": float64(3600),
"token_type": "Bearer",
"redirect": "/dashboard",
}, },
}). }).
SetExpiresAt(time.Now().UTC().Add(10 * time.Minute)). SetExpiresAt(time.Now().UTC().Add(10 * time.Minute)).
...@@ -767,6 +771,8 @@ func TestExchangePendingOAuthCompletionExistingLoginWithSuggestedProfileSkipsAdo ...@@ -767,6 +771,8 @@ func TestExchangePendingOAuthCompletionExistingLoginWithSuggestedProfileSkipsAdo
payload := decodeJSONResponseData(t, recorder) payload := decodeJSONResponseData(t, recorder)
require.NotEmpty(t, payload["access_token"]) require.NotEmpty(t, payload["access_token"])
require.NotEmpty(t, payload["refresh_token"]) require.NotEmpty(t, payload["refresh_token"])
require.NotEqual(t, "legacy-access-token", payload["access_token"])
require.NotEqual(t, "legacy-refresh-token", payload["refresh_token"])
require.Equal(t, "/dashboard", payload["redirect"]) require.Equal(t, "/dashboard", payload["redirect"])
require.Equal(t, "Existing Login Example", payload["suggested_display_name"]) require.Equal(t, "Existing Login Example", payload["suggested_display_name"])
require.Equal(t, "https://cdn.example/existing-login.png", payload["suggested_avatar_url"]) require.Equal(t, "https://cdn.example/existing-login.png", payload["suggested_avatar_url"])
...@@ -781,6 +787,14 @@ func TestExchangePendingOAuthCompletionExistingLoginWithSuggestedProfileSkipsAdo ...@@ -781,6 +787,14 @@ func TestExchangePendingOAuthCompletionExistingLoginWithSuggestedProfileSkipsAdo
storedSession, err := client.PendingAuthSession.Get(ctx, session.ID) storedSession, err := client.PendingAuthSession.Get(ctx, session.ID)
require.NoError(t, err) require.NoError(t, err)
require.NotNil(t, storedSession.ConsumedAt) require.NotNil(t, storedSession.ConsumedAt)
completion, ok := storedSession.LocalFlowState[oauthCompletionResponseKey].(map[string]any)
require.True(t, ok)
require.NotContains(t, completion, "access_token")
require.NotContains(t, completion, "refresh_token")
require.NotContains(t, completion, "expires_in")
require.NotContains(t, completion, "token_type")
require.Equal(t, "/dashboard", completion["redirect"])
} }
func TestExchangePendingOAuthCompletionBlocksBackendModeBeforeReturningTokenPayload(t *testing.T) { func TestExchangePendingOAuthCompletionBlocksBackendModeBeforeReturningTokenPayload(t *testing.T) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment