@@ -396,15 +396,19 @@ func TestAddPrecertificate(t *testing.T) {
396396 defer cleanUp ()
397397
398398 reg := createWorkingRegistration (t , sa )
399+ regID := reg .Id
399400
400- // Create a throw-away self signed certificate with a random name and
401- // serial number
401+ // Add a cert to the DB to test with.
402402 serial , testCert := test .ThrowAwayCert (t , clk )
403-
404- // Add the cert as a precertificate
405- regID := reg .Id
403+ _ , err := sa .AddSerial (ctx , & sapb.AddSerialRequest {
404+ RegID : regID ,
405+ Serial : serial ,
406+ Created : timestamppb .New (testCert .NotBefore ),
407+ Expires : timestamppb .New (testCert .NotAfter ),
408+ })
409+ test .AssertNotError (t , err , "failed to add test serial" )
406410 issuedTime := mustTimestamp ("2018-04-01 07:00" )
407- _ , err : = sa .AddPrecertificate (ctx , & sapb.AddCertificateRequest {
411+ _ , err = sa .AddPrecertificate (ctx , & sapb.AddCertificateRequest {
408412 Der : testCert .Raw ,
409413 RegID : regID ,
410414 Issued : issuedTime ,
@@ -413,11 +417,9 @@ func TestAddPrecertificate(t *testing.T) {
413417 test .AssertNotError (t , err , "Couldn't add test cert" )
414418
415419 // It should have the expected certificate status
416- certStatus , err := sa .GetCertificateStatus (ctx , & sapb.Serial {Serial : serial })
420+ certStatus , err := sa .GetRevocationStatus (ctx , & sapb.Serial {Serial : serial })
417421 test .AssertNotError (t , err , "Couldn't get status for test cert" )
418- test .AssertEquals (t , certStatus .Status , string (core .OCSPStatusGood ))
419- now := clk .Now ()
420- test .AssertEquals (t , now , certStatus .OcspLastUpdated .AsTime ())
422+ test .AssertEquals (t , certStatus .Status , core .RevocationStatusGood )
421423
422424 // It should show up in the issued names table
423425 issuedNamesSerial , err := findIssuedName (ctx , sa .dbMap , reverseFQDN (testCert .DNSNames [0 ]))
@@ -1787,10 +1789,9 @@ func TestRevokeCertificate(t *testing.T) {
17871789 sa , fc , cleanUp := initSA (t )
17881790 defer cleanUp ()
17891791
1790- reg := createWorkingRegistration (t , sa )
17911792 // Add a cert to the DB to test with.
1793+ reg := createWorkingRegistration (t , sa )
17921794 serial , testCert := test .ThrowAwayCert (t , fc )
1793- issuedTime := sa .clk .Now ()
17941795 _ , err := sa .AddSerial (ctx , & sapb.AddSerialRequest {
17951796 RegID : reg .Id ,
17961797 Serial : core .SerialToString (testCert .SerialNumber ),
@@ -1801,14 +1802,14 @@ func TestRevokeCertificate(t *testing.T) {
18011802 _ , err = sa .AddPrecertificate (ctx , & sapb.AddCertificateRequest {
18021803 Der : testCert .Raw ,
18031804 RegID : reg .Id ,
1804- Issued : timestamppb .New (issuedTime ),
1805+ Issued : timestamppb .New (testCert . NotBefore ),
18051806 IssuerNameID : 1 ,
18061807 })
18071808 test .AssertNotError (t , err , "Couldn't add test cert" )
18081809
1809- status , err := sa .GetCertificateStatus (ctx , & sapb.Serial {Serial : serial })
1810+ status , err := sa .GetRevocationStatus (ctx , & sapb.Serial {Serial : serial })
18101811 test .AssertNotError (t , err , "GetCertificateStatus failed" )
1811- test .AssertEquals (t , core . OCSPStatus ( status .Status ) , core .OCSPStatusGood )
1812+ test .AssertEquals (t , status .Status , core .RevocationStatusGood )
18121813
18131814 fc .Add (1 * time .Hour )
18141815
@@ -1824,12 +1825,11 @@ func TestRevokeCertificate(t *testing.T) {
18241825 })
18251826 test .AssertNotError (t , err , "RevokeCertificate with no OCSP response should succeed" )
18261827
1827- status , err = sa .GetCertificateStatus (ctx , & sapb.Serial {Serial : serial })
1828+ status , err = sa .GetRevocationStatus (ctx , & sapb.Serial {Serial : serial })
18281829 test .AssertNotError (t , err , "GetCertificateStatus failed" )
1829- test .AssertEquals (t , core . OCSPStatus ( status .Status ) , core .OCSPStatusRevoked )
1830+ test .AssertEquals (t , status .Status , core .RevocationStatusRevoked )
18301831 test .AssertEquals (t , status .RevokedReason , reason )
18311832 test .AssertEquals (t , status .RevokedDate .AsTime (), now )
1832- test .AssertEquals (t , status .OcspLastUpdated .AsTime (), now )
18331833
18341834 _ , err = sa .RevokeCertificate (context .Background (), & sapb.RevokeCertificateRequest {
18351835 IssuerID : 1 ,
@@ -1840,67 +1840,13 @@ func TestRevokeCertificate(t *testing.T) {
18401840 test .AssertError (t , err , "RevokeCertificate should've failed when certificate already revoked" )
18411841}
18421842
1843- func TestRevokeCertificateWithShard (t * testing.T ) {
1844- sa , fc , cleanUp := initSA (t )
1845- defer cleanUp ()
1846-
1847- // Add a cert to the DB to test with.
1848- reg := createWorkingRegistration (t , sa )
1849- eeCert , err := core .LoadCert ("../test/hierarchy/ee-e1.cert.pem" )
1850- test .AssertNotError (t , err , "failed to load test cert" )
1851- _ , err = sa .AddSerial (ctx , & sapb.AddSerialRequest {
1852- RegID : reg .Id ,
1853- Serial : core .SerialToString (eeCert .SerialNumber ),
1854- Created : timestamppb .New (eeCert .NotBefore ),
1855- Expires : timestamppb .New (eeCert .NotAfter ),
1856- })
1857- test .AssertNotError (t , err , "failed to add test serial" )
1858- _ , err = sa .AddPrecertificate (ctx , & sapb.AddCertificateRequest {
1859- Der : eeCert .Raw ,
1860- RegID : reg .Id ,
1861- Issued : timestamppb .New (eeCert .NotBefore ),
1862- IssuerNameID : 1 ,
1863- })
1864- test .AssertNotError (t , err , "failed to add test cert" )
1865-
1866- serial := core .SerialToString (eeCert .SerialNumber )
1867- fc .Add (1 * time .Hour )
1868- now := fc .Now ()
1869- reason := int64 (1 )
1870-
1871- _ , err = sa .RevokeCertificate (context .Background (), & sapb.RevokeCertificateRequest {
1872- IssuerID : 1 ,
1873- ShardIdx : 9 ,
1874- Serial : serial ,
1875- Date : timestamppb .New (now ),
1876- Reason : reason ,
1877- })
1878- test .AssertNotError (t , err , "RevokeCertificate with no OCSP response should succeed" )
1879-
1880- status , err := sa .GetCertificateStatus (ctx , & sapb.Serial {Serial : serial })
1881- test .AssertNotError (t , err , "GetCertificateStatus failed" )
1882- test .AssertEquals (t , core .OCSPStatus (status .Status ), core .OCSPStatusRevoked )
1883- test .AssertEquals (t , status .RevokedReason , reason )
1884- test .AssertEquals (t , status .RevokedDate .AsTime (), now )
1885- test .AssertEquals (t , status .OcspLastUpdated .AsTime (), now )
1886- test .AssertEquals (t , status .NotAfter .AsTime (), eeCert .NotAfter )
1887-
1888- var result revokedCertModel
1889- err = sa .dbMap .SelectOne (
1890- ctx , & result , `SELECT * FROM revokedCertificates WHERE serial = ?` , core .SerialToString (eeCert .SerialNumber ))
1891- test .AssertNotError (t , err , "should be exactly one row in revokedCertificates" )
1892- test .AssertEquals (t , result .ShardIdx , int64 (9 ))
1893- test .AssertEquals (t , result .RevokedReason , revocation .KeyCompromise )
1894- }
1895-
18961843func TestUpdateRevokedCertificate (t * testing.T ) {
18971844 sa , fc , cleanUp := initSA (t )
18981845 defer cleanUp ()
18991846
19001847 // Add a cert to the DB to test with.
19011848 reg := createWorkingRegistration (t , sa )
19021849 serial , testCert := test .ThrowAwayCert (t , fc )
1903- issuedTime := fc .Now ()
19041850 _ , err := sa .AddSerial (ctx , & sapb.AddSerialRequest {
19051851 RegID : reg .Id ,
19061852 Serial : core .SerialToString (testCert .SerialNumber ),
@@ -1911,7 +1857,7 @@ func TestUpdateRevokedCertificate(t *testing.T) {
19111857 _ , err = sa .AddPrecertificate (ctx , & sapb.AddCertificateRequest {
19121858 Der : testCert .Raw ,
19131859 RegID : reg .Id ,
1914- Issued : timestamppb .New (issuedTime ),
1860+ Issued : timestamppb .New (testCert . NotBefore ),
19151861 IssuerNameID : 1 ,
19161862 })
19171863 test .AssertNotError (t , err , "Couldn't add test cert" )
@@ -1944,10 +1890,10 @@ func TestUpdateRevokedCertificate(t *testing.T) {
19441890 test .AssertNotError (t , err , "RevokeCertificate failed" )
19451891
19461892 // Double check that setup worked.
1947- status , err := sa .GetCertificateStatus (ctx , & sapb.Serial {Serial : serial })
1893+ status , err := sa .GetRevocationStatus (ctx , & sapb.Serial {Serial : serial })
19481894 test .AssertNotError (t , err , "GetCertificateStatus failed" )
1949- test .AssertEquals (t , core . OCSPStatus ( status .Status ) , core .OCSPStatusRevoked )
1950- test .AssertEquals (t , revocation . Reason ( status .RevokedReason ), revocation .CessationOfOperation )
1895+ test .AssertEquals (t , status .Status , core .RevocationStatusRevoked )
1896+ test .AssertEquals (t , status .RevokedReason , int64 ( revocation .CessationOfOperation ) )
19511897 fc .Add (1 * time .Hour )
19521898
19531899 // Try to update its revocation info with no backdate
@@ -3000,10 +2946,10 @@ func TestGetRevokedCerts(t *testing.T) {
30002946 test .AssertNotError (t , err , "failed to add test cert" )
30012947
30022948 // Check that it worked.
3003- status , err := sa .GetCertificateStatus (
2949+ status , err := sa .GetRevocationStatus (
30042950 ctx , & sapb.Serial {Serial : core .SerialToString (eeCert .SerialNumber )})
30052951 test .AssertNotError (t , err , "GetCertificateStatus failed" )
3006- test .AssertEquals (t , core . OCSPStatus ( status .Status ) , core .OCSPStatusGood )
2952+ test .AssertEquals (t , status .Status , core .RevocationStatusGood )
30072953
30082954 // Here's a little helper func we'll use to call GetRevokedCerts and count
30092955 // how many results it returned.
@@ -3107,10 +3053,10 @@ func TestGetRevokedCertsByShard(t *testing.T) {
31073053 test .AssertNotError (t , err , "failed to add test cert" )
31083054
31093055 // Check that it worked.
3110- status , err := sa .GetCertificateStatus (
3056+ status , err := sa .GetRevocationStatus (
31113057 ctx , & sapb.Serial {Serial : core .SerialToString (eeCert .SerialNumber )})
31123058 test .AssertNotError (t , err , "GetCertificateStatus failed" )
3113- test .AssertEquals (t , core . OCSPStatus ( status .Status ) , core .OCSPStatusGood )
3059+ test .AssertEquals (t , status .Status , core .RevocationStatusGood )
31143060
31153061 // Here's a little helper func we'll use to call GetRevokedCertsByShard and count
31163062 // how many results it returned.
0 commit comments