@@ -23,7 +23,8 @@ const sampleAccessKey = "eyJhbGciOiJSUzI1NiIsImtpZCI6InB1YmxpYzpmODg2ZDBmNy0zYmY
2323
2424const sampleWellKnownJwk = "{\" keys\" :[{\" use\" :\" sig\" ,\" kty\" :\" RSA\" ,\" kid\" :\" public:f886d0f7-3bf4-4338-8e8c-5f8c6ee4c71d\" ,\" alg\" :\" RS256\" ,\" n\" :\" 43g42b14fJGjB9wVMrYlk6L1Aig7HWt5Aere0AQQC3tdJdmzwvyCA4rYKDB2rTHSgN-xSWq12rtgrZIfjNHFj8w4p04U0aXhWFb_bVs0TTLrdlb9syAidX1H3JAwKngqHC3zkDRzVsKUKQCGSl2IScLR6B6eclgCsPL9O-SKA7BwdH3XHz3lFBhpc3Fn_TMMd2q44YQH8JWGKJPXiVHR6XB3w2IwNtFEbE3D2HpimRxP7GpGDMYFq1_eCFYUSdSK39dTfXj-SeQ0tM_voWNrS1ydH9eC5Au0zLaxWskco_8dKiGWYoQzep_Od4tlc_l2GDFoXhCOeb_6e3NENFGkef1ewPyX-hUguYm7OxBYwauBi6LTZYTkSHKocG1wT_XyE2QB7TEb2F1KQ_4WhLicGlOz4biVSs75v9FSPHFhMJ_ZpzjReYdTUJVBoQI2HMo5vElgxB79GgzCp-cp4286_OW1QnDfpvkgDIJtYnedNMmMWCpLTwtswYqO5lucCjR-jYukuV36NDuDOV1b-UqPQh95IScZUca6kVEU_5vcbiXaf24cDcVlMbN854HIYBzWinqrn_YX1mATrq6uoHT9Frth_pMJSop28iX5861p2dLdY0wBlb-x1YbQ8m5eoM7WMIDL1VVcoorecR6L_LS3App_XbaDSrtEE7wbS5iqyjk\" ,\" e\" :\" AQAB\" },{\" use\" :\" sig\" ,\" kty\" :\" RSA\" ,\" kid\" :\" public:0a7dad6b-ee8c-4d8a-8692-741770246f74\" ,\" alg\" :\" RS256\" ,\" n\" :\" x8zZj5GjuhJ4yABn2X1bCZi3jGJEIROqJxSNFt7lCi-IVMKbENudWL0HQxtnkglRitdAZXaiXToo5eWl-eWEIeK0p501PIX1Iq32BPehUI6H7t7Xth-0C65Ub2_Aho5QKCyXNH2mi75yyWIXLk0EWzgP_2H32BzS2w3OHjrogino7h0Neo98Q_727fKbTkreOLRyrvTNJWzpPrhoodz4UsT9EyY9eAW6kdaBl4k05qDm52BZM2PT4ToMeP3kMTFx_2aeoiegjaNkV2G5ONCLlYOHp3n8Hek_V_--695jaWvHgsWprykZ9KEX0nwhgy3B8DT329I9huf0vtjDqe1-Dd6qMwcMII8OT3i0_fp7rIlJUweufEIHpRVyR4KXfrsH8BP3V4Qyh_4o6IsaQpBcbNaKqSPgtOpySkJJkK0XbbRY7YcDZyCIbdpVfZHmz2sGspQ9wk0-bg8I2QJVJ6QvIP7lo_rysTjAjuMMw-e6rNuBO-zPVZumt9qOelupFhXhuk54gP_kWK3yCLdkwGHBloelbptDJLVK9IyYcPbEIxMLafIiOJ5XVFi5sEuSsvhEu9yi2M2c-BY4hlmxYuZPvGkwmxqFP2X4JQhnYAKhrdk7Hj6A2TnXhWOJu5v9L-JOkaY3MDuE3dQVMX90S_XsXD_Ew6mzUsF3BvY911glHxs\" ,\" e\" :\" AQAB\" }]}"
2525
26- const tenantWellKnownJwk = "{\" keys\" :[{\" use\" :\" sig\" ,\" kty\" :\" RSA\" ,\" kid\" :\" 30c43677-4c0d-4191-bff1-5ced49059f4f\" ,\" alg\" :\" RS256\" ,\" n\" :\" 5E0LW8-pnWJJof9SWVmyOfnijHXeJn7ZUZ0FywAzKjgj5oGJvxMQO0mxa3OTySTkHl0keJecEfxhbHyQOmt_RsGXfjOaKTsVblJwgEyC_LxFn4qCP1KV5m1G_2uSNoImMrBrWXYDwt7cd3Bvk7cUHUrW5YINqpNGv1-BPobq2gCI06mJxESyWH0qJYrCWhJoXUp_pZp4UFa1IzLqK_V0m6kIVg-ad_F6Lzd0MDq2DSRM-iNpQLURGAlvTZKyJEchVG17t4zK9bq21WgF7ses8_zDY_-2xyPPUNRMR76dAHUdnJrBd08XhDuq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7q2C1wLaDN-NwwJZRT6d8Hwesy1jasqzQ9GxM0aRPEp4rrcMnUQfc2U05-YWc91-dFk5SrjLmJ5JfJc0q8w_jQdvB6HOGsyhQyNa9gN8\" ,\" e\" :\" AQAB\" }]}"
26+ // testContextKey is a custom type for context keys to avoid collisions.
27+ type testContextKey string
2728
2829// AuthenticationTestSuite extends FrameBaseTestSuite for comprehensive authentication testing.
2930type AuthenticationTestSuite struct {
@@ -171,7 +172,7 @@ func (s *AuthenticationTestSuite) TestSimpleAuthenticate() {
171172 }
172173
173174 for _ , tc := range testCases {
174- s .T (). Run (tc .name , func (t * testing. T ) {
175+ s .Run (tc .name , func () {
175176 // Create authenticator directly with mock config
176177 auth := openid .NewJwtTokenAuthenticator (& mockJWTConfig {
177178 ConfigurationDefault : config.ConfigurationDefault {
@@ -181,28 +182,28 @@ func (s *AuthenticationTestSuite) TestSimpleAuthenticate() {
181182 jwksURL : s .jwksURL ,
182183 })
183184
184- ctx := t .Context ()
185-
185+ ctx := s . T () .Context ()
186+
186187 var opts []security.AuthOption
187188 if tc .audience != "" {
188189 opts = append (opts , security .WithAudience (tc .audience ))
189190 }
190191 if tc .issuer != "" {
191192 opts = append (opts , security .WithIssuer (tc .issuer ))
192193 }
193-
194+
194195 ctx2 , err := auth .Authenticate (ctx , tc .accessKey , opts ... )
195196
196197 if tc .expectError {
197- require . Error (t , err , "expected authentication to fail" )
198+ s . Require (). Error (err , "expected authentication to fail" )
198199 return
199200 }
200201
201- require . NoError (t , err , "authentication should succeed" )
202+ s . Require (). NoError (err , "authentication should succeed" )
202203
203204 if tc .expectClaims {
204205 claims := security .ClaimsFromContext (ctx2 )
205- require . NotNil (t , claims , "expected authentication claims in context" )
206+ s . Require (). NotNil (claims , "expected authentication claims in context" )
206207 }
207208 })
208209 }
@@ -260,7 +261,7 @@ func (s *AuthenticationTestSuite) TestTenancySkipFunctions() {
260261 ctx = security .SkipTenancyChecksFromMap (ctx , m )
261262 return ctx , m
262263 },
263- checkResult : func (t * testing.T , ctx context.Context , m map [string ]string ) {
264+ checkResult : func (t * testing.T , ctx context.Context , _ map [string ]string ) {
264265 require .True (t , security .IsTenancyChecksOnClaimSkipped (ctx ), "tenancy checks should be skipped" )
265266 },
266267 },
@@ -271,7 +272,7 @@ func (s *AuthenticationTestSuite) TestTenancySkipFunctions() {
271272 ctx = security .SkipTenancyChecksFromMap (ctx , m )
272273 return ctx , m
273274 },
274- checkResult : func (t * testing.T , ctx context.Context , m map [string ]string ) {
275+ checkResult : func (t * testing.T , ctx context.Context , _ map [string ]string ) {
275276 require .False (t , security .IsTenancyChecksOnClaimSkipped (ctx ), "tenancy checks should not be skipped" )
276277 },
277278 },
@@ -281,7 +282,7 @@ func (s *AuthenticationTestSuite) TestTenancySkipFunctions() {
281282 ctx = security .SkipTenancyChecksFromMap (ctx , m )
282283 return ctx , m
283284 },
284- checkResult : func (t * testing.T , ctx context.Context , m map [string ]string ) {
285+ checkResult : func (t * testing.T , ctx context.Context , _ map [string ]string ) {
285286 require .False (t , security .IsTenancyChecksOnClaimSkipped (ctx ), "tenancy checks should not be skipped" )
286287 },
287288 },
@@ -293,7 +294,7 @@ func (s *AuthenticationTestSuite) TestTenancySkipFunctions() {
293294 ctx = security .SkipTenancyChecksFromMap (ctx , m )
294295 return ctx , m
295296 },
296- checkResult : func (t * testing.T , ctx context.Context , m map [string ]string ) {
297+ checkResult : func (t * testing.T , ctx context.Context , _ map [string ]string ) {
297298 require .False (t , security .IsTenancyChecksOnClaimSkipped (ctx ), "tenancy checks should not be skipped" )
298299 },
299300 },
@@ -327,7 +328,7 @@ func (s *AuthenticationTestSuite) TestTenancySkipFunctions() {
327328 m = security .SkipTenancyChecksToMap (ctx , m )
328329 return ctx , m
329330 },
330- checkResult : func (t * testing.T , ctx context.Context , m map [string ]string ) {
331+ checkResult : func (t * testing.T , _ context.Context , m map [string ]string ) {
331332 require .Equal (t , "existing_value" , m ["existing_key" ], "existing map values should be preserved" )
332333 require .Equal (t , "true" , m ["skip_tenancy_check" ], "skip_tenancy_check should be set to true" )
333334 },
@@ -338,7 +339,7 @@ func (s *AuthenticationTestSuite) TestTenancySkipFunctions() {
338339 ctx = security .SkipTenancyChecksOnClaims (ctx )
339340 return ctx , m
340341 },
341- checkResult : func (t * testing.T , ctx context.Context , m map [string ]string ) {
342+ checkResult : func (t * testing.T , ctx context.Context , _ map [string ]string ) {
342343 require .True (t , security .IsTenancyChecksOnClaimSkipped (ctx ), "should return true when skip flag is set" )
343344 },
344345 },
@@ -347,18 +348,26 @@ func (s *AuthenticationTestSuite) TestTenancySkipFunctions() {
347348 setup : func (ctx context.Context , m map [string ]string ) (context.Context , map [string ]string ) {
348349 return ctx , m
349350 },
350- checkResult : func (t * testing.T , ctx context.Context , m map [string ]string ) {
351- require .False (t , security .IsTenancyChecksOnClaimSkipped (ctx ), "should return false when skip flag is not set" )
351+ checkResult : func (t * testing.T , ctx context.Context , _ map [string ]string ) {
352+ require .False (
353+ t ,
354+ security .IsTenancyChecksOnClaimSkipped (ctx ),
355+ "should return false when skip flag is not set" ,
356+ )
352357 },
353358 },
354359 {
355360 name : "IsTenancyChecksOnClaimSkipped with wrong context value type returns false" ,
356361 setup : func (ctx context.Context , m map [string ]string ) (context.Context , map [string ]string ) {
357- ctx = context .WithValue (ctx , "wrong_key" , "string_instead_of_bool" )
362+ ctx = context .WithValue (ctx , testContextKey ( "wrong_key" ) , "string_instead_of_bool" )
358363 return ctx , m
359364 },
360- checkResult : func (t * testing.T , ctx context.Context , m map [string ]string ) {
361- require .False (t , security .IsTenancyChecksOnClaimSkipped (ctx ), "should return false for wrong value type" )
365+ checkResult : func (t * testing.T , ctx context.Context , _ map [string ]string ) {
366+ require .False (
367+ t ,
368+ security .IsTenancyChecksOnClaimSkipped (ctx ),
369+ "should return false for wrong value type" ,
370+ )
362371 },
363372 },
364373 {
@@ -367,8 +376,12 @@ func (s *AuthenticationTestSuite) TestTenancySkipFunctions() {
367376 ctx = security .SkipTenancyChecksOnClaims (ctx )
368377 return ctx , m
369378 },
370- checkResult : func (t * testing.T , ctx context.Context , m map [string ]string ) {
371- require .True (t , security .IsTenancyChecksOnClaimSkipped (ctx ), "SkipTenancyChecksOnClaims should set skip flag" )
379+ checkResult : func (t * testing.T , ctx context.Context , _ map [string ]string ) {
380+ require .True (
381+ t ,
382+ security .IsTenancyChecksOnClaimSkipped (ctx ),
383+ "SkipTenancyChecksOnClaims should set skip flag" ,
384+ )
372385 },
373386 },
374387 {
@@ -383,17 +396,22 @@ func (s *AuthenticationTestSuite) TestTenancySkipFunctions() {
383396 },
384397 checkResult : func (t * testing.T , ctx context.Context , m map [string ]string ) {
385398 require .True (t , security .IsTenancyChecksOnClaimSkipped (ctx ), "context should have skip flag" )
386- require .NotContains (t , m , "skip_tenancy_check" , "map should not contain skip_tenancy_check when context has skip flag" )
399+ require .NotContains (
400+ t ,
401+ m ,
402+ "skip_tenancy_check" ,
403+ "map should not contain skip_tenancy_check when context has skip flag" ,
404+ )
387405 },
388406 },
389407 }
390408
391409 for _ , tc := range testCases {
392- s .T (). Run (tc .name , func (t * testing. T ) {
393- ctx := t .Context ()
410+ s .Run (tc .name , func () {
411+ ctx := s . T () .Context ()
394412 m := make (map [string ]string )
395413 ctx , m = tc .setup (ctx , m )
396- tc .checkResult (t , ctx , m )
414+ tc .checkResult (s . T () , ctx , m )
397415 })
398416 }
399417}
0 commit comments