Skip to content

Commit 7964c11

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
test(monday): exercise OAuth link route
1 parent 6b1dff6 commit 7964c11

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { createMockFetch, resetEnvMock, setEnv } from '@sim/testing'
2-
import { createAuthorizationURL, getOAuth2Tokens } from 'better-auth/oauth2'
2+
import { getOAuth2Tokens } from 'better-auth/oauth2'
3+
import { genericOAuth } from 'better-auth/plugins'
4+
import { getTestInstance } from 'better-auth/test'
35
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
46

57
beforeAll(() => {
@@ -180,21 +182,19 @@ describe('Monday OAuth connector', () => {
180182
redirectURI: 'http://localhost:3000/api/auth/oauth2/callback/monday',
181183
authorizationUrlParams: { force_install_if_needed: 'true' },
182184
})
183-
const authorizationUrl = await createAuthorizationURL({
184-
id: connector.providerId,
185-
options: {
186-
clientId: connector.clientId,
187-
clientSecret: connector.clientSecret,
188-
redirectURI: connector.redirectURI,
185+
const { auth, signInWithTestUser } = await getTestInstance({
186+
baseURL: 'http://localhost:3000',
187+
plugins: [genericOAuth({ config: [connector] })],
188+
})
189+
const { headers } = await signInWithTestUser()
190+
const { url } = await auth.api.oAuth2LinkAccount({
191+
body: {
192+
providerId: connector.providerId,
193+
callbackURL: 'http://localhost:3000/workspace',
189194
},
190-
authorizationEndpoint: connector.authorizationUrl!,
191-
state: 'state-1',
192-
codeVerifier: 'a'.repeat(128),
193-
scopes: connector.scopes,
194-
redirectURI: connector.redirectURI!,
195-
responseType: connector.responseType,
196-
additionalParams: connector.authorizationUrlParams,
195+
headers,
197196
})
197+
const authorizationUrl = new URL(url)
198198

199199
expect(authorizationUrl.searchParams.get('redirect_uri')).toBe(
200200
'http://localhost:3000/api/auth/oauth2/callback/monday'

0 commit comments

Comments
 (0)