Pin Vercel OAuth callback team parameter name
The Vercel connector reads the team from the camelCase teamId callback parameter, unlike the snake_case params most providers use. Nothing guarded the name, so a regression back to team_id would silently drop the team on every Vercel connect and leave the source resolving no users. Extract the read into vercelCallbackTeamID and pin the exact parameter name with a test, since the surrounding handler needs a live connector registry and database to exercise directly. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
69
pkg/server/api/console/v1/resolver_test.go
Normal file
69
pkg/server/api/console/v1/resolver_test.go
Normal file
@@ -0,0 +1,69 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
package console_v1
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// TestVercelCallbackTeamID pins the exact OAuth-callback query-parameter name
|
||||
// Vercel uses. It is camelCase `teamId`; a regression to the snake_case
|
||||
// `team_id` used by most other providers would silently drop the team on every
|
||||
// Vercel connect and leave the source resolving nobody.
|
||||
func TestVercelCallbackTeamID(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
query url.Values
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "camelCase teamId is read",
|
||||
query: url.Values{"teamId": {"team_abc123"}},
|
||||
want: "team_abc123",
|
||||
},
|
||||
{
|
||||
name: "snake_case team_id is ignored",
|
||||
query: url.Values{"team_id": {"team_abc123"}},
|
||||
want: "",
|
||||
},
|
||||
{
|
||||
name: "absent parameter yields empty",
|
||||
query: url.Values{},
|
||||
want: "",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(
|
||||
tc.name,
|
||||
func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
assert.Equal(t, tc.want, vercelCallbackTeamID(tc.query))
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user