Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

2.4 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { isAllowedPluginGitUrl, pluginInstallSourceSchema } from './plugin-install-lockfile'

describe('pluginInstallSourceSchema marketplace provenance', () => {
  it('records both the marketplace snapshot and plugin Git ref', () => {
    expect(
      pluginInstallSourceSchema.parse({
        kind: 'marketplace',
        marketplace: {
          url: 'https://github.com/stablyai/orca-plugins.git',
          ref: 'main',
          resolvedCommit: 'a'.repeat(40)
        },
        plugin: {
          url: '[email protected]:stablyai/orca-skills.git',
          ref: 'v1.0.0'
        }
      })
    ).toEqual({
      kind: 'marketplace',
      marketplace: {
        url: 'https://github.com/stablyai/orca-plugins.git',
        ref: 'main',
        resolvedCommit: 'a'.repeat(40)
      },
      plugin: {
        url: '[email protected]:stablyai/orca-skills.git',
        ref: 'v1.0.0'
      }
    })
  })

  it('requires pinned refs and an exact marketplace snapshot commit', () => {
    const source = {
      kind: 'marketplace',
      marketplace: {
        url: 'https://github.com/stablyai/orca-plugins.git',
        ref: 'main',
        resolvedCommit: 'a'.repeat(40)
      },
      plugin: {
        url: 'https://github.com/stablyai/orca-skills.git',
        ref: 'v1.0.0'
      }
    }

    expect(
      pluginInstallSourceSchema.safeParse({
        ...source,
        marketplace: { ...source.marketplace, ref: '' }
      }).success
    ).toBe(false)
    expect(
      pluginInstallSourceSchema.safeParse({
        ...source,
        marketplace: { ...source.marketplace, resolvedCommit: 'main' }
      }).success
    ).toBe(false)
    expect(
      pluginInstallSourceSchema.safeParse({
        ...source,
        plugin: { ...source.plugin, ref: '' }
      }).success
    ).toBe(false)
  })
})

describe('isAllowedPluginGitUrl', () => {
  it.each([
    'https://github.com/stablyai/orca-plugins.git',
    'ssh://[email protected]/stablyai/orca-plugins.git',
    '[email protected]:stablyai/orca-plugins.git'
  ])('accepts %s', (url) => {
    expect(isAllowedPluginGitUrl(url)).toBe(true)
  })

  it.each([
    'git@-oProxyCommand=evil:repo.git',
    '[email protected]:repo.git',
    'ssh://-oProxyCommand=evil/repo.git',
    'ssh://[email protected]/repo.git',
    '[email protected]:repo.git',
    'https://github..com/repo.git'
  ])('rejects %s', (url) => {
    expect(isAllowedPluginGitUrl(url)).toBe(false)
  })
})