2 from sfa.trust.certificate import Keypair
3 from sfa.trust.gid import *
5 class TestGid(unittest.TestCase):
9 def testSetGetHrn(self):
10 gid = GID(subject="test")
14 self.assertEqual(gid.get_hrn(), hrn)
16 def testSetGetUuid(self):
17 gid = GID(subject="test")
21 self.assertEqual(gid.get_uuid(), u)
23 def testEncodeDecode(self):
24 gid = GID(subject="test")
34 self.assertEqual(gid.get_hrn(), hrn)
35 self.assertEqual(gid.get_uuid(), u)
37 def testSaveAndLoadString(self):
38 gid = GID(subject="test")
46 # create an issuer and sign the certificate
47 issuerKey = Keypair(create = True)
48 issuerSubject = "testissuer"
49 gid.set_issuer(issuerKey, issuerSubject)
52 certstr = gid.save_to_string()
56 gid2 = GID(string = certstr)
58 self.assertEqual(gid.get_hrn(), hrn)
59 self.assertEqual(gid.get_uuid(), u)
61 if __name__ == "__main__":