Files
accounted/extensions/general/zettle/__tests__/oauth.test.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

30 lines
1.1 KiB
TypeScript

import { describe, it, expect, beforeEach, afterEach } from 'vitest'
import { buildAuthorizeUrl, ZETTLE_OAUTH_SCOPES } from '../lib/oauth'
describe('zettle oauth', () => {
const env = { ...process.env }
beforeEach(() => {
process.env.ZETTLE_CLIENT_ID = 'client-123'
process.env.ZETTLE_CLIENT_SECRET = 'secret-456'
process.env.ZETTLE_CREDENTIALS_ENCRYPTION_KEY = 'enc-key'
process.env.NEXT_PUBLIC_APP_URL = 'https://app.example.com'
})
afterEach(() => {
process.env = { ...env }
})
it('builds the authorize URL with purchase + userinfo scopes', () => {
const url = new URL(buildAuthorizeUrl('state-abc'))
expect(url.origin + url.pathname).toBe('https://oauth.zettle.com/authorize')
expect(url.searchParams.get('response_type')).toBe('code')
expect(url.searchParams.get('client_id')).toBe('client-123')
expect(url.searchParams.get('state')).toBe('state-abc')
expect(url.searchParams.get('scope')).toBe(ZETTLE_OAUTH_SCOPES)
expect(url.searchParams.get('redirect_uri')).toBe(
'https://app.example.com/api/extensions/zettle/callback',
)
})
})