CallerIdentityTests.swift
39 lines 1.3 KB
Raw
sha256:bd1eb24434d281fe65142038c1bf217493421f5a86880c22dff7e6037d2d4700 feat(companion): add production macOS distribution path Human minor ⚠ breaking 25 days ago
1 import XCTest
2 @testable import KnowtationSecurity
3
4 final class CallerIdentityTests: XCTestCase {
5 private let policy = CallerIdentityPolicy(
6 teamIdentifier: "TEAM123456",
7 allowedIdentifiers: [
8 KnowtationReleaseContract.appIdentifier,
9 KnowtationReleaseContract.cliIdentifier,
10 KnowtationReleaseContract.mcpIdentifier,
11 ]
12 )
13
14 func testAcceptsSameTeamAllowedCaller() throws {
15 let identity = CallerIdentity(
16 identifier: KnowtationReleaseContract.cliIdentifier,
17 teamIdentifier: "TEAM123456"
18 )
19 XCTAssertEqual(try policy.evaluate(identity), identity)
20 }
21
22 func testRejectsOtherTeam() {
23 XCTAssertThrowsError(try policy.evaluate(CallerIdentity(
24 identifier: KnowtationReleaseContract.cliIdentifier,
25 teamIdentifier: "ATTACKER00"
26 ))) { error in
27 XCTAssertEqual(error as? CallerIdentityError, .teamMismatch)
28 }
29 }
30
31 func testRejectsSameTeamUnknownIdentifier() {
32 XCTAssertThrowsError(try policy.evaluate(CallerIdentity(
33 identifier: "store.knowtation.substituted",
34 teamIdentifier: "TEAM123456"
35 ))) { error in
36 XCTAssertEqual(error as? CallerIdentityError, .identifierDenied)
37 }
38 }
39 }
File History 1 commit
sha256:bd1eb24434d281fe65142038c1bf217493421f5a86880c22dff7e6037d2d4700 feat(companion): add production macOS distribution path Human minor ⚠ 25 days ago