1 /*
2  * Copyright (c) 2010 .SE (The Internet Infrastructure Foundation)
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
18  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 /*****************************************************************************
28  TestsNoPINInitBase.h
29 
30  Base class for test classes. Used when there is no need for user login.
31  *****************************************************************************/
32 
33 #ifndef SRC_LIB_TEST_TESTSNOPININITBASE_H_
34 #define SRC_LIB_TEST_TESTSNOPININITBASE_H_
35 
36 #include "cryptoki.h"
37 #include <cppunit/TestFixture.h>
38 
39 
40 #ifdef P11M
41 #define CRYPTOKI_F_PTR(func) m_ptr->func
42 #else
43 #define CRYPTOKI_F_PTR(func) func
44 #endif
45 
46 class TestsNoPINInitBase : public CppUnit::TestFixture {
47 public:
48 	TestsNoPINInitBase();
49 	virtual ~TestsNoPINInitBase();
50 
51 	virtual void setUp();
52 	virtual void tearDown();
53 private:
54 	void getSlotIDs();
55 #ifdef P11M
56 #ifdef _WIN32
57 	HINSTANCE__* p11Library;
58 #else
59 	void *const p11Library;
60 #endif
61 protected:
62 	const CK_FUNCTION_LIST_PTR m_ptr;
63 #else
64 protected:
65 #endif
66 	const CK_SLOT_ID m_invalidSlotID;
67 	CK_SLOT_ID m_initializedTokenSlotID;
68 	CK_SLOT_ID m_notInitializedTokenSlotID;
69 
70 	const CK_UTF8CHAR_PTR m_soPin1;
71 	const CK_ULONG m_soPin1Length;
72 
73 	const CK_UTF8CHAR_PTR m_userPin1;
74 	const CK_ULONG m_userPin1Length;
75 };
76 
77 
78 #endif /* SRC_LIB_TEST_TESTSNOPININITBASE_H_ */
79