feat: carry suggested third-party profile through pending oauth
This commit is contained in:
40
backend/internal/handler/auth_oauth_pending_flow_test.go
Normal file
40
backend/internal/handler/auth_oauth_pending_flow_test.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestApplySuggestedProfileToCompletionResponse(t *testing.T) {
|
||||
payload := map[string]any{
|
||||
"access_token": "token",
|
||||
}
|
||||
upstream := map[string]any{
|
||||
"suggested_display_name": "Alice",
|
||||
"suggested_avatar_url": "https://cdn.example/avatar.png",
|
||||
}
|
||||
|
||||
applySuggestedProfileToCompletionResponse(payload, upstream)
|
||||
|
||||
require.Equal(t, "Alice", payload["suggested_display_name"])
|
||||
require.Equal(t, "https://cdn.example/avatar.png", payload["suggested_avatar_url"])
|
||||
require.Equal(t, true, payload["adoption_required"])
|
||||
}
|
||||
|
||||
func TestApplySuggestedProfileToCompletionResponseKeepsExistingPayloadValues(t *testing.T) {
|
||||
payload := map[string]any{
|
||||
"suggested_display_name": "Existing",
|
||||
"adoption_required": false,
|
||||
}
|
||||
upstream := map[string]any{
|
||||
"suggested_display_name": "Alice",
|
||||
"suggested_avatar_url": "https://cdn.example/avatar.png",
|
||||
}
|
||||
|
||||
applySuggestedProfileToCompletionResponse(payload, upstream)
|
||||
|
||||
require.Equal(t, "Existing", payload["suggested_display_name"])
|
||||
require.Equal(t, "https://cdn.example/avatar.png", payload["suggested_avatar_url"])
|
||||
require.Equal(t, true, payload["adoption_required"])
|
||||
}
|
||||
Reference in New Issue
Block a user