@@ -287,27 +287,58 @@ public void testProviderRefresh() throws Exception {
287287
288288 List <String > credentialsLog = getOutputLines ();
289289
290+ // Assert that individual messages occur at least once in the credentials log
291+ String generatingMsg = "Generating App Installation Token for app ID 54321" ;
292+ String failedMsg =
293+ "Failed to generate new GitHub App Installation Token for app ID 54321: cached token is stale but has not expired" ;
294+
295+ // Be sure the expected messages are in the log
296+ assertThat (credentialsLog , hasItem (generatingMsg ));
297+ assertThat (credentialsLog , hasItem (failedMsg ));
298+
290299 // Verify correct messages from GitHubAppCredential logger indicating token was retrieved on
291300 // agent
292- assertThat (
293- "Creds should cache on master" ,
294- credentialsLog ,
295- contains (
296- // refresh on controller
297- "Generating App Installation Token for app ID 54321" ,
298- // next call uses cached token
299- // sleep and then refresh stale token
300- "Generating App Installation Token for app ID 54321" ,
301- // next call (error forced by wiremock)
302- "Failed to generate new GitHub App Installation Token for app ID 54321: cached token is stale but has not expired" ,
303- // next call refreshes the still stale token
304- "Generating App Installation Token for app ID 54321" ,
305- // sleep and then refresh stale token hits another error forced by wiremock
306- "Failed to generate new GitHub App Installation Token for app ID 54321: cached token is stale but has not expired" ,
307- // next call refreshes the still stale token
308- "Generating App Installation Token for app ID 54321"
309- // next call uses cached token
310- ));
301+ if (credentialsLog .get (2 ).equals (failedMsg )) {
302+ assertThat (
303+ "Creds should cache on master - typical order" ,
304+ credentialsLog ,
305+ contains (
306+ // refresh on controller
307+ generatingMsg ,
308+ // next call uses cached token
309+ // sleep and then refresh stale token
310+ generatingMsg ,
311+ // next call (error forced by wiremock)
312+ failedMsg ,
313+ // next call refreshes the still stale token
314+ generatingMsg ,
315+ // sleep and then refresh stale token hits another error forced by wiremock
316+ failedMsg ,
317+ // next call refreshes the still stale token
318+ generatingMsg
319+ // next call uses cached token
320+ ));
321+ } else {
322+ assertThat (
323+ "Creds should cache on master - alternate order" ,
324+ credentialsLog ,
325+ contains (
326+ // refresh on controller
327+ generatingMsg ,
328+ // next call uses cached token
329+ // sleep and then refresh stale token
330+ generatingMsg ,
331+ // next call refreshes the still stale token
332+ generatingMsg ,
333+ // next call (error forced by wiremock)
334+ failedMsg ,
335+ // sleep and then refresh stale token hits another error forced by wiremock
336+ failedMsg ,
337+ // next call refreshes the still stale token
338+ generatingMsg
339+ // next call uses cached token
340+ ));
341+ }
311342
312343 // Getting the token for via AuthorizationProvider on controller should not check rate_limit
313344 githubApi .verify (
0 commit comments