Skip to content

Commit 49c813a

Browse files
committed
fix(auth): type the SSO token-auth selector against 1.7's config and the new test calls
1 parent 7293f7a commit 49c813a

6 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎apps/sim/app/(auth)/oauth/sign-in/route.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ describe('OAuth login bridge', () => {
6363
const response = await GET(
6464
request(
6565
'client_id=mcp-client&scope=api%3Aread&sim_resource=https%3A%2F%2Fsim.test%2Fapi%2Fmcp&sig=signed'
66-
)
66+
),
67+
{ params: Promise.resolve({}) }
6768
)
6869
const { callback } = redirectParts(response)
6970

‎apps/sim/app/api/auth/[...all]/route.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ describe('auth catch-all route email OTP sign-in', () => {
227227
'http://localhost:3000/api/auth/sign-in/email-otp'
228228
)
229229

230-
expect((await POST(req)).status).toBe(404)
230+
expect((await POST(req, { params: Promise.resolve({}) })).status).toBe(404)
231231
expect(handlerMocks.betterAuthPOST).not.toHaveBeenCalled()
232232
})
233233
})
@@ -242,7 +242,7 @@ describe('auth catch-all route legacy SAML ACS path', () => {
242242
body: form,
243243
})
244244

245-
const res = await POST(req)
245+
const res = await POST(req, { params: Promise.resolve({}) })
246246

247247
expect(res.status).toBe(302)
248248
const forwarded: Request = handlerMocks.betterAuthPOST.mock.calls[0][0]
@@ -260,7 +260,7 @@ describe('auth catch-all route legacy SAML ACS path', () => {
260260
headers: { cookie: 'session=1' },
261261
})
262262

263-
expect((await GET(req)).status).toBe(302)
263+
expect((await GET(req, { params: Promise.resolve({}) })).status).toBe(302)
264264
const forwarded: Request = handlerMocks.betterAuthGET.mock.calls[0][0]
265265
expect(new URL(forwarded.url).pathname).toBe('/api/auth/sso/saml2/sp/acs/acme-saml')
266266
expect(forwarded.headers.get('cookie')).toBe('session=1')

‎apps/sim/app/api/auth/oauth2/authorize/route.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ describe('OAuth2 authorize route', () => {
206206
expect(new URL(forwarded.url).searchParams.get('sim_resource')).toBe(`${BASE_URL}/api/mcp`)
207207
})
208208

209-
it.each([
209+
it.each<Record<string, string>>([
210210
{ sim_resource: `${BASE_URL}/api/mcp` },
211211
{ dpop_jkt: 'a'.repeat(43), resource: `${BASE_URL}/api/mcp` },
212212
])('refuses reserved or unsupported provider parameters: %o', async (extra) => {
@@ -219,7 +219,8 @@ describe('OAuth2 authorize route', () => {
219219
code_challenge: 'a'.repeat(43),
220220
code_challenge_method: 'S256',
221221
...extra,
222-
})
222+
}),
223+
{ params: Promise.resolve({}) }
223224
)
224225
expect(response.status).toBe(400)
225226
expect(mocks.betterAuthGET).not.toHaveBeenCalled()

‎apps/sim/app/api/auth/oauth2/register/route.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ describe('MCP public client registration', () => {
110110
{ status: 201 }
111111
)
112112
)
113-
const response = await POST(request({ ...client, scope: 'search:read offline_access' }))
113+
const response = await POST(request({ ...client, scope: 'search:read offline_access' }), {
114+
params: Promise.resolve({}),
115+
})
114116
expect(response.status).toBe(201)
115117
expect(await response.json()).toMatchObject({ scope: 'search:read offline_access' })
116118
expect(mocks.markPublic).toHaveBeenCalledWith('client-1', ['search:read', 'offline_access'])

‎apps/sim/lib/auth/sso/application/provider-registration.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ function trimTrailingSlashes(url: string): string {
6464
*/
6565
function selectTokenEndpointAuthMethod(
6666
supportedMethods: unknown,
67-
existing?: TokenEndpointAuthMethod
67+
existing?: string
6868
): TokenEndpointAuthMethod {
69-
if (existing) return existing
69+
if (existing === 'client_secret_basic' || existing === 'client_secret_post') return existing
7070
if (!Array.isArray(supportedMethods) || supportedMethods.length === 0) {
7171
return 'client_secret_post'
7272
}

‎apps/sim/lib/oauth/oauth.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ describe('connector callbacks without an account link', () => {
5252
it('yields no profile when the OAuth state does not come from /link-social', async () => {
5353
mockGetOAuthState.mockResolvedValue({ callbackURL: '/' })
5454
const fetchMock = createMockFetch({ json: { account_id: 'account-123' } })
55+
const getUserInfo = getBitbucketConnector().getUserInfo
56+
if (!getUserInfo) throw new Error('Bitbucket connector must define getUserInfo')
5557

5658
const profile = await withMockFetch(fetchMock, () =>
57-
getBitbucketConnector().getUserInfo?.(
58-
getOAuth2Tokens({ access_token: 'bitbucket_access_token' })
59-
)
59+
getUserInfo(getOAuth2Tokens({ access_token: 'bitbucket_access_token' }))
6060
)
6161

6262
expect(profile).toBeNull()

0 commit comments

Comments
 (0)