@@ -93,7 +93,10 @@ func TestRevokeIncidentTableSerials(t *testing.T) {
9393 test .Assert (t , len (testCtx .log .GetAllMatching ("No serials found in incident table" )) > 0 , "Expected log output not found" )
9494 testCtx .log .Clear ()
9595
96- _ , err = testIncidentsDbMap .Exec (
96+ ctx := context .Background ()
97+
98+ _ , err = testIncidentsDbMap .ExecContext (
99+ ctx ,
97100 fmt .Sprintf ("INSERT INTO incident_foo (%s) VALUES ('%s', %d, %d, '%s')" ,
98101 "serial, registrationID, orderID, lastNoticeSent" ,
99102 core .SerialToString (entries [0 ].serial ),
@@ -104,14 +107,14 @@ func TestRevokeIncidentTableSerials(t *testing.T) {
104107 )
105108 test .AssertNotError (t , err , "while inserting row into incident table" )
106109
107- err = testCtx .revoker .revokeIncidentTableSerials (context . Background () , "incident_foo" , 0 , 1 )
110+ err = testCtx .revoker .revokeIncidentTableSerials (ctx , "incident_foo" , 0 , 1 )
108111 test .AssertNotError (t , err , "revokeIncidentTableSerials failed" )
109112
110113 // Ensure that a populated incident table results in the expected log output.
111114 test .AssertNotError (t , err , "revokeIncidentTableSerials failed" )
112115 test .Assert (t , len (testCtx .log .GetAllMatching ("No serials found in incident table" )) <= 0 , "Expected log output not found" )
113116
114- status , err := testCtx .ssa .GetCertificateStatus (context . Background () , & sapb.Serial {Serial : core .SerialToString (entries [0 ].serial )})
117+ status , err := testCtx .ssa .GetCertificateStatus (ctx , & sapb.Serial {Serial : core .SerialToString (entries [0 ].serial )})
115118 test .AssertNotError (t , err , "failed to retrieve certificate status" )
116119 test .AssertEquals (t , core .OCSPStatus (status .Status ), core .OCSPStatusRevoked )
117120}
@@ -143,9 +146,11 @@ func TestBlockAndRevokeByPrivateKey(t *testing.T) {
143146 spkiHash , err := getPublicKeySPKIHash (& duplicateEntry .testKey .PublicKey )
144147 test .AssertNotError (t , err , "Failed to get SPKI hash for dupe." )
145148
149+ ctx := context .Background ()
150+
146151 // Ensure that the SPKI hash hasn't already been added to the blockedKeys
147152 // table.
148- keyExists , err := testCtx .revoker .spkiHashInBlockedKeys (spkiHash )
153+ keyExists , err := testCtx .revoker .spkiHashInBlockedKeys (ctx , spkiHash )
149154 test .AssertNotError (t , err , "countCertsMatchingSPKIHash for dupe failed" )
150155 test .Assert (t , ! keyExists , "SPKI hash should not be in blockedKeys" )
151156
@@ -155,19 +160,19 @@ func TestBlockAndRevokeByPrivateKey(t *testing.T) {
155160 switch e .names [0 ] {
156161 case uniqueEntries [0 ].names [0 ]:
157162 // example-1337.com
158- count , err := testCtx .revoker .countCertsMatchingSPKIHash (e .spkiHash )
163+ count , err := testCtx .revoker .countCertsMatchingSPKIHash (ctx , e .spkiHash )
159164 test .AssertNotError (t , err , "countCertsMatchingSPKIHash for entry failed" )
160165 test .AssertEquals (t , count , 2 )
161166
162167 case uniqueEntries [1 ].names [0 ]:
163168 // example-1338.com
164- count , err := testCtx .revoker .countCertsMatchingSPKIHash (e .spkiHash )
169+ count , err := testCtx .revoker .countCertsMatchingSPKIHash (ctx , e .spkiHash )
165170 test .AssertNotError (t , err , "countCertsMatchingSPKIHash for entry failed" )
166171 test .AssertEquals (t , count , 1 )
167172
168173 case uniqueEntries [2 ].names [0 ]:
169174 // example-1339.com
170- count , err := testCtx .revoker .countCertsMatchingSPKIHash (e .spkiHash )
175+ count , err := testCtx .revoker .countCertsMatchingSPKIHash (ctx , e .spkiHash )
171176 test .AssertNotError (t , err , "countCertsMatchingSPKIHash for entry failed" )
172177 test .AssertEquals (t , count , 1 )
173178 }
@@ -184,7 +189,7 @@ func TestBlockAndRevokeByPrivateKey(t *testing.T) {
184189 test .AssertNotError (t , err , "While attempting to revoke certificates for the provided key" )
185190
186191 // Ensure that the key is not blocked, yet.
187- keyExists , err = testCtx .revoker .spkiHashInBlockedKeys (spkiHash )
192+ keyExists , err = testCtx .revoker .spkiHashInBlockedKeys (ctx , spkiHash )
188193 test .AssertNotError (t , err , "countCertsMatchingSPKIHash for dupe failed" )
189194 test .Assert (t , ! keyExists , "SPKI hash should not be in blockedKeys" )
190195
@@ -193,7 +198,7 @@ func TestBlockAndRevokeByPrivateKey(t *testing.T) {
193198 test .AssertNotError (t , err , "While attempting to block issuance for the provided key" )
194199
195200 // Ensure that the key is now blocked.
196- keyExists , err = testCtx .revoker .spkiHashInBlockedKeys (spkiHash )
201+ keyExists , err = testCtx .revoker .spkiHashInBlockedKeys (ctx , spkiHash )
197202 test .AssertNotError (t , err , "countCertsMatchingSPKIHash for dupe failed" )
198203 test .Assert (t , keyExists , "SPKI hash should not be in blockedKeys" )
199204
@@ -203,6 +208,7 @@ func TestBlockAndRevokeByPrivateKey(t *testing.T) {
203208}
204209
205210func TestPrivateKeyBlock (t * testing.T ) {
211+ ctx := context .Background ()
206212 testCtx := setup (t )
207213 defer testCtx .cleanUp ()
208214
@@ -231,35 +237,35 @@ func TestPrivateKeyBlock(t *testing.T) {
231237
232238 // Query the 'keyHashToSerial' table for certificates with a matching SPKI
233239 // hash. We expect that since this key was re-used we'll find 2 matches.
234- count , err := testCtx .revoker .countCertsMatchingSPKIHash (duplicateKeySPKI )
240+ count , err := testCtx .revoker .countCertsMatchingSPKIHash (ctx , duplicateKeySPKI )
235241 test .AssertNotError (t , err , "countCertsMatchingSPKIHash for dupe failed" )
236242 test .AssertEquals (t , count , 2 )
237243
238244 // With dryRun=true this should not block the key.
239- err = privateKeyBlock (& testCtx .revoker , true , "" , count , duplicateKeySPKI , duplicateKeyFile .Name ())
245+ err = privateKeyBlock (ctx , & testCtx .revoker , true , "" , count , duplicateKeySPKI , duplicateKeyFile .Name ())
240246 test .AssertNotError (t , err , "While attempting to block issuance for the provided key" )
241247
242248 // Ensure that the key is not blocked, yet.
243- keyExists , err := testCtx .revoker .spkiHashInBlockedKeys (duplicateKeySPKI )
249+ keyExists , err := testCtx .revoker .spkiHashInBlockedKeys (ctx , duplicateKeySPKI )
244250 test .AssertNotError (t , err , "countCertsMatchingSPKIHash for dupe failed" )
245251 test .Assert (t , ! keyExists , "SPKI hash should not be in blockedKeys" )
246252
247253 // With dryRun=false this should block the key.
248254 comment := "key blocked as part of test"
249- err = privateKeyBlock (& testCtx .revoker , false , comment , count , duplicateKeySPKI , duplicateKeyFile .Name ())
255+ err = privateKeyBlock (ctx , & testCtx .revoker , false , comment , count , duplicateKeySPKI , duplicateKeyFile .Name ())
250256 test .AssertNotError (t , err , "While attempting to block issuance for the provided key" )
251257
252258 // With dryRun=false this should result in an error as the key is already blocked.
253- err = privateKeyBlock (& testCtx .revoker , false , "" , count , duplicateKeySPKI , duplicateKeyFile .Name ())
259+ err = privateKeyBlock (ctx , & testCtx .revoker , false , "" , count , duplicateKeySPKI , duplicateKeyFile .Name ())
254260 test .AssertError (t , err , "Attempting to block a key which is already blocked should have failed." )
255261
256262 // Ensure that the key is now blocked.
257- keyExists , err = testCtx .revoker .spkiHashInBlockedKeys (duplicateKeySPKI )
263+ keyExists , err = testCtx .revoker .spkiHashInBlockedKeys (ctx , duplicateKeySPKI )
258264 test .AssertNotError (t , err , "countCertsMatchingSPKIHash for dupe failed" )
259265 test .Assert (t , keyExists , "SPKI hash should not be in blockedKeys" )
260266
261267 // Ensure that the comment was set as expected
262- commentFromDB , err := testCtx .dbMap .SelectStr ("SELECT comment from blockedKeys WHERE keyHash = ?" , duplicateKeySPKI )
268+ commentFromDB , err := testCtx .dbMap .SelectStr (ctx , "SELECT comment from blockedKeys WHERE keyHash = ?" , duplicateKeySPKI )
263269 test .AssertNotError (t , err , "Failed to get comment from database" )
264270 u , err := user .Current ()
265271 test .AssertNotError (t , err , "Failed to get current user" )
@@ -268,6 +274,7 @@ func TestPrivateKeyBlock(t *testing.T) {
268274}
269275
270276func TestPrivateKeyRevoke (t * testing.T ) {
277+ ctx := context .Background ()
271278 testCtx := setup (t )
272279 defer testCtx .cleanUp ()
273280
@@ -296,7 +303,7 @@ func TestPrivateKeyRevoke(t *testing.T) {
296303
297304 // Query the 'keyHashToSerial' table for certificates with a matching SPKI
298305 // hash. We expect that since this key was re-used we'll find 2 matches.
299- count , err := testCtx .revoker .countCertsMatchingSPKIHash (duplicateKeySPKI )
306+ count , err := testCtx .revoker .countCertsMatchingSPKIHash (ctx , duplicateKeySPKI )
300307 test .AssertNotError (t , err , "countCertsMatchingSPKIHash for dupe failed" )
301308 test .AssertEquals (t , count , 2 )
302309
@@ -305,7 +312,7 @@ func TestPrivateKeyRevoke(t *testing.T) {
305312 test .AssertNotError (t , err , "While attempting to block issuance for the provided key" )
306313
307314 // Ensure that the key is not blocked, yet.
308- keyExists , err := testCtx .revoker .spkiHashInBlockedKeys (duplicateKeySPKI )
315+ keyExists , err := testCtx .revoker .spkiHashInBlockedKeys (ctx , duplicateKeySPKI )
309316 test .AssertNotError (t , err , "spkiHashInBlockedKeys failed for key that shouldn't be blocked yet" )
310317 test .Assert (t , ! keyExists , "SPKI hash should not be in blockedKeys" )
311318
@@ -315,12 +322,12 @@ func TestPrivateKeyRevoke(t *testing.T) {
315322 test .AssertNotError (t , err , "While attempting to block issuance for the provided key" )
316323
317324 // Ensure that the key is now blocked.
318- keyExists , err = testCtx .revoker .spkiHashInBlockedKeys (duplicateKeySPKI )
325+ keyExists , err = testCtx .revoker .spkiHashInBlockedKeys (ctx , duplicateKeySPKI )
319326 test .AssertNotError (t , err , "spkiHashInBlockedKeys failed for key that should now be blocked" )
320327 test .Assert (t , keyExists , "SPKI hash should not be in blockedKeys" )
321328
322329 // Ensure that the comment was set as expected
323- commentFromDB , err := testCtx .dbMap .SelectStr ("SELECT comment from blockedKeys WHERE keyHash = ?" , duplicateKeySPKI )
330+ commentFromDB , err := testCtx .dbMap .SelectStr (ctx , "SELECT comment from blockedKeys WHERE keyHash = ?" , duplicateKeySPKI )
324331 test .AssertNotError (t , err , "Failed to get comment from database" )
325332 u , err := user .Current ()
326333 test .AssertNotError (t , err , "Failed to get current user" )
0 commit comments