-
-
Save ydzheng/7946d8add5df2e04a39f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)testAuthenticateWithTouchID { | |
id mockLAContext = [OCMockObject mockForClass:[LAContext class]]; | |
[_authManager setLocalAuthContext:mockLAContext]; | |
[[mockLAContext expect] setLocalizedFallbackTitle:@"Wealthfront PIN"]; | |
BOOL boolValue = YES; | |
NSError *err = nil; | |
[[[mockLAContext expect] andDo:^(NSInvocation *i) { | |
void(^reply)(BOOL success, NSError *error) = nil; | |
[i getArgument:&reply | |
atIndex:4]; | |
reply(boolValue, err); | |
}] evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics | |
localizedReason:@"Please authenticate to proceed" | |
reply:[OCMArg isNotNil]]; | |
__block BOOL succeeded = NO; | |
[_authManager authenticateByTouchIDWithFallbackButtonTitle:@"Wealthfront PIN" | |
success:^{ | |
succeeded = YES; | |
} fallback:^(NSError *error){ | |
XCTFail(@"fallback block should not have been called"); | |
}]; | |
XCTAssertTrue(succeeded, @"Should have succeeded"); | |
XCTAssertNil(_authManager.localAuthContext, @"Should be nil now"); | |
XCTAssertThrows([_authManager authenticateByTouchIDWithFallbackButtonTitle:nil | |
success:OCMOCK_ANY | |
fallback:OCMOCK_ANY]); | |
[mockLAContext verify]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment