@@ -60,9 +60,8 @@ func getPrecertByName(db *sql.DB, reversedName string) (*x509.Certificate, error
6060
6161// TestIssuanceCertStorageFailed tests what happens when a storage RPC fails 
6262// during issuance. Specifically, it tests that case where we successfully 
63- // prepared and stored a linting certificate plus metadata, but after 
64- // issuing the precertificate we failed to mark the certificate as "ready" 
65- // to serve an OCSP "good" response. 
63+ // prepared and stored a linting certificate plus metadata, but failed to store 
64+ // the corresponding final certificate after issuance completed. 
6665// 
6766// To do this, we need to mess with the database, because we want to cause 
6867// a failure in one specific query, without control ever returning to the 
@@ -83,28 +82,26 @@ func TestIssuanceCertStorageFailed(t *testing.T) {
8382	_ , err  =  db .ExecContext (ctx , `DROP TRIGGER IF EXISTS fail_ready` )
8483	test .AssertNotError (t , err , "failed to drop trigger" )
8584
86- 	// Make a specific update to certificateStatus  fail, for this test but not others. 
85+ 	// Make a specific insert into certificates  fail, for this test but not others. 
8786	// To limit the effect to this one test, we make the trigger aware of a specific 
88- 	// hostname used in this test. Since the UPDATE  to the certificateStatus  table 
87+ 	// hostname used in this test. Since the INSERT  to the certificates  table 
8988	// doesn't include the hostname, we look it up in the issuedNames table, keyed 
90- 	// off of the serial being updated. 
91- 	// We limit this to UPDATEs that set the status to "good" because otherwise we 
92- 	// would fail to revoke the certificate later. 
89+ 	// off of the serial. 
9390	// NOTE: CREATE and DROP TRIGGER do not work in prepared statements. Go's 
9491	// database/sql will automatically try to use a prepared statement if you pass 
9592	// any arguments to Exec besides the query itself, so don't do that. 
9693	_ , err  =  db .ExecContext (ctx , ` 
9794		CREATE TRIGGER fail_ready 
98- 		BEFORE UPDATE  ON certificateStatus  
95+ 		BEFORE INSERT  ON certificates  
9996		FOR EACH ROW BEGIN 
10097		DECLARE reversedName1 VARCHAR(255); 
10198		SELECT reversedName 
10299		    INTO reversedName1 
103100			FROM issuedNames 
104101			WHERE serial = NEW.serial 
105102			    AND reversedName LIKE "com.wantserror.%"; 
106- 		IF NEW.status = "good" AND  reversedName1 != "" THEN 
107- 			SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Pretend there was an error updating the certificateStatus '; 
103+ 		IF reversedName1 != "" THEN 
104+ 			SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Pretend there was an error inserting into certificates '; 
108105		END IF; 
109106		END 
110107	` )
@@ -117,7 +114,7 @@ func TestIssuanceCertStorageFailed(t *testing.T) {
117114
118115	// ---- Test revocation by serial ---- 
119116	revokeMeDomain  :=  "revokeme.wantserror.com" 
120- 	// This should fail because the trigger prevented setting  the certificate status to "ready"  
117+ 	// This should fail because the trigger prevented storing  the final certificate.  
121118	_ , err  =  authAndIssue (nil , certKey , []acme.Identifier {{Type : "dns" , Value : revokeMeDomain }}, true , "" )
122119	test .AssertError (t , err , "expected authAndIssue to fail" )
123120
@@ -140,7 +137,7 @@ func TestIssuanceCertStorageFailed(t *testing.T) {
140137
141138	// ---- Test revocation by key ---- 
142139	blockMyKeyDomain  :=  "blockmykey.wantserror.com" 
143- 	// This should fail because the trigger prevented setting  the certificate status to "ready"  
140+ 	// This should fail because the trigger prevented storing  the final certificate.  
144141	_ , err  =  authAndIssue (nil , certKey , []acme.Identifier {{Type : "dns" , Value : blockMyKeyDomain }}, true , "" )
145142	test .AssertError (t , err , "expected authAndIssue to fail" )
146143
0 commit comments