Commit Graph

12857 Commits

Author SHA1 Message Date
Guillermo Iguaran
5a21634407
Merge pull request #48956 from skipkayhil/hm-rack-lint-show-exceptions-failsafe
Add test coverage for ShowExceptions failsafe
2023-08-18 16:08:41 -07:00
Guillermo Iguaran
4ec3a986d5
Merge pull request #48959 from skipkayhil/hm-clean-filters-requires
Remove uneeded requires of core_ext/string/filters
2023-08-18 16:03:44 -07:00
Rafael Mendonça França
c82d624ea1
Fix documentation of with_routing in the class level
There is no assertions inside it.
2023-08-18 22:21:06 +00:00
Rafael Mendonça França
08cd280866
Use class method module instead of DSL
This will make sure documentation is generated for the module.
2023-08-18 22:11:48 +00:00
Hartley McGuire
ff6e885d59
Remove uneeded requires of core_ext/string/filters
`actionpack/lib/action_dispatch/routing.rb`
- added: 013745151be062aa4d0fc1f2a008a7303fdb6e04
- removed: 93034ad7fea7e00562103a7cd0acfab19bbfadf9

`activejob/lib/active_job/log_subscriber.rb`
- added: b314ab555e0d85e6efb41be94fb5f3a157bb12fe
- removed: 5ab2034730feacfc2caee418f8c0b55191d27427

`activemodel/lib/active_model/errors.rb`
- added: cf7fac7e29bb2816412c949fdaed3d61a923eb23
- removed: 9de6457ab0767ebab7f2c8bc583420fda072e2bd

`activerecord/lib/active_record/core.rb`
- added: b3bfa361c503e107aff4dee5edf79bd7fd3d3725
- removed: e1066f450d1a99c9a0b4d786b202e2ca82a4c3b3

`activesupport/lib/active_support/core_ext/module/introspection.rb`
- added: 358ac36edf1695fcbec0aa21f126a3d8b83d4b5a
- removed: 167b4153cac0069a21e0bb9689cb16f34f6abbaa

`activesupport/lib/active_support/duration.rb`
- added: 75924c4517c8f87712d3f59c11f10152ed57b9d8
- removed: a91ea1d51048342d13fc73f9b09ce4cfd086bb34

`railties/lib/rails/commands/server/server_command.rb`
- added: f2173648938b418d120f5a68d8f3862d8ae9dace
- removed: 553b86fc751c751db504bcbe2d033eb2bb5b6a0b

`railties/lib/rails/command/base.rb`
- added: 6813edc7d926965e5644cd8befaf229a35b9d8ca
- removed: b617a561d865a65cfc140caa0e3c4af4350bfcef
2023-08-16 17:39:25 -04:00
Hartley McGuire
6bf2ee09f7
Add test coverage for ShowExceptions failsafe
This adds additional test coverage to ShowExceptions, since one of the
possible responses it creates was not previously tested. Because of the
previous [addition][1] of Rack::Lint, this also demonstrates that the
Content-Type header needed to be fixed.

[1]: 339dda4a82356d173b62dab144870790618e40c6
2023-08-16 16:00:25 -04:00
Akira Matsuda
5cf742ef51
ERB is no longer in use here since c2e756a944fd3ca2efa58bd285c0e75e0b4794ab 2023-08-17 04:46:35 +09:00
Matija Čupić
eed1ac1782
Use relative path for screenshot metadata 2023-08-05 15:20:01 +02:00
Rafael Mendonça França
2df0e5fa0c
Merge pull request #48857 from seanpdoyle/fixture-file-upload-rename
Rename `fixture_file_upload` method to `file_fixture_upload`
2023-08-04 17:08:40 -04:00
Sean Doyle
6cafc49d2c Rename fixture_file_upload method to file_fixture_upload
The naming difference between the test harness' [file_fixture][] helper
made available through Active Support (along with the
`file_fixture_path` configuration value) and the integration test
harness' [fixture_file_upload][] is a constant source of confusion and
surprise.

Since Active Support is more ubiquitous, this commit renames the
`fixture_file_upload` method to `file_fixture_upload` to match the order
of words in `file_fixture` and `file_fixture_path`.

To preserve backwards compatibility, declare a `fixture_file_upload`
alias to be preserved into the future (or removed at a future point in
time).

[file_fixture]: https://edgeapi.rubyonrails.org/classes/ActiveSupport/Testing/FileFixtures.html#method-i-file_fixture
[fixture_file_upload]: https://edgeapi.rubyonrails.org/classes/ActionDispatch/TestProcess/FixtureFile.html#method-i-fixture_file_upload
2023-08-04 12:40:17 -04:00
Bryan Traywick
a4633725d2 Fix NoMethodError when request Content-Type is blank. 2023-08-04 12:36:11 -04:00
Mike Dalessio
8a57ba8c0e
Update Action View and Dispatch to use Rails::Dom::Testing helpers
Use the helpers introduced in rails-dom-testing 2.2.0 instead of
managing the HTML parsers as was done in #48523.

See also related #47144 / ad79ed0e
2023-08-03 11:17:38 -04:00
Jean Boussier
ee3117ba8a
Merge pull request #48863 from matteeyah/main
Save screenshot path on system test failure
2023-08-03 16:35:29 +02:00
Eugene Kenny
797a7c5a62 Fix typos in RequestForgeryProtection docs [ci-skip] 2023-08-03 13:58:26 +01:00
Matija Čupić
a962fc3c9c
Save failure screenshot path in test metadata 2023-08-03 14:43:49 +02:00
Rafael Mendonça França
e980f158a4
Merge pull request #48847 from seanpdoyle/omit-webdrivers-from-gemfile-template
Omit `webdrivers` gem from `Gemfile` template
2023-08-02 13:49:28 -04:00
Sean Doyle
9a53234695 Omit webdrivers gem from Gemfile template
As of Selenium 4.6, [the Selenium Manager is capable of managing Chrome
Driver installations and integrations][readme]. As of Selenium 4.11, the
Selenium Manager is capable of [capable of resolving the Chrome for
Testing installation][] path.

By omitting the `gem` declaration from the `Gemfile.tt`, newly generated
applications and applications updating their `Gemfile` in lockstep with
newer Rails versions can shed the dependency and avoid test failures
introduced by newly released Chrome versions (like, for example,
[titusfortner/webdrivers#247][]).

[readme]: 43f8ac436c (update-selenium-manager)
[titusfortner/webdrivers#247]: https://github.com/titusfortner/webdrivers/issues/247
[capable of resolving the Chrome for Testing installation]: https://github.com/rails/rails/pull/48847#issuecomment-1656756862

Co-authored-by: Titus Fortner <titusfortner@users.noreply.github.com>
2023-08-01 09:22:08 -04:00
Adrianna Chang
339dda4a82
Add Rack::Lint to ActionDispatch::ShowExceptions tests
This wraps test coverage for `ActionDispatch::ShowExpections` in
`Rack::Lint` middleware in order to validate that both
`ActionDispatch::ShowExceptions` and `ActionDispatch::PublicExceptions`
conform to the Rack SPEC.

It also ensures that the response headers returned by the *Exceptions
middleware respect casing (mixed case for Rack 2, lower case for Rack 3)
2023-08-01 09:18:59 -04:00
Hartley McGuire
ac7ee278fd
Add Rack::Lint to DebugExceptions tests
This adds additional test coverage to DebugExceptions to validate that
its behavior conforms to the Rack SPEC.

The only changes necessary were to use dynamic header casing for
Content-Type and Content-Length
2023-07-29 16:49:10 -04:00
Adrianna Chang
2401b336fb
Use expected casing for x-cascade headers in router
This commit changes the router to use the expected casing for the
x-cascade header: in Rack 2, this is mixed-case, and in Rack 3, this is
lower case.

This also fixes https://github.com/rails/rails/issues/47096.
2023-07-28 16:17:08 -04:00
Adrianna Chang
9d840a1719
Make ActionDispatch::SSL compatible with Rack 3.0
Rack 3 now allows response header values to be an Array when handling
multiple values. Newline encoded headers are no longer supported.

This commit updates `ActionDispatch::SSL#flag_cookies_as_secure!` to
be Rack-3 compliant by setting the `set-cookie` header to an Array
rather than a newline-separated String if the current Rack version is
3+.

Additionally, this commit adds `Rack::Lint` to the Rack app in the
middleware test suite so that we can ensure all of the tests are
compliant with the Rack SPEC.
2023-07-28 14:23:25 -04:00
Eileen M. Uchitelle
43be5c4dc4
Merge pull request #48839 from skipkayhil/hm-rack-lint-test-request
Fix TestRequest coercing SERVER_PORT to be an int
2023-07-28 14:08:47 -04:00
Guillermo Iguaran
1788f67431
Merge pull request #48812 from nunosilva800/ns-rack-lint-content-security-policy-middleware
Add Rack::Lint to ContentSecurityPolicy::Middleware tests
2023-07-28 10:27:26 -07:00
Hartley McGuire
70335e0793
Fix TestRequest coercing SERVER_PORT to be an int
In both Rack 2 and Rack 3, all headers must be strings. SERVER_PORT has
an additional requirement that it must be an Integer (represented as a
string).

When using #port= on a TestRequest, the value passed has been coerced
into an integer since it was [introduced][1]. Since this is explicitly
incorrect per both Rack 2 and Rack SPEC, the coercion is removed.

This does have the potential to change the value for users who are
checking TestRequest#headers directly, but if they are using
Request#port the value will not change because #port also coerces values
to ints.

[1]: 61960e7b37767140e9af68bd5373e06dce08492d
2023-07-28 13:02:27 -04:00
Nuno Silva
04c61163bf
Add Rack::Lint to ActionDispatch::ServerTiming tests
To ensure Rails is and remains compliant with [the Rack 3
spec](6d16306192/UPGRADE-GUIDE.md)
we can add `Rack::Lint` to the Rails middleware tests.

This adds additional test coverage to `ActionDispatch::ServerTiming` to
validate that its input and output follow the Rack SPEC.

The `Server-Timing` header definition was moved to
`ActionDispatch::Constants` and is now downcased to match the Rack 3
SPEC.

The tests that rely on a `Concurrent::CyclicBarrier` ("events are
tracked by thread") were changed since passing the required proc in the
env is not compatible with the SPEC:

```
Rack::Lint::LintError: env variable proc has non-string value
```

The same can be achieved by invoking the proc as a child Rack app.
2023-07-28 15:24:32 +00:00
Eileen M. Uchitelle
dda937fa62
Merge pull request #48819 from skipkayhil/hm-doc-integration-tweaks
Add and remove some links in IntegrationTest docs [ci skip]
2023-07-28 08:54:53 -04:00
Eileen M. Uchitelle
924a371e38
Merge pull request #48788 from ylecuyer/fix-selenium-tests-yle
Fix: Do not execute selenium driver_path if it is a string.
2023-07-28 08:53:25 -04:00
Nuno Silva
d1381dc654
Add Rack::Lint to ContentSecurityPolicy::Middleware tests
To ensure Rails is and remains compliant with [the Rack 3
spec](6d16306192/UPGRADE-GUIDE.md)
we can add `Rack::Lint` to the Rails middleware tests.

This adds additional test coverage to
`ContentSecurityPolicy::Middleware` to validate that its input and
output follow the Rack SPEC.

The changes made are because of:
- [Response Headers must be lower case](6d16306192/UPGRADE-GUIDE.md (response-headers-must-be-lower-case))

Added tests to ensure that CSP headers set by an app are not overridden,
regardless of the casing.
An example of this is Sidekiq: https://github.com/sidekiq/sidekiq/blob/b3225ce/lib/sidekiq/web/application.rb#L353
2023-07-28 09:37:23 +00:00
Guillermo Iguaran
ff232b1190 Move X-Request-Id header name to ActionDispatch::Constants 2023-07-27 16:03:52 -07:00
Guillermo Iguaran
5b45803984 Use constants defined in ActionDispatch::Constants instead of conditional assignments 2023-07-27 15:21:18 -07:00
Guillermo Iguaran
1fd79abb54 Define constants for headers in ActionDispatch::Constants to avoid conditional checks around multiple classes 2023-07-27 15:20:33 -07:00
Yoann Lecuyer
bd8a6778a0 Fix: Do not execute selenium driver_path if it is a string. 2023-07-27 22:57:49 +02:00
Guillermo Iguaran
034cae80a9
Merge pull request #48818 from skipkayhil/hm-rack-list-permissions-policy
Add Rack::Lint to PermissionsPolicy tests
2023-07-27 13:56:03 -07:00
Eileen M. Uchitelle
c9a104008f
Merge pull request #48832 from skipkayhil/hm-rack-lint-debug-locks
Add Rack::Lint to DebugLocks tests
2023-07-27 16:51:53 -04:00
Hartley McGuire
fe5eb3d0fb
Add Rack::Lint to DebugLocks tests
This adds additional test coverage to HostAuthorization to validate that
its behavior conforms to Rack SPEC.

This fixes the following two issues in the reponse returned by
DebugLocks:
- Rack::Lint::Error: uppercase character in header name
  Content-{Type/Length}
- Rack::Lint::Error: a header value must be a String or Array of
  Strings, but the value of 'content-length' is an Integer
2023-07-27 16:33:41 -04:00
Guillermo Iguaran
d835023f1b
Merge pull request #48831 from skipkayhil/hm-rack-lint-static
Add Rack::Lint to Static tests
2023-07-27 13:26:28 -07:00
Guillermo Iguaran
4b3172035c
Merge pull request #48813 from skipkayhil/hm-rack-lint-actionable-actionable-exceptions
Add Rack::Lint to ActionableExceptions tests
2023-07-27 13:22:47 -07:00
Guillermo Iguaran
1d34845e3f
Merge pull request #48811 from nunosilva800/ns-rack-lint-assume-ssl
Add Rack::Lint to AssumeSSL middleware tests
2023-07-27 12:56:44 -07:00
Hartley McGuire
b580df616b
Add Rack::Lint to Static tests
This adds additional test coverage to Static to validate that its
behavior conforms to the Rack SPEC.

The test changes are just downcasing headers where appropriate:
- the Static `headers` params is purely user configured headers, so its
  reasonable to expect these shoud be correct for an application's Rack
  version
- header assertions can use downcased headers because Rack::MockRequest
  returns a Rack::Response, which uses Rack::Headers internally (so
  either casing will work)

Additionally, the unconditionally downcased headers in the Static
middleware were updated to be conditional based on the Rack version to
ensure that this middleware remains fully compatible with other Rack 2
middleware.
2023-07-27 15:48:43 -04:00
Hartley McGuire
34947521d9
Add and remove some links in IntegrationTest docs
Add direct links to #get, #post, #parsed_body, and #open_session.

Remove links to Session when already on the Session page.
2023-07-26 18:14:07 -04:00
Hartley McGuire
4991525abb
Add Rack::Lint to PermissionsPolicy tests
This adds additional test coverage to PermissionsPolicy::Middleware to
validate that it conforms to the Rack SPEC.

The only changes necessary were to use the appropriate header casing for
Content-Type and Feature-Policy. Since this was the only usage of the
CONTENT_TYPE constant, I opted to remove it, but I can replace it with a
DeprecatedConstantProxy if that's more desirable.
2023-07-26 13:34:14 -04:00
Hartley McGuire
0c92013158
Add Rack::Lint to ActionableExceptions tests
This adds additional test coverage to ActionableExceptions to validate
that its behavior conforms to the Rack SPEC.

The changes neccesary were to ensure that Response headers are downcased
when using Rack 3. For Content-Type and Content-Length, this is trivial
because Rack provides constants who's casing is dependent on the version
(Rack 2 is mixed, and Rack 3 is downcased). Since Rack does not include
a LOCATION constant, the Response::LOCATION constant was updated to
have a downcased value when using Rack 3.

Additionally, there was some missing coverage for invalid redirect URLs
which was addressed as well.
2023-07-26 10:13:57 -04:00
Hartley McGuire
37522f1596
Add Rack::Lint to HostAuthorization tests
This adds additional test coverage to HostAuthorization to validate that
its behavior conforms to the Rack SPEC.

By using Rack:: constants for Content-Type and Content-Length, we are
able to use the "correct" versions of the headers for applications using
each Rack version.

Additionally, two tests had to be updated that use an ipv6 address
without brackets in the HOST header because Rack::Lint warned that these
addresses were not valid HOST values. Rack::Lint checks HOST headers using
`URI.parse("http://#{HOST}/")`, and from what I could find, this
requirement follows RFC 3986 Section 3.2.2:

```
host        = IP-literal / IPv4address / reg-name
IP-literal = "[" ( IPv6address / IPvFuture  ) "]"
IPvFuture  = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
```
2023-07-26 09:50:06 -04:00
Nuno Silva
df2616e20b
Add Rack::Lint to AssumeSSL middleware tests
To ensure Rails is and remains compliant with [the Rack 3
spec](6d16306192/UPGRADE-GUIDE.md)
we can add `Rack::Lint` to the Rails middleware tests.

There was no test file for ActionDispatch::AssumeSSL, so this change
adds one and validating that its input and output follow the Rack SPEC.
2023-07-26 11:08:43 +00:00
Ufuk Kayserilioglu
c2b195e1e3
Change load error messages to use Kernel#warn instead of $stderr.puts
When development tools try to load Rails components, they sometimes end up loading files that will error out since a dependency is missing. In these cases, the tooling can catch the error and change its behaviour.

However, since the warning is printed directly to `$stderr`, the tooling cannot catch and suppress it easily, which ends up causing noise in the output of the tool.

This change makes Rails print these warnings using `Kernel#warn` instead, which can be suppressed by the tooling.
2023-07-21 00:38:12 +03:00
Henrik Nyh
cf166fb13c Doc and spec cookies.delete returning value 2023-07-12 12:08:35 +01:00
Guillermo Iguaran
1c0aeed2fb
Merge pull request #48575 from skipkayhil/hm-config-exception-level
Make the log level in DebugExceptions configurable
2023-06-27 10:17:45 -07:00
Xavier Noria
9294a55187 Fix indentation in ActionDispatch::Routing::RouteSet::Dispatcher 2023-06-27 16:15:09 +02:00
Carlos Antonio da Silva
d9af9f1023 Avoid creating match object when checking for illegal header value
We can use `match?` to check against the illegal header value regexp,
since we don't need the match data result.
2023-06-27 09:40:35 -03:00
Guillermo Iguaran
10b4bd597f
Merge branch 'main' into hm-config-exception-level 2023-06-26 19:07:08 -07:00