src/tests/api/t_publisher.py
changeset 2026 d1b30615bc99
parent 1715 8f305f0a6864
child 2272 d81ea073d050
child 2572 20cf41d565de
equal deleted inserted replaced
2025:4ba5092f1b06 2026:d1b30615bc99
    19 #
    19 #
    20 # CDDL HEADER END
    20 # CDDL HEADER END
    21 #
    21 #
    22 
    22 
    23 #
    23 #
    24 # Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
    24 # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
    25 # Use is subject to license terms.
    25 #
    26 #
    26 
    27 
    27 
    28 import testutils
    28 import testutils
    29 if __name__ == "__main__":
    29 if __name__ == "__main__":
    30         testutils.setup_environment("../../../proto")
    30         testutils.setup_environment("../../../proto")
    31 import pkg5unittest
    31 import pkg5unittest
   429                         else:
   429                         else:
   430                                 pobj.remove_repository(name=r.name)
   430                                 pobj.remove_repository(name=r.name)
   431                                 self.assertRaises(api_errors.UnknownRepository,
   431                                 self.assertRaises(api_errors.UnknownRepository,
   432                                     pobj.get_repository, name=r.name)
   432                                     pobj.get_repository, name=r.name)
   433 
   433 
       
   434                 # Verify that adding, removing, and unsetting ca certs works
       
   435                 # as expected.
       
   436                 pobj.create_meta_root()
       
   437                 self.pub_cas_dir = os.path.join(self.ro_data_root,
       
   438                     "signing_certs", "produced", "publisher_cas")
       
   439                 ca_path = os.path.join(self.pub_cas_dir, "pubCA1_ta3_cert.pem")
       
   440                 with open(ca_path, "rb") as fh:
       
   441                         ca_data = fh.read()
       
   442                 hsh = self.calc_file_hash(ca_path)
       
   443                 # Test revoking a ca cert.
       
   444                 pobj.revoke_ca_cert(hsh)
       
   445                 self.assert_(hsh in pobj.revoked_ca_certs)
       
   446                 # Test moving from revoked to approved
       
   447                 pobj.approve_ca_cert(ca_data, manual=True)
       
   448                 self.assert_(hsh not in pobj.revoked_ca_certs)
       
   449                 self.assert_(hsh in pobj.approved_ca_certs)
       
   450                 self.assert_(hsh in pobj.signing_ca_certs)
       
   451                 # Test unsetting from approved
       
   452                 pobj.unset_ca_cert(hsh)
       
   453                 self.assert_(hsh not in pobj.revoked_ca_certs)
       
   454                 self.assert_(hsh not in pobj.approved_ca_certs)
       
   455                 # Test approving a ca cert
       
   456                 pobj.approve_ca_cert(ca_data, manual=True)
       
   457                 self.assert_(hsh in pobj.approved_ca_certs)
       
   458                 # Test moving from approved to revoked
       
   459                 pobj.revoke_ca_cert(hsh)
       
   460                 self.assert_(hsh in pobj.revoked_ca_certs)
       
   461                 self.assert_(hsh not in pobj.approved_ca_certs)
       
   462                 # Test moving from revoked to unset
       
   463                 pobj.unset_ca_cert(hsh)
       
   464                 self.assert_(hsh not in pobj.revoked_ca_certs)
       
   465                 self.assert_(hsh not in pobj.approved_ca_certs)
       
   466 
   434 
   467 
   435 if __name__ == "__main__":
   468 if __name__ == "__main__":
   436         unittest.main()
   469         unittest.main()
   437 
   470