Skip to content

Commit

Permalink
Add unit test for fix in #1165.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarkowsky committed Sep 2, 2023
1 parent 97ef241 commit c6924cb
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions Source/santad/SNTExecutionControllerTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ - (void)testSynchronousShouldProcessExecEvent {
XCTBubbleMockVerifyAndClearExpectations(mockESApi.get());
}


- (void)validateExecEvent:(SNTAction)wantAction
messageSetup:(void (^)(es_message_t *))messageSetupBlock {
es_file_t file = MakeESFile("foo");
Expand Down Expand Up @@ -465,24 +464,21 @@ - (void)testBinaryAllowTransitiveRuleDisabled {
[self checkMetricCounters:kAllowTransitive expected:@0];
}

- (void)testPlatformBinaryAllow {
- (void)testThatPlatformBinaryCachedDecisionsSetModeCorrectly {
OCMStub([self.mockFileInfo isMachO]).andReturn(YES);
OCMStub([self.mockFileInfo SHA256]).andReturn(@"a");
OCMStub([self.mockConfigurator clientMode]).andReturn(SNTClientModeLockdown);
OCMStub([self.mockConfigurator enableTransitiveRules]).andReturn(NO);

SNTRule *rule = [[SNTRule alloc] init];
rule.state = SNTRuleStateAllow;
rule.type = SNTRuleTypeBinary;
OCMStub([self.mockRuleDatabase ruleForBinarySHA256:@"a"
signingID:nil
certificateSHA256:nil
teamID:nil])
.andReturn(rule);
[self validateExecEvent:SNTActionRespondAllow
messageSetup:^(es_message_t *msg){
msg->event.exec.target->is_platform_binary = true;
}];
SNTCachedDecision *cd = [[SNTCachedDecision alloc] init];
cd.decision = SNTEventStateAllowBinary;
OCMStub([self.mockRuleDatabase criticalSystemBinaries]).andReturn(@{@"a" : cd});

[self validateExecEvent:SNTActionRespondAllow];
[self checkMetricCounters:kAllowBinary expected:@1];
[self checkMetricCounters:kAllowUnknown expected:@0];

XCTAssertEqual(cd.decisionClientMode, SNTClientModeLockdown);
}

- (void)testDefaultDecision {
Expand Down

0 comments on commit c6924cb

Please sign in to comment.