mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
Add skip SSH host key verification and fix self-hosted server support (#121)
* Add SSH host key verification with automatic trust and SCP-style URL support * Fix TypeScript errors for SSH host key schema and test mocks
This commit is contained in:
1 parent
677ce748cd
commit
7341dce1ef
25 files changed
+203
-123
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { fetchGitHubUserInfo, findGitHubCredential, resolveGitIdentity, createGitIdentityEnv } from '../../src/utils/git-auth'
|
||||
import type { GitCredential } from '../../src/utils/git-auth'
|
||||
import type { GitCredential } from '@opencode-manager/shared'
|
||||
|
||||
describe('fetchGitHubUserInfo', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -148,22 +148,19 @@ describe('SSH Key Cleanup', () => {
|
||||
await writeTemporarySSHKey(key2, 'test-cleanup-2')
|
||||
|
||||
await cleanupAllSSHKeys()
|
||||
|
||||
const keysDir = join(getWorkspacePath(), '.ssh-keys')
|
||||
await expect(fs.access(keysDir)).rejects.toThrow()
|
||||
})
|
||||
|
||||
it('should handle cleanup of non-existent file gracefully', async () => {
|
||||
const nonExistentPath = '/tmp/non-existent-ssh-key-12345'
|
||||
|
||||
await expect(cleanupSSHKey(nonExistentPath)).resolves.not.toThrow()
|
||||
})
|
||||
it('should handle cleanup of non-existent file gracefully', async () => {
|
||||
const nonExistentPath = '/tmp/non-existent-ssh-key-12345'
|
||||
|
||||
await cleanupSSHKey(nonExistentPath)
|
||||
})
|
||||
|
||||
it('should handle cleanup of already cleaned up file gracefully', async () => {
|
||||
const key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRHw== test@host'
|
||||
const keyPath = await writeTemporarySSHKey(key, 'test-double-cleanup')
|
||||
|
||||
await cleanupSSHKey(keyPath)
|
||||
await expect(cleanupSSHKey(keyPath)).resolves.not.toThrow()
|
||||
})
|
||||
})
|
||||
it('should handle cleanup of already cleaned up file gracefully', async () => {
|
||||
const key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRHw== test@host'
|
||||
const keyPath = await writeTemporarySSHKey(key, 'test-double-cleanup')
|
||||
|
||||
await cleanupSSHKey(keyPath)
|
||||
await cleanupSSHKey(keyPath)
|
||||
})
|
||||
})
|
||||
@@ -1,6 +1,4 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||
|
||||
const mockExecuteCommand = vi.fn()
|
||||
import { describe, it, expect, vi, beforeEach, afterEach, beforeAll, afterAll } from 'vitest'
|
||||
|
||||
vi.mock('@opencode-manager/shared/config/env', () => ({
|
||||
ENV: {
|
||||
@@ -18,8 +16,10 @@ vi.mock('@opencode-manager/shared/config/env', () => ({
|
||||
getWorkspacePath: vi.fn(() => '/tmp/test-workspace')
|
||||
}))
|
||||
|
||||
let mockExecuteCommand: any
|
||||
|
||||
vi.mock('../../src/utils/process', () => ({
|
||||
executeCommand: mockExecuteCommand
|
||||
executeCommand: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('fs', () => ({
|
||||
@@ -30,6 +30,11 @@ vi.mock('fs', () => ({
|
||||
}))
|
||||
|
||||
import { validateSSHPrivateKey } from '../../src/utils/ssh-validation'
|
||||
import { executeCommand } from '../../src/utils/process'
|
||||
|
||||
beforeAll(() => {
|
||||
mockExecuteCommand = executeCommand
|
||||
})
|
||||
|
||||
describe('validateSSHPrivateKey', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
Reference in new issue
Block a user