b1ddad2c99
* feat: update author and committer input defaults * Update github-actions[bot] * Update author to new email format * feat: optional input for git ops token * feat: allow push-to-fork to push to sibling repos (#2414) Fixes #2412. * build: update dist * feat: update action runtime to node 20 (#2340) * feat: add truncate warning to pull request body * perf: unshallow only when necessary * fix: remove the remote for the fork on completion * feat: infer github server and api urls * test: integration test fixes * build: bump major version * docs: update to v6 --------- Co-authored-by: Teko <112829523+Teko012@users.noreply.github.com> Co-authored-by: Benjamin Gilbert <bgilbert@backtick.net>
86 lines
2.6 KiB
TypeScript
86 lines
2.6 KiB
TypeScript
import {GitCommandManager} from '../lib/git-command-manager'
|
|
import {GitConfigHelper} from '../lib/git-config-helper'
|
|
|
|
const REPO_PATH = '/git/local/repos/test-base'
|
|
|
|
const extraheaderConfigKey = 'http.https://127.0.0.1/.extraheader'
|
|
|
|
describe('git-config-helper integration tests', () => {
|
|
let git: GitCommandManager
|
|
let gitConfigHelper: GitConfigHelper
|
|
|
|
beforeAll(async () => {
|
|
git = await GitCommandManager.create(REPO_PATH)
|
|
})
|
|
|
|
it('tests save and restore with no persisted auth', async () => {
|
|
const gitConfigHelper = await GitConfigHelper.create(git)
|
|
await gitConfigHelper.close()
|
|
})
|
|
|
|
it('tests configure and removal of auth', async () => {
|
|
const gitConfigHelper = await GitConfigHelper.create(git)
|
|
await gitConfigHelper.configureToken('github-token')
|
|
expect(await git.configExists(extraheaderConfigKey)).toBeTruthy()
|
|
expect(await git.getConfigValue(extraheaderConfigKey)).toEqual(
|
|
'AUTHORIZATION: basic eC1hY2Nlc3MtdG9rZW46Z2l0aHViLXRva2Vu'
|
|
)
|
|
|
|
await gitConfigHelper.close()
|
|
expect(await git.configExists(extraheaderConfigKey)).toBeFalsy()
|
|
})
|
|
|
|
it('tests save and restore of persisted auth', async () => {
|
|
const extraheaderConfigValue = 'AUTHORIZATION: basic ***persisted-auth***'
|
|
await git.config(extraheaderConfigKey, extraheaderConfigValue)
|
|
|
|
const gitConfigHelper = await GitConfigHelper.create(git)
|
|
|
|
const exists = await git.configExists(extraheaderConfigKey)
|
|
expect(exists).toBeFalsy()
|
|
|
|
await gitConfigHelper.close()
|
|
|
|
const configValue = await git.getConfigValue(extraheaderConfigKey)
|
|
expect(configValue).toEqual(extraheaderConfigValue)
|
|
|
|
const unset = await git.tryConfigUnset(
|
|
extraheaderConfigKey,
|
|
'^AUTHORIZATION:'
|
|
)
|
|
expect(unset).toBeTruthy()
|
|
})
|
|
|
|
it('tests not adding/removing the safe.directory config when it already exists', async () => {
|
|
await git.config('safe.directory', '/another-value', true, true)
|
|
|
|
const gitConfigHelper = await GitConfigHelper.create(git)
|
|
|
|
expect(
|
|
await git.configExists('safe.directory', '/another-value', true)
|
|
).toBeTruthy()
|
|
|
|
await gitConfigHelper.close()
|
|
|
|
const unset = await git.tryConfigUnset(
|
|
'safe.directory',
|
|
'/another-value',
|
|
true
|
|
)
|
|
expect(unset).toBeTruthy()
|
|
})
|
|
|
|
it('tests adding and removing the safe.directory config', async () => {
|
|
const gitConfigHelper = await GitConfigHelper.create(git)
|
|
|
|
expect(
|
|
await git.configExists('safe.directory', REPO_PATH, true)
|
|
).toBeTruthy()
|
|
|
|
await gitConfigHelper.close()
|
|
|
|
expect(
|
|
await git.configExists('safe.directory', REPO_PATH, true)
|
|
).toBeFalsy()
|
|
})
|
|
})
|