3 from sfa.trust.certificate import Keypair
4 from sfa.trust.gid import *
6 class TestGid(unittest.TestCase):
10 def testSetGetHrn(self):
11 gid = GID(subject="test")
15 self.assertEqual(gid.get_hrn(), hrn)
17 def testSetGetUuid(self):
18 gid = GID(subject="test")
22 self.assertEqual(gid.get_uuid(), u)
24 def testEncodeDecode(self):
25 gid = GID(subject="test")
26 u = str(uuid.uuid4().int)
35 self.assertEqual(gid.get_hrn(), hrn)
36 self.assertEqual(gid.get_uuid(), u)
38 def testSaveAndLoadString(self):
39 gid = GID(subject="test")
41 u = str(uuid.uuid4().int)
47 # create an issuer and sign the certificate
48 issuerKey = Keypair(create = True)
49 issuerSubject = "testissuer"
50 gid.set_issuer(issuerKey, issuerSubject)
53 certstr = gid.save_to_string()
57 gid2 = GID(string = certstr)
59 self.assertEqual(gid.get_hrn(), hrn)
60 self.assertEqual(gid.get_uuid(), u)
62 if __name__ == "__main__":