1 #import "SecDbBackupTestsBase.h"
3 static int checkV12DevEnabledOn(void) {
7 static int checkV12DevEnabledOff(void) {
11 NSString* _uuidstring;
13 @implementation SecDbBackupTestsBase {
14 NSString* _testHomeDirectory;
17 + (void)setV12Development:(BOOL)newState {
19 checkV12DevEnabled = checkV12DevEnabledOn;
21 checkV12DevEnabled = checkV12DevEnabledOff;
27 checkV12DevEnabled = checkV12DevEnabledOn;
30 SecCKKSTestSetDisableSOS(true);
32 _uuidstring = [[NSUUID UUID] UUIDString];
36 NSString* testName = [self.name componentsSeparatedByString:@" "][1];
37 testName = [testName stringByReplacingOccurrencesOfString:@"]" withString:@""];
38 secnotice("secdbbackuptest", "Beginning test %@", testName);
40 // Make a new fake keychain
42 _testHomeDirectory = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@/%@/", _uuidstring, testName]];
44 NSLog(@"%@", _testHomeDirectory);
46 [[NSFileManager defaultManager] createDirectoryAtPath:_testHomeDirectory
47 withIntermediateDirectories:YES
51 XCTAssertNil(error, "Could not make directory at %@", _testHomeDirectory);
53 SetCustomHomeURLString((__bridge CFStringRef)_testHomeDirectory);
54 static dispatch_once_t onceToken;
55 dispatch_once(&onceToken, ^{
58 SecKeychainDbReset(NULL);
60 // Actually load the database.
61 kc_with_dbt(true, NULL, ^bool (SecDbConnectionRef dbt) { return false; });
65 // Put teardown code here. This method is called after the invocation of each test method in the class.
69 SetCustomHomeURL(NULL);
70 SecKeychainDbReset(NULL);
71 resetCheckV12DevEnabled();