def test_good(self): csrs = [fixtures.CSRData.initial] self.assertSimilarSequence(CSR.all(), csrs) csrs.append(fixtures.CSRData.good) csrs[-1]().save() sortkey = attrgetter("sha256sum") csrs.sort(key=sortkey) self.assertSimilarSequence(sorted(CSR.all(), key=sortkey), csrs) self.assertTrue(csrs[1].match(CSR.by_sha256sum(csrs[1].sha256sum)))
def test_exists_valid(self): sha256sum = fixtures.CSRData.initial.sha256sum csr = CSR.by_sha256sum(sha256sum) now = datetime.datetime.utcnow() self.req.matchdict["sha256"] = sha256sum resp = views.cert_fetch(self.req) # Verify response contents self.assertIsInstance(resp, Response) self.assertEqual(resp.body, csr.certificates[0].pem) self.assertEqual(self.req.response.status_int, 200) # Verify there's a new AccessLog entry self.assertEqual(csr.accessed[0].addr, self.req.remote_addr) self.assertAlmostEqual(csr.accessed[0].when, now, delta=datetime.timedelta(seconds=1))
def test_not_found(self): with self.assertRaises(NoResultFound): CSR.by_sha256sum(fixtures.CSRData.good.sha256sum)