@@ -35,15 +35,17 @@ func TestSaCache(t *testing.T) {
3535 webhookUsage : prometheus .NewGauge (prometheus.GaugeOpts {}),
3636 }
3737
38- role , aud , useRegionalSTS , tokenExpiration := cache .Get ("default" , "default" )
39-
38+ role , aud , useRegionalSTS , tokenExpiration , err := cache .Get ("default" , "default" )
39+ if err == nil {
40+ t .Fatal ("Expected err to not be empty" )
41+ }
4042 if role != "" || aud != "" {
4143 t .Errorf ("Expected role and aud to be empty, got %s, %s, %t, %d" , role , aud , useRegionalSTS , tokenExpiration )
4244 }
4345
4446 cache .addSA (testSA )
4547
46- role , aud , useRegionalSTS , tokenExpiration = cache .Get ("default" , "default" )
48+ role , aud , useRegionalSTS , tokenExpiration , err = cache .Get ("default" , "default" )
4749
4850 assert .Equal (t , roleArn , role , "Expected role to be %s, got %s" , roleArn , role )
4951 assert .Equal (t , "sts.amazonaws.com" , aud , "Expected aud to be sts.amzonaws.com, got %s" , aud )
@@ -154,7 +156,10 @@ func TestNonRegionalSTS(t *testing.T) {
154156 t .Fatalf ("cache never called addSA: %v" , err )
155157 }
156158
157- gotRoleArn , gotAudience , useRegionalSTS , gotTokenExpiration := cache .Get ("default" , "default" )
159+ gotRoleArn , gotAudience , useRegionalSTS , gotTokenExpiration , err := cache .Get ("default" , "default" )
160+ if err != nil {
161+ t .Fatal (err )
162+ }
158163 if gotRoleArn != roleArn {
159164 t .Errorf ("got roleArn %v, expected %v" , gotRoleArn , roleArn )
160165 }
@@ -199,7 +204,10 @@ func TestPopulateCacheFromCM(t *testing.T) {
199204 t .Errorf ("failed to build cache: %v" , err )
200205 }
201206
202- role , _ , _ , _ := c .Get ("mysa2" , "myns2" )
207+ role , _ , _ , _ , err := c .Get ("mysa2" , "myns2" )
208+ if err != nil {
209+ t .Fatal (err )
210+ }
203211 if role == "" {
204212 t .Errorf ("cloud not find entry that should have been added" )
205213 }
@@ -211,7 +219,10 @@ func TestPopulateCacheFromCM(t *testing.T) {
211219 t .Errorf ("failed to build cache: %v" , err )
212220 }
213221
214- role , _ , _ , _ := c .Get ("mysa2" , "myns2" )
222+ role , _ , _ , _ , err := c .Get ("mysa2" , "myns2" )
223+ if err != nil {
224+ t .Fatal (err )
225+ }
215226 if role == "" {
216227 t .Errorf ("cloud not find entry that should have been added" )
217228 }
@@ -223,7 +234,8 @@ func TestPopulateCacheFromCM(t *testing.T) {
223234 t .Errorf ("failed to build cache: %v" , err )
224235 }
225236
226- role , _ , _ , _ := c .Get ("mysa2" , "myns2" )
237+ role , _ , _ , _ , _ := c .Get ("mysa2" , "myns2" )
238+
227239 if role != "" {
228240 t .Errorf ("found entry that should have been removed" )
229241 }
@@ -253,7 +265,10 @@ func TestSAAnnotationRemoval(t *testing.T) {
253265 c .addSA (oldSA )
254266
255267 {
256- gotRoleArn , _ , _ , _ := c .Get ("default" , "default" )
268+ gotRoleArn , _ , _ , _ , err := c .Get ("default" , "default" )
269+ if err != nil {
270+ t .Fatal (err )
271+ }
257272 if gotRoleArn != roleArn {
258273 t .Errorf ("got roleArn %q, expected %q" , gotRoleArn , roleArn )
259274 }
@@ -265,7 +280,10 @@ func TestSAAnnotationRemoval(t *testing.T) {
265280 c .addSA (newSA )
266281
267282 {
268- gotRoleArn , _ , _ , _ := c .Get ("default" , "default" )
283+ gotRoleArn , _ , _ , _ , err := c .Get ("default" , "default" )
284+ if err != nil {
285+ t .Fatal (err )
286+ }
269287 if gotRoleArn != "" {
270288 t .Errorf ("got roleArn %v, expected %q" , gotRoleArn , "" )
271289 }
@@ -320,7 +338,10 @@ func TestCachePrecedence(t *testing.T) {
320338 t .Errorf ("failed to build cache: %v" , err )
321339 }
322340
323- role , _ , _ , exp := c .Get ("mysa2" , "myns2" )
341+ role , _ , _ , exp , err := c .Get ("mysa2" , "myns2" )
342+ if err != nil {
343+ t .Fatal (err )
344+ }
324345 if role == "" {
325346 t .Errorf ("could not find entry that should have been added" )
326347 }
@@ -337,7 +358,10 @@ func TestCachePrecedence(t *testing.T) {
337358 }
338359
339360 // Removing sa2 from CM, but SA still exists
340- role , _ , _ , exp := c .Get ("mysa2" , "myns2" )
361+ role , _ , _ , exp , err := c .Get ("mysa2" , "myns2" )
362+ if err != nil {
363+ t .Fatal (err )
364+ }
341365 if role == "" {
342366 t .Errorf ("could not find entry that should still exist" )
343367 }
@@ -353,7 +377,10 @@ func TestCachePrecedence(t *testing.T) {
353377 c .addSA (sa2 )
354378
355379 // Neither cache should return any hits now
356- role , _ , _ , _ := c .Get ("myns2" , "mysa2" )
380+ role , _ , _ , _ , err := c .Get ("myns2" , "mysa2" )
381+ if err == nil {
382+ t .Errorf ("found entry that should not exist" )
383+ }
357384 if role != "" {
358385 t .Errorf ("found entry that should not exist" )
359386 }
@@ -367,7 +394,10 @@ func TestCachePrecedence(t *testing.T) {
367394 t .Errorf ("failed to build cache: %v" , err )
368395 }
369396
370- role , _ , _ , exp := c .Get ("mysa2" , "myns2" )
397+ role , _ , _ , exp , err := c .Get ("mysa2" , "myns2" )
398+ if err != nil {
399+ t .Fatal (err )
400+ }
371401 if role == "" {
372402 t .Errorf ("cloud not find entry that should have been added" )
373403 }
0 commit comments