Sources: accept login:password Basic credential for Gitea (API + git store)
This commit is contained in:
+9
-1
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { Engine, key, type Assessor, type Executor, type OutboundMessage, type Trigger } from '../src/core/index.ts'
|
||||
import { KV } from '../src/kv.ts'
|
||||
import { GiteaConfigSchema, apply, giteaKind, giteaThreadContext, pollRound } from '../src/sources/gitea.ts'
|
||||
import { giteaClient, GiteaApiError } from '../src/sources/gitea-api.ts'
|
||||
import { giteaAuthorization, giteaClient, GiteaApiError } from '../src/sources/gitea-api.ts'
|
||||
import { SOURCE, issueTrigger } from '../src/sources/gitea-trigger.ts'
|
||||
import { giteaLink, sendGitea } from '../src/sources/gitea-channel.ts'
|
||||
import { SourceRegistry } from '../src/sources/registry.ts'
|
||||
@@ -70,6 +70,14 @@ const issue = (number: number, over: Record<string, unknown> = {}): Record<strin
|
||||
const triggerOf = (meta: Record<string, unknown>): Trigger => ({ id: 't', source: SOURCE, threads: [{ source: SOURCE, id: '12' }],
|
||||
actor: { source: SOURCE, id: 'alice' }, human: true, at: '2026-09-08T00:00:00Z', text: '', meta })
|
||||
|
||||
describe('giteaAuthorization', () => {
|
||||
it('sends a value with a colon as HTTP Basic and a token as token auth', () => {
|
||||
expect(giteaAuthorization('bot:secret:1')).toBe(`Basic ${Buffer.from('bot:secret:1', 'utf8').toString('base64')}`)
|
||||
expect(giteaAuthorization('0123456789abcdef0123456789abcdef01234567')).toBe('token 0123456789abcdef0123456789abcdef01234567')
|
||||
expect(giteaAuthorization('glpat-abc_123')).toBe('token glpat-abc_123')
|
||||
})
|
||||
})
|
||||
|
||||
describe('GiteaConfigSchema', () => {
|
||||
it('defaults a bare config to a safe baseline', () => {
|
||||
expect(GiteaConfigSchema.parse({})).toEqual({
|
||||
|
||||
Reference in New Issue
Block a user