Skip to content

Commit b9e126f

Browse files
committed
Update TestIssuanceCertStorageFailed
1 parent 3cfdf4d commit b9e126f

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

test/integration/cert_storage_failed_test.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,28 +83,26 @@ func TestIssuanceCertStorageFailed(t *testing.T) {
8383
_, err = db.ExecContext(ctx, `DROP TRIGGER IF EXISTS fail_ready`)
8484
test.AssertNotError(t, err, "failed to drop trigger")
8585

86-
// Make a specific update to certificateStatus fail, for this test but not others.
86+
// Make a specific insert into certificates fail, for this test but not others.
8787
// 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
88+
// hostname used in this test. Since the INSERT to the certificates table
8989
// 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.
90+
// off of the serial.
9391
// NOTE: CREATE and DROP TRIGGER do not work in prepared statements. Go's
9492
// database/sql will automatically try to use a prepared statement if you pass
9593
// any arguments to Exec besides the query itself, so don't do that.
9694
_, err = db.ExecContext(ctx, `
9795
CREATE TRIGGER fail_ready
98-
BEFORE UPDATE ON certificateStatus
96+
BEFORE INSERT ON certificates
9997
FOR EACH ROW BEGIN
10098
DECLARE reversedName1 VARCHAR(255);
10199
SELECT reversedName
102100
INTO reversedName1
103101
FROM issuedNames
104102
WHERE serial = NEW.serial
105103
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';
104+
IF reversedName1 != "" THEN
105+
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Pretend there was an error inserting into certificates';
108106
END IF;
109107
END
110108
`)
@@ -117,7 +115,7 @@ func TestIssuanceCertStorageFailed(t *testing.T) {
117115

118116
// ---- Test revocation by serial ----
119117
revokeMeDomain := "revokeme.wantserror.com"
120-
// This should fail because the trigger prevented setting the certificate status to "ready"
118+
// This should fail because the trigger prevented storing the final certificate.
121119
_, err = authAndIssue(nil, certKey, []acme.Identifier{{Type: "dns", Value: revokeMeDomain}}, true, "")
122120
test.AssertError(t, err, "expected authAndIssue to fail")
123121

@@ -140,7 +138,7 @@ func TestIssuanceCertStorageFailed(t *testing.T) {
140138

141139
// ---- Test revocation by key ----
142140
blockMyKeyDomain := "blockmykey.wantserror.com"
143-
// This should fail because the trigger prevented setting the certificate status to "ready"
141+
// This should fail because the trigger prevented storing the final certificate.
144142
_, err = authAndIssue(nil, certKey, []acme.Identifier{{Type: "dns", Value: blockMyKeyDomain}}, true, "")
145143
test.AssertError(t, err, "expected authAndIssue to fail")
146144

0 commit comments

Comments
 (0)