]>
git.saurik.com Git - apple/security.git/blob - SecurityServer/tests/testutils.h
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // testutils - utilities for unit test drivers
25 #include "testclient.h"
35 // Error and diagnostic drivers
37 void error(const char *fmt
, ...) __attribute__((format(printf
,1,2)));
38 void error(const CssmCommonError
&error
, const char *fmt
, ...) __attribute__((format(printf
,2,3)));
39 void detail(const char *fmt
, ...) __attribute__((format(printf
,1,2)));
40 void detail(const CssmCommonError
&error
, const char *msg
);
41 void prompt(const char *msg
);
46 // A self-building "fake" context.
47 // (Fake in that it was hand-made without involvement of CSSM.)
49 class FakeContext
: public ::Context
{
51 FakeContext(CSSM_CONTEXT_TYPE type
, CSSM_ALGORITHMS alg
, uint32 count
);
52 FakeContext(CSSM_CONTEXT_TYPE type
, CSSM_ALGORITHMS alg
, ...);
57 // A test driver class for ACL tests
61 AclTester(ClientSession
&ss
, const AclEntryInput
*acl
);
63 void testWrap(const AccessCredentials
*cred
, const char *howWrong
= NULL
);
64 void testEncrypt(const AccessCredentials
*cred
, const char *howWrong
= NULL
);
66 ClientSession
&session
;
72 // A test driver class for database tests
76 DbTester(ClientSession
&ss
, const char *path
,
77 const AccessCredentials
*cred
, int timeout
= 30, bool sleepLock
= true);
79 operator DbHandle () const { return dbRef
; }
80 void unlock(const char *howWrong
= NULL
);
81 void changePassphrase(const AccessCredentials
*cred
, const char *howWrong
= NULL
);
83 ClientSession
&session
;