]>
git.saurik.com Git - apple/security.git/blob - securityd/tests/testutils.h
2 * Copyright (c) 2000-2001,2003-2004 Apple Computer, 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@
26 // testutils - utilities for unit test drivers
31 #include "testclient.h"
41 // Error and diagnostic drivers
43 void error(const char *fmt
, ...) __attribute__((format(printf
,1,2)));
44 void error(const CssmCommonError
&error
, const char *fmt
, ...) __attribute__((format(printf
,2,3)));
45 void detail(const char *fmt
, ...) __attribute__((format(printf
,1,2)));
46 void detail(const CssmCommonError
&error
, const char *msg
);
47 void prompt(const char *msg
);
52 // A self-building "fake" context.
53 // (Fake in that it was hand-made without involvement of CSSM.)
55 class FakeContext
: public ::Context
{
57 FakeContext(CSSM_CONTEXT_TYPE type
, CSSM_ALGORITHMS alg
, uint32 count
);
58 FakeContext(CSSM_CONTEXT_TYPE type
, CSSM_ALGORITHMS alg
, ...);
63 // A test driver class for ACL tests
67 AclTester(ClientSession
&ss
, const AclEntryInput
*acl
);
69 void testWrap(const AccessCredentials
*cred
, const char *howWrong
= NULL
);
70 void testEncrypt(const AccessCredentials
*cred
, const char *howWrong
= NULL
);
72 ClientSession
&session
;
78 // A test driver class for database tests
82 DbTester(ClientSession
&ss
, const char *path
,
83 const AccessCredentials
*cred
, int timeout
= 30, bool sleepLock
= true);
85 operator DbHandle () const { return dbRef
; }
86 void unlock(const char *howWrong
= NULL
);
87 void changePassphrase(const AccessCredentials
*cred
, const char *howWrong
= NULL
);
89 ClientSession
&session
;