mirror of
https://github.com/stablyai/orca.git
synced 2026-10-21 16:03:26 +00:00
* Fix stacked-worktree PR creation targeting a local-only parent branch - Resolve the eligibility default base to a remote-tracking ref instead of blindly trusting the submitted parent branch, since a stacked worktree's base is often a local-only branch the remote can't resolve - Add a create-time hard block (base_not_on_remote) so a stale or unpushed submitted base fails with actionable copy instead of the provider's opaque error - Update the dialog's default-base resolution and blocked-action/ dropdown copy to match the new remote-validated default * Split hosted-review-creation.test.ts to fix max-lines lint error Moved getHostedReviewCreationEligibility tests to a separate file (hosted-review-creation-eligibility.test.ts) to reduce the original file size from 880 to 579 lines, satisfying the max-lines lint constraint. Co-authored-by: Orca <help@stably.ai> * Fix Create PR intent flow to use remote-validated eligibility default fo Prefer eligibilityDefaultBaseRef over the raw compare base when resolving the review base for the one-click Create PR intent flow, since eligibility is recomputed from the same compare base right before creation and already corrects a local-only stacked parent to the repo default. Falls back to the compare base only when eligibility supplies no default. * Simplify base-ref remote existence check into a single for-each-ref call Combine the wildcard and exact-tracking-ref lookups into one for-each-ref invocation with multiple patterns instead of two sequential git calls, removing the redundant rev-parse fallback path. --------- Co-authored-by: Orca <help@stably.ai>
158 lines
5.3 KiB
TypeScript
158 lines
5.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { hasSufficientWindowsFirewallRemoteScope } from './windows-firewall-remote-scope'
|
|
|
|
type RuleScope = { remoteAddresses: unknown }
|
|
|
|
function rule(remoteAddresses: unknown): RuleScope {
|
|
return { remoteAddresses }
|
|
}
|
|
|
|
describe('Windows firewall remote-address scope', () => {
|
|
it.each([['Any'], ['any'], ['LocalSubnet']])('accepts the documented %s scope', (scope) => {
|
|
expect(hasSufficientWindowsFirewallRemoteScope([rule(scope)], undefined, undefined)).toBe(true)
|
|
})
|
|
|
|
it.each([['Any4'], ['LocalSubnet4']])(
|
|
'accepts address-family-specific %s on the selected IPv4 interface',
|
|
(scope) => {
|
|
expect(hasSufficientWindowsFirewallRemoteScope([rule([scope])], '192.168.0.108', 24)).toBe(
|
|
true
|
|
)
|
|
}
|
|
)
|
|
|
|
it('keeps address-family-specific keywords on the selected interface family', () => {
|
|
expect(hasSufficientWindowsFirewallRemoteScope([rule(['Any6'])], 'fd7a:115c:a1e0::5', 64)).toBe(
|
|
true
|
|
)
|
|
expect(
|
|
hasSufficientWindowsFirewallRemoteScope([rule(['LocalSubnet6'])], 'fd7a:115c:a1e0::5', 64)
|
|
).toBe(true)
|
|
expect(
|
|
hasSufficientWindowsFirewallRemoteScope([rule(['LocalSubnet6'])], '192.168.0.108', 24)
|
|
).toBe(false)
|
|
})
|
|
|
|
it.each([
|
|
['192.168.0.0/24', '192.168.0.108', 24],
|
|
['192.168.0.0-192.168.0.255', '192.168.0.108', 24],
|
|
['fd7a:115c:a1e0::/64', 'fd7a:115c:a1e0::5', 64],
|
|
['fd7a:115c:a1e0::-fd7a:115c:a1e0:0:ffff:ffff:ffff:ffff', 'fd7a:115c:a1e0::5', 64]
|
|
])('accepts explicit scope %s covering the selected local subnet', (scope, address, prefix) => {
|
|
expect(hasSufficientWindowsFirewallRemoteScope([rule([scope])], address, prefix)).toBe(true)
|
|
})
|
|
|
|
it.each([
|
|
['192.168.1.0/24', '192.168.0.108', 24],
|
|
['192.168.0.64/26', '192.168.0.108', 24],
|
|
['192.168.0.108', '192.168.0.108', 24],
|
|
['fd7a:115c:a1e1::/64', 'fd7a:115c:a1e0::5', 64],
|
|
['Internet', '192.168.0.108', 24]
|
|
])('rejects restrictive or unsupported scope %s', (scope, address, prefix) => {
|
|
expect(hasSufficientWindowsFirewallRemoteScope([rule([scope])], address, prefix)).toBe(false)
|
|
})
|
|
|
|
it('does not infer explicit scope coverage without selected interface subnet data', () => {
|
|
expect(
|
|
hasSufficientWindowsFirewallRemoteScope([rule(['192.168.0.0/24'])], undefined, undefined)
|
|
).toBe(false)
|
|
expect(
|
|
hasSufficientWindowsFirewallRemoteScope([rule(['192.168.0.0/24'])], '192.168.0.108', 40)
|
|
).toBe(false)
|
|
expect(
|
|
hasSufficientWindowsFirewallRemoteScope([rule(['100.64.0.0/10'])], '100.64.1.20', 32)
|
|
).toBe(false)
|
|
})
|
|
|
|
it.each([
|
|
undefined,
|
|
null,
|
|
[],
|
|
{},
|
|
[rule(undefined)],
|
|
[rule([])],
|
|
[rule([''])],
|
|
[rule(['not-an-address'])],
|
|
[{ remoteAddresses: [42] }]
|
|
])('rejects malformed or empty structured output %#', (rules) => {
|
|
expect(hasSufficientWindowsFirewallRemoteScope(rules, '192.168.0.108', 24)).toBe(false)
|
|
})
|
|
|
|
it('evaluates each rule independently instead of merging partial ranges', () => {
|
|
expect(
|
|
hasSufficientWindowsFirewallRemoteScope(
|
|
[rule(['192.168.0.0-192.168.0.127']), rule(['192.168.0.128-192.168.0.255'])],
|
|
'192.168.0.108',
|
|
24
|
|
)
|
|
).toBe(false)
|
|
expect(
|
|
hasSufficientWindowsFirewallRemoteScope(
|
|
[rule(['192.168.1.0/24']), rule(['192.168.0.0/24'])],
|
|
'192.168.0.108',
|
|
24
|
|
)
|
|
).toBe(true)
|
|
})
|
|
|
|
it('accepts PowerShell single-object and single-string JSON shapes', () => {
|
|
expect(
|
|
hasSufficientWindowsFirewallRemoteScope(
|
|
{ remoteAddresses: '192.168.0.0/24' },
|
|
'192.168.0.108',
|
|
24
|
|
)
|
|
).toBe(true)
|
|
})
|
|
|
|
it('accepts dotted-netmask CIDR with a contiguous mask and rejects a holey one', () => {
|
|
expect(
|
|
hasSufficientWindowsFirewallRemoteScope(
|
|
[rule(['192.168.0.0/255.255.255.0'])],
|
|
'192.168.0.108',
|
|
24
|
|
)
|
|
).toBe(true)
|
|
expect(
|
|
hasSufficientWindowsFirewallRemoteScope(
|
|
[rule(['192.168.0.0/255.0.255.0'])],
|
|
'192.168.0.108',
|
|
24
|
|
)
|
|
).toBe(false)
|
|
})
|
|
|
|
it('treats a single-host (/32) interface as coverable only by Any/LocalSubnet keywords', () => {
|
|
// A /32 subnet is just the desktop itself, so an explicit range cannot prove
|
|
// the phone (a different host) is allowed — only the keywords can.
|
|
expect(hasSufficientWindowsFirewallRemoteScope([rule(['Any'])], '100.64.1.20', 32)).toBe(true)
|
|
expect(
|
|
hasSufficientWindowsFirewallRemoteScope([rule(['LocalSubnet'])], '100.64.1.20', 32)
|
|
).toBe(true)
|
|
expect(
|
|
hasSufficientWindowsFirewallRemoteScope([rule(['100.64.0.0/10'])], '100.64.1.20', 32)
|
|
).toBe(false)
|
|
})
|
|
|
|
it('fails address-family keywords closed when the interface family is unknown', () => {
|
|
expect(hasSufficientWindowsFirewallRemoteScope([rule(['Any'])], undefined, undefined)).toBe(
|
|
true
|
|
)
|
|
expect(hasSufficientWindowsFirewallRemoteScope([rule(['Any4'])], undefined, undefined)).toBe(
|
|
false
|
|
)
|
|
expect(hasSufficientWindowsFirewallRemoteScope([rule(['Any6'])], undefined, undefined)).toBe(
|
|
false
|
|
)
|
|
})
|
|
|
|
it.each([['Intranet'], ['DNS'], ['DHCP'], ['DefaultGateway'], ['PlayToDevice']])(
|
|
'fails the policy-defined %s keyword closed rather than assuming subnet coverage',
|
|
(scope) => {
|
|
expect(hasSufficientWindowsFirewallRemoteScope([rule([scope])], '192.168.0.108', 24)).toBe(
|
|
false
|
|
)
|
|
}
|
|
)
|
|
})
|