mirror of
https://github.com/complexcaresolutions/cms.c2sgmbh.git
synced 2026-03-18 00:24:10 +00:00
feat(youtube): add upload and analytics OAuth scopes
Add youtube.upload and yt-analytics.readonly scopes to enable video uploading and analytics data retrieval in the YouTube Operations Hub. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2718dea356
commit
097bc5225c
2 changed files with 77 additions and 0 deletions
|
|
@ -10,6 +10,8 @@ const SCOPES = [
|
||||||
'https://www.googleapis.com/auth/youtube.readonly',
|
'https://www.googleapis.com/auth/youtube.readonly',
|
||||||
'https://www.googleapis.com/auth/youtube.force-ssl',
|
'https://www.googleapis.com/auth/youtube.force-ssl',
|
||||||
'https://www.googleapis.com/auth/youtube',
|
'https://www.googleapis.com/auth/youtube',
|
||||||
|
'https://www.googleapis.com/auth/youtube.upload',
|
||||||
|
'https://www.googleapis.com/auth/yt-analytics.readonly',
|
||||||
]
|
]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
75
tests/unit/youtube/oauth-scopes.unit.spec.ts
Normal file
75
tests/unit/youtube/oauth-scopes.unit.spec.ts
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
/**
|
||||||
|
* YouTube OAuth Scopes Unit Tests
|
||||||
|
*
|
||||||
|
* Verifies that all required OAuth scopes are present in the YouTube OAuth configuration,
|
||||||
|
* including upload and analytics scopes needed for the YouTube Operations Hub.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { describe, it, expect, vi } from 'vitest'
|
||||||
|
|
||||||
|
vi.mock('googleapis', () => {
|
||||||
|
class MockOAuth2 {
|
||||||
|
generateAuthUrl({ scope }: { scope: string[] }): string {
|
||||||
|
return `https://accounts.google.com/o/oauth2/v2/auth?scope=${encodeURIComponent(scope.join(' '))}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
google: {
|
||||||
|
auth: {
|
||||||
|
OAuth2: MockOAuth2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
vi.stubEnv('YOUTUBE_CLIENT_ID', 'test-client-id')
|
||||||
|
vi.stubEnv('YOUTUBE_CLIENT_SECRET', 'test-client-secret')
|
||||||
|
vi.stubEnv('YOUTUBE_REDIRECT_URI', 'https://test.example.com/api/youtube/callback')
|
||||||
|
|
||||||
|
describe('YouTube OAuth Scopes', () => {
|
||||||
|
it('should include youtube.readonly scope', async () => {
|
||||||
|
vi.resetModules()
|
||||||
|
const { getAuthUrl } = await import('@/lib/integrations/youtube/oauth')
|
||||||
|
const url = getAuthUrl()
|
||||||
|
expect(url).toContain('youtube.readonly')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should include youtube.force-ssl scope', async () => {
|
||||||
|
vi.resetModules()
|
||||||
|
const { getAuthUrl } = await import('@/lib/integrations/youtube/oauth')
|
||||||
|
const url = getAuthUrl()
|
||||||
|
expect(url).toContain('youtube.force-ssl')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should include youtube scope (full access)', async () => {
|
||||||
|
vi.resetModules()
|
||||||
|
const { getAuthUrl } = await import('@/lib/integrations/youtube/oauth')
|
||||||
|
const url = getAuthUrl()
|
||||||
|
expect(url).toContain('auth%2Fyoutube')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should include youtube.upload scope', async () => {
|
||||||
|
vi.resetModules()
|
||||||
|
const { getAuthUrl } = await import('@/lib/integrations/youtube/oauth')
|
||||||
|
const url = getAuthUrl()
|
||||||
|
expect(url).toContain('youtube.upload')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should include yt-analytics.readonly scope', async () => {
|
||||||
|
vi.resetModules()
|
||||||
|
const { getAuthUrl } = await import('@/lib/integrations/youtube/oauth')
|
||||||
|
const url = getAuthUrl()
|
||||||
|
expect(url).toContain('yt-analytics.readonly')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should contain exactly 5 scopes', async () => {
|
||||||
|
vi.resetModules()
|
||||||
|
const { getAuthUrl } = await import('@/lib/integrations/youtube/oauth')
|
||||||
|
const url = getAuthUrl()
|
||||||
|
const decodedUrl = decodeURIComponent(url)
|
||||||
|
const scopeParam = decodedUrl.split('scope=')[1]
|
||||||
|
const scopes = scopeParam.split(' ')
|
||||||
|
expect(scopes).toHaveLength(5)
|
||||||
|
})
|
||||||
|
})
|
||||||
Loading…
Reference in a new issue