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.

1.4 KB
Raw Blame
import Darwin
import XCTest
@testable import OrcaComputerUseMacOSCore

final class UnixSocketPathSafetyTests: XCTestCase {
    func testOnlyUnixSocketModesAreAccepted() {
        XCTAssertTrue(UnixSocketPathSafety.isSocketMode(mode_t(S_IFSOCK | 0o600)))
        XCTAssertFalse(UnixSocketPathSafety.isSocketMode(mode_t(S_IFREG | 0o600)))
        XCTAssertFalse(UnixSocketPathSafety.isSocketMode(mode_t(S_IFDIR | 0o700)))
        XCTAssertFalse(UnixSocketPathSafety.isSocketMode(mode_t(S_IFLNK | 0o777)))
    }

    func testRejectsOnlyNonSocketPathsAfterAddressInUseBindFailure() {
        XCTAssertTrue(
            UnixSocketPathSafety.shouldRejectExistingPathAfterBindFailure(
                bindErrno: EADDRINUSE,
                existingMode: mode_t(S_IFREG | 0o600)
            )
        )
        XCTAssertFalse(
            UnixSocketPathSafety.shouldRejectExistingPathAfterBindFailure(
                bindErrno: EADDRINUSE,
                existingMode: mode_t(S_IFSOCK | 0o600)
            )
        )
        XCTAssertFalse(
            UnixSocketPathSafety.shouldRejectExistingPathAfterBindFailure(
                bindErrno: EACCES,
                existingMode: mode_t(S_IFREG | 0o600)
            )
        )
        XCTAssertFalse(
            UnixSocketPathSafety.shouldRejectExistingPathAfterBindFailure(
                bindErrno: EADDRINUSE,
                existingMode: nil
            )
        )
    }
}