]>
git.saurik.com Git - apple/securityd.git/blob - tests/testutils.h
d3550646565c6c057553c6ec1e83d96fd6254ec2
2 * Copyright (c) 2000-2001,2004 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
28 // testutils - utilities for unit test drivers
33 #include "testclient.h"
43 // Error and diagnostic drivers
45 void error(const char *fmt
, ...) __attribute__((format(printf
,1,2)));
46 void error(const CssmCommonError
&error
, const char *fmt
, ...) __attribute__((format(printf
,2,3)));
47 void detail(const char *fmt
, ...) __attribute__((format(printf
,1,2)));
48 void detail(const CssmCommonError
&error
, const char *msg
);
49 void prompt(const char *msg
);
54 // A self-building "fake" context.
55 // (Fake in that it was hand-made without involvement of CSSM.)
57 class FakeContext
: public ::Context
{
59 FakeContext(CSSM_CONTEXT_TYPE type
, CSSM_ALGORITHMS alg
, uint32 count
);
60 FakeContext(CSSM_CONTEXT_TYPE type
, CSSM_ALGORITHMS alg
, ...);
65 // A test driver class for ACL tests
69 AclTester(ClientSession
&ss
, const AclEntryInput
*acl
);
71 void testWrap(const AccessCredentials
*cred
, const char *howWrong
= NULL
);
72 void testEncrypt(const AccessCredentials
*cred
, const char *howWrong
= NULL
);
74 ClientSession
&session
;
80 // A test driver class for database tests
84 DbTester(ClientSession
&ss
, const char *path
,
85 const AccessCredentials
*cred
, int timeout
= 30, bool sleepLock
= true);
87 operator DbHandle () const { return dbRef
; }
88 void unlock(const char *howWrong
= NULL
);
89 void changePassphrase(const AccessCredentials
*cred
, const char *howWrong
= NULL
);
91 ClientSession
&session
;