def test_whitelist_creation(self): whitelist = cvmfs.Whitelist(self.sane_whitelist) last_modified = datetime.datetime(2015, 6, 3, 9, 55, 27, tzinfo=tzutc()) expires = datetime.datetime(2015, 7, 4, 9, 55, 27, tzinfo=tzutc()) self.assertTrue(hasattr(whitelist, 'last_modified')) self.assertTrue(hasattr(whitelist, 'expires')) self.assertTrue(hasattr(whitelist, 'repository_name')) self.assertTrue(hasattr(whitelist, 'fingerprints')) self.assertEqual(last_modified, whitelist.last_modified) self.assertEqual(expires, whitelist.expires) self.assertEqual('atlas.cern.ch', whitelist.repository_name) self.assertEqual(3, len(whitelist.fingerprints))
def test_non_expired_whitelist(self): whitelist = cvmfs.Whitelist(self.time_valid_whitelist) self.assertFalse(whitelist.expired())
def test_expired_whitelist(self): whitelist = cvmfs.Whitelist(self.expired_whitelist) self.assertTrue(whitelist.expired())
def test_doesnt_contain_certificate(self): with open(self.certificate_file) as cert: whitelist = cvmfs.Whitelist( self.insane_whitelist_signature_mismatch) certificate = cvmfs.Certificate(cert) self.assertFalse(whitelist.contains(certificate))
def test_contains_certificate(self): with open(self.certificate_file) as cert: whitelist = cvmfs.Whitelist(self.sane_whitelist) certificate = cvmfs.Certificate(cert) self.assertTrue(whitelist.contains(certificate))
def test_verify_malformed_signature(self): whitelist = cvmfs.Whitelist(self.insane_whitelist_broken_signature) signature_valid = whitelist.verify_signature(self.public_key_file) self.assertFalse(signature_valid)
def test_verify_mismatching_signature(self): whitelist = cvmfs.Whitelist(self.insane_whitelist_signature_mismatch) signature_valid = whitelist.verify_signature(self.public_key_file) self.assertFalse(signature_valid)
def test_verify_signature(self): whitelist = cvmfs.Whitelist(self.sane_whitelist) signature_valid = whitelist.verify_signature(self.public_key_file) self.assertTrue(signature_valid)