@@ -93,6 +93,41 @@ def test_objects(self):
9393 template = [(PyKCS11 .CKA_HW_FEATURE_TYPE , PyKCS11 .CKH_USER_INTERFACE )]
9494 o = self .session .findObjects (template )
9595
96+ def test_BoolAttributes (self ):
97+ # dictionary of attributes expected to be bool and their expected values
98+ boolAttributes = {
99+ PyKCS11 .CKA_TOKEN : PyKCS11 .CK_FALSE ,
100+ PyKCS11 .CKA_PRIVATE : PyKCS11 .CK_FALSE ,
101+ # The attributes below are defaulted to CK_TRUE
102+ # ( according to the PKCS#11 standard )
103+ PyKCS11 .CKA_MODIFIABLE : PyKCS11 .CK_TRUE ,
104+ PyKCS11 .CKA_COPYABLE : PyKCS11 .CK_TRUE ,
105+ PyKCS11 .CKA_DESTROYABLE : PyKCS11 .CK_TRUE ,
106+ }
107+
108+ CkoDataTemplate = [
109+ (PyKCS11 .CKA_CLASS , PyKCS11 .CKO_DATA ),
110+ (PyKCS11 .CKA_TOKEN , PyKCS11 .CK_FALSE ),
111+ (PyKCS11 .CKA_PRIVATE , PyKCS11 .CK_FALSE ),
112+ (PyKCS11 .CKA_LABEL , "TestData" ),
113+ ]
114+
115+ # create a CKO_DATA object
116+ ckoData = self .session .createObject (CkoDataTemplate )
117+ self .assertIsNotNone (ckoData )
118+
119+ attrValues = self .session .getAttributeValue (
120+ ckoData , list (boolAttributes .keys ())
121+ )
122+
123+ # check that attributes are of bool type
124+ # and have expected values
125+ for i , attr in enumerate (boolAttributes ):
126+ self .assertIsInstance (attrValues [i ], bool )
127+ self .assertEqual (attrValues [i ], boolAttributes [attr ])
128+
129+ # clean up
130+ self .session .destroyObject (ckoData )
96131
97132class TestGetSetAttributeValues (unittest .TestCase ):
98133
0 commit comments