@@ -13,10 +13,7 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
1313 end
1414
1515 teardown do
16- # Restore feature flags so later tests (e.g. file_push, url push) don't see them false
17- Settings . require_mfa = false
18- Settings . enable_file_pushes = true
19- Settings . enable_url_pushes = true
16+ Settings . reload!
2017 Rails . application . reload_routes!
2118 end
2219
@@ -278,8 +275,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
278275 end
279276
280277 test "/p/create with files requires authentication even when allow_anonymous is true" do
281- previous_allow_anonymous = Settings . allow_anonymous
282- previous_enable_file_pushes = Settings . enable_file_pushes
283278 Settings . allow_anonymous = true
284279 Settings . enable_file_pushes = true
285280 Rails . application . reload_routes!
@@ -296,10 +291,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
296291 }
297292
298293 assert_response :unauthorized
299- ensure
300- Settings . allow_anonymous = previous_allow_anonymous
301- Settings . enable_file_pushes = previous_enable_file_pushes
302- Rails . application . reload_routes!
303294 end
304295
305296 test "/p/create with files works with valid token when allow_anonymous is true" do
@@ -322,10 +313,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
322313 assert_response :created
323314 json = JSON . parse ( response . body )
324315 assert json [ "url_token" ] . present?
325- ensure
326- Settings . allow_anonymous = true
327- Settings . enable_file_pushes = false
328- Rails . application . reload_routes!
329316 end
330317
331318 test "/p/create with empty files key requires authentication when allow_anonymous is true" do
@@ -345,10 +332,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
345332 }
346333
347334 assert_response :unauthorized
348- ensure
349- Settings . allow_anonymous = true
350- Settings . enable_file_pushes = false
351- Rails . application . reload_routes!
352335 end
353336
354337 # When allow_anonymous is false, Api::V1::PushesController#create calls
@@ -372,8 +355,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
372355 if response . redirect?
373356 assert_match ( %r{/users/sign_in} , response . location )
374357 end
375- ensure
376- Settings . allow_anonymous = true
377358 end
378359
379360 test "/p/create with valid token succeeds when allow_anonymous is false" do
@@ -393,8 +374,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
393374 assert_response :created , "authenticated create should succeed when allow_anonymous is false"
394375 json = JSON . parse ( response . body )
395376 assert json [ "url_token" ] . present?
396- ensure
397- Settings . allow_anonymous = true
398377 end
399378
400379 test "v2 show requires authentication when allow_anonymous is false" do
@@ -407,8 +386,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
407386 }
408387
409388 assert_response :unauthorized
410- ensure
411- Settings . allow_anonymous = true
412389 end
413390
414391 # Test path-based authentication requirements for /f paths
@@ -428,9 +405,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
428405 }
429406
430407 assert_response :unauthorized
431- ensure
432- Settings . enable_file_pushes = false
433- Rails . application . reload_routes!
434408 end
435409
436410 test "/f/create works with valid token" do
@@ -451,9 +425,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
451425
452426 # Should not be unauthorized (may be other validation errors)
453427 assert_not_equal :unauthorized , response . status
454- ensure
455- Settings . enable_file_pushes = false
456- Rails . application . reload_routes!
457428 end
458429
459430 test "/f/audit requires authentication" do
@@ -465,9 +436,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
465436
466437 get "/f/#{ push . url_token } /audit.json"
467438 assert_response :unauthorized
468- ensure
469- Settings . enable_file_pushes = false
470- Rails . application . reload_routes!
471439 end
472440
473441 test "/f/active requires authentication" do
@@ -476,9 +444,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
476444
477445 get "/f/active.json"
478446 assert_response :unauthorized
479- ensure
480- Settings . enable_file_pushes = false
481- Rails . application . reload_routes!
482447 end
483448
484449 test "/f/expired requires authentication" do
@@ -487,9 +452,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
487452
488453 get "/f/expired.json"
489454 assert_response :unauthorized
490- ensure
491- Settings . enable_file_pushes = false
492- Rails . application . reload_routes!
493455 end
494456
495457 # Test path-based authentication requirements for /r paths
@@ -508,9 +470,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
508470 }
509471
510472 assert_response :unauthorized
511- ensure
512- Settings . enable_url_pushes = false
513- Rails . application . reload_routes!
514473 end
515474
516475 test "/r/create works with valid token" do
@@ -530,9 +489,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
530489
531490 # Should not be unauthorized (may be other validation errors)
532491 assert_not_equal :unauthorized , response . status
533- ensure
534- Settings . enable_url_pushes = false
535- Rails . application . reload_routes!
536492 end
537493
538494 test "/r/audit requires authentication" do
@@ -544,9 +500,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
544500
545501 get "/r/#{ push . url_token } /audit.json"
546502 assert_response :unauthorized
547- ensure
548- Settings . enable_url_pushes = false
549- Rails . application . reload_routes!
550503 end
551504
552505 test "/r/active requires authentication" do
@@ -555,9 +508,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
555508
556509 get "/r/active.json"
557510 assert_response :unauthorized
558- ensure
559- Settings . enable_url_pushes = false
560- Rails . application . reload_routes!
561511 end
562512
563513 test "/r/expired requires authentication" do
@@ -566,9 +516,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
566516
567517 get "/r/expired.json"
568518 assert_response :unauthorized
569- ensure
570- Settings . enable_url_pushes = false
571- Rails . application . reload_routes!
572519 end
573520
574521 # Test user already signed in (session-based auth)
@@ -664,9 +611,6 @@ class Api::BaseControllerTest < ActionDispatch::IntegrationTest
664611 assert_response :bad_request
665612 json_response = JSON . parse ( @response . body )
666613 assert json_response . key? ( "error" )
667- ensure
668- Settings . enable_file_pushes = false
669- Rails . application . reload_routes!
670614 end
671615
672616 # Test token with blank/nil values
0 commit comments