#ifndef _H_TESTUTILS
#define _H_TESTUTILS
#include "testclient.h"
extern bool verbose;
void error(const char *fmt, ...) __attribute__((format(printf,1,2)));
void error(const CssmCommonError &error, const char *fmt, ...) __attribute__((format(printf,2,3)));
void detail(const char *fmt, ...) __attribute__((format(printf,1,2)));
void detail(const CssmCommonError &error, const char *msg);
void prompt(const char *msg);
void prompt();
class FakeContext : public ::Context {
public:
FakeContext(CSSM_CONTEXT_TYPE type, CSSM_ALGORITHMS alg, uint32 count);
FakeContext(CSSM_CONTEXT_TYPE type, CSSM_ALGORITHMS alg, ...);
};
class AclTester {
public:
AclTester(ClientSession &ss, const AclEntryInput *acl);
void testWrap(const AccessCredentials *cred, const char *howWrong = NULL);
void testEncrypt(const AccessCredentials *cred, const char *howWrong = NULL);
ClientSession &session;
KeyHandle keyRef;
};
class DbTester {
public:
DbTester(ClientSession &ss, const char *path,
const AccessCredentials *cred, int timeout = 30, bool sleepLock = true);
operator DbHandle () const { return dbRef; }
void unlock(const char *howWrong = NULL);
void changePassphrase(const AccessCredentials *cred, const char *howWrong = NULL);
ClientSession &session;
DBParameters params;
DLDbIdentifier dbId;
DbHandle dbRef;
};
#endif //_H_TESTUTILS