2 * Copyright (c) 2013-2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 #include <Security/SecBase.h>
26 #include <Security/SecItem.h>
28 #include "keychain/SecureObjectSync/SOSAccount.h"
29 #include <Security/SecureObjectSync/SOSCloudCircle.h>
30 #include "keychain/SecureObjectSync/SOSInternal.h"
31 #include "keychain/SecureObjectSync/SOSUserKeygen.h"
32 #include "keychain/SecureObjectSync/SOSAccountTrustClassic+Circle.h"
37 #include "secd_regressions.h"
38 #include "SOSTestDataSource.h"
40 #include "SOSRegressionUtilities.h"
41 #include <utilities/SecCFWrappers.h>
43 #include "keychain/securityd/SOSCloudCircleServer.h"
45 #include "SecdTestKeychainUtilities.h"
46 #include "SOSAccountTesting.h"
47 #include "SOSTransportTestTransports.h"
51 #define kCompatibilityTestCount 0
53 static void test_v6(void) {
54 SOSDataSourceFactoryRef ak_factory = SOSTestDataSourceFactoryCreate();
55 SOSDataSourceRef test_source = SOSTestDataSourceCreate();
56 SOSTestDataSourceFactorySetDataSource(ak_factory, CFSTR("ak"), test_source);
57 CFErrorRef error = NULL;
59 const uint8_t *der_p = v6_der;
61 SOSAccount* convertedAccount = SOSAccountCreateFromDER(kCFAllocatorDefault, ak_factory, &error, &der_p, v6_der + sizeof(v6_der));
63 ok(convertedAccount, "inflate v6 account (%@)", error);
66 is(kSOSCCInCircle, [convertedAccount.trust getCircleStatus:&error], "in the circle");
68 CFReleaseSafe(convertedAccount);
69 ak_factory->release(ak_factory);
70 SOSDataSourceRelease(test_source, NULL);
74 static int kTestTestCount = 11 + kSecdTestSetupTestCount;
75 static void tests(void)
78 CFErrorRef error = NULL;
79 CFDataRef cfpassword = CFDataCreate(NULL, (uint8_t *) "FooFooFoo", 10);
80 CFStringRef cfaccount = CFSTR("test@test.org");
82 SOSDataSourceFactoryRef test_factory = SOSTestDataSourceFactoryCreate();
83 SOSDataSourceRef test_source = SOSTestDataSourceCreate();
84 SOSTestDataSourceFactorySetDataSource(test_factory, CFSTR("TestType"), test_source);
86 SOSAccount* account = CreateAccountForLocalChanges(CFSTR("Test Device"), CFSTR("TestType"));
87 ok(SOSAccountAssertUserCredentialsAndUpdate(account, cfaccount, cfpassword, &error), "Credential setting (%@)", error);
89 CFReleaseNull(cfpassword);
91 ok(NULL != account, "Created");
93 ok(SOSAccountResetToOffering_wTxn(account, &error), "Reset to offering (%@)", error);
96 ok(testAccountPersistence(account), "Test Account->DER->Account Equivalence");
100 test_factory->release(test_factory);
101 SOSDataSourceRelease(test_source, NULL);
106 int secd_51_account_inflate(int argc, char *const *argv)
109 plan_tests(kTestTestCount + kCompatibilityTestCount);
110 secd_test_setup_temp_keychain(__FUNCTION__, NULL);
111 secd_test_clear_testviews();