@@ -36,16 +36,18 @@ func TestSaCache(t *testing.T) {
3636 webhookUsage : prometheus .NewGauge (prometheus.GaugeOpts {}),
3737 }
3838
39- role , aud , useRegionalSTS , tokenExpiration := cache .Get ("default" , "default" )
39+ role , aud , useRegionalSTS , tokenExpiration , found := cache .Get ("default" , "default" )
4040
41+ assert .False (t , found , "Expected no cache entry to be found" )
4142 if role != "" || aud != "" {
4243 t .Errorf ("Expected role and aud to be empty, got %s, %s, %t, %d" , role , aud , useRegionalSTS , tokenExpiration )
4344 }
4445
4546 cache .addSA (testSA )
4647
47- role , aud , useRegionalSTS , tokenExpiration = cache .Get ("default" , "default" )
48+ role , aud , useRegionalSTS , tokenExpiration , found = cache .Get ("default" , "default" )
4849
50+ assert .True (t , found , "Expected cache entry to be found" )
4951 assert .Equal (t , roleArn , role , "Expected role to be %s, got %s" , roleArn , role )
5052 assert .Equal (t , "sts.amazonaws.com" , aud , "Expected aud to be sts.amzonaws.com, got %s" , aud )
5153 assert .True (t , useRegionalSTS , "Expected regional STS to be true, got false" )
@@ -157,7 +159,8 @@ func TestNonRegionalSTS(t *testing.T) {
157159 t .Fatalf ("cache never called addSA: %v" , err )
158160 }
159161
160- gotRoleArn , gotAudience , useRegionalSTS , gotTokenExpiration := cache .Get ("default" , "default" )
162+ gotRoleArn , gotAudience , useRegionalSTS , gotTokenExpiration , found := cache .Get ("default" , "default" )
163+ assert .True (t , found , "Expected cache entry to be found" )
161164 if gotRoleArn != roleArn {
162165 t .Errorf ("got roleArn %v, expected %v" , gotRoleArn , roleArn )
163166 }
@@ -202,7 +205,7 @@ func TestPopulateCacheFromCM(t *testing.T) {
202205 t .Errorf ("failed to build cache: %v" , err )
203206 }
204207
205- role , _ , _ , _ := c .Get ("mysa2" , "myns2" )
208+ role , _ , _ , _ , _ := c .Get ("mysa2" , "myns2" )
206209 if role == "" {
207210 t .Errorf ("cloud not find entry that should have been added" )
208211 }
@@ -214,7 +217,7 @@ func TestPopulateCacheFromCM(t *testing.T) {
214217 t .Errorf ("failed to build cache: %v" , err )
215218 }
216219
217- role , _ , _ , _ := c .Get ("mysa2" , "myns2" )
220+ role , _ , _ , _ , _ := c .Get ("mysa2" , "myns2" )
218221 if role == "" {
219222 t .Errorf ("cloud not find entry that should have been added" )
220223 }
@@ -226,7 +229,7 @@ func TestPopulateCacheFromCM(t *testing.T) {
226229 t .Errorf ("failed to build cache: %v" , err )
227230 }
228231
229- role , _ , _ , _ := c .Get ("mysa2" , "myns2" )
232+ role , _ , _ , _ , _ := c .Get ("mysa2" , "myns2" )
230233 if role != "" {
231234 t .Errorf ("found entry that should have been removed" )
232235 }
@@ -256,7 +259,7 @@ func TestSAAnnotationRemoval(t *testing.T) {
256259 c .addSA (oldSA )
257260
258261 {
259- gotRoleArn , _ , _ , _ := c .Get ("default" , "default" )
262+ gotRoleArn , _ , _ , _ , _ := c .Get ("default" , "default" )
260263 if gotRoleArn != roleArn {
261264 t .Errorf ("got roleArn %q, expected %q" , gotRoleArn , roleArn )
262265 }
@@ -268,7 +271,7 @@ func TestSAAnnotationRemoval(t *testing.T) {
268271 c .addSA (newSA )
269272
270273 {
271- gotRoleArn , _ , _ , _ := c .Get ("default" , "default" )
274+ gotRoleArn , _ , _ , _ , _ := c .Get ("default" , "default" )
272275 if gotRoleArn != "" {
273276 t .Errorf ("got roleArn %v, expected %q" , gotRoleArn , "" )
274277 }
@@ -323,7 +326,7 @@ func TestCachePrecedence(t *testing.T) {
323326 t .Errorf ("failed to build cache: %v" , err )
324327 }
325328
326- role , _ , _ , exp := c .Get ("mysa2" , "myns2" )
329+ role , _ , _ , exp , _ := c .Get ("mysa2" , "myns2" )
327330 if role == "" {
328331 t .Errorf ("could not find entry that should have been added" )
329332 }
@@ -340,7 +343,7 @@ func TestCachePrecedence(t *testing.T) {
340343 }
341344
342345 // Removing sa2 from CM, but SA still exists
343- role , _ , _ , exp := c .Get ("mysa2" , "myns2" )
346+ role , _ , _ , exp , _ := c .Get ("mysa2" , "myns2" )
344347 if role == "" {
345348 t .Errorf ("could not find entry that should still exist" )
346349 }
@@ -356,7 +359,7 @@ func TestCachePrecedence(t *testing.T) {
356359 c .addSA (sa2 )
357360
358361 // Neither cache should return any hits now
359- role , _ , _ , _ := c .Get ("myns2" , "mysa2" )
362+ role , _ , _ , _ , _ := c .Get ("myns2" , "mysa2" )
360363 if role != "" {
361364 t .Errorf ("found entry that should not exist" )
362365 }
@@ -370,7 +373,7 @@ func TestCachePrecedence(t *testing.T) {
370373 t .Errorf ("failed to build cache: %v" , err )
371374 }
372375
373- role , _ , _ , exp := c .Get ("mysa2" , "myns2" )
376+ role , _ , _ , exp , _ := c .Get ("mysa2" , "myns2" )
374377 if role == "" {
375378 t .Errorf ("cloud not find entry that should have been added" )
376379 }
@@ -422,7 +425,7 @@ func TestRoleArnComposition(t *testing.T) {
422425
423426 var roleArn string
424427 err := wait .ExponentialBackoff (wait.Backoff {Duration : 10 * time .Millisecond , Factor : 1.0 , Steps : 3 }, func () (bool , error ) {
425- roleArn , _ , _ , _ = cache .Get ("default" , "default" )
428+ roleArn , _ , _ , _ , _ = cache .Get ("default" , "default" )
426429 return roleArn != "" , nil
427430 })
428431 if err != nil {
0 commit comments