aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | | Replace `assert !` with `assert_not`Daniel Colson2018-04-1914-26/+26
| | | | | | | | | | | | | | | | | | | | | | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* | | | | Pass nonce to CSP policy from outsideAndrew White2018-04-181-21/+72
| | | | |
* | | | | Output only one nonce in CSP header per requestAndrey Novikov2018-04-171-5/+23
|/ / / /
* | | | Fix rendering a differently-formatted partial after cachingGeorge Claghorn2018-04-133-0/+14
| | | |
* | | | Add WebSocket URI support to CSP DSL mappingsStephen Solis2018-04-121-0/+6
| | | |
* | | | Add `TestCaseTest#test_request_format_kwarg_doesnt_mutate_params` to masterbogdanvlviv2018-04-101-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Initially, the test was added to 5-0-stable in #32492 and a bit modified in #32506. This test ensures that request(in tests) doesn't mutate params. It was fixed since v5.1.0.beta1 by 98b8309569a326910a723f521911e54994b112fb and then on 5-0-stable by #32492. This commit adds this test to master branch in order to prevent any regressions.
* | | | Partially revert 0bfdd1dyuuji.yaginuma2018-04-071-1/+5
| | | | | | | | | | | | | | | | | | | | The `Capybara.server=` proc acceptance restored in Capyara 3.0.1. Ref: https://github.com/teamcapybara/capybara/commit/8f115d94e035eca992036f16e50c1dce5f555c97
* | | | Fix broken `ServerTest` with Capybara 3.0.0yuuji.yaginuma2018-04-061-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It seems that it is no longer possible to specify the value held by `Capybara.server` as sever. Ref: https://github.com/teamcapybara/capybara/commit/ba7674086cbcd3b22d3614011815bc5d483e5960
* | | | Merge pull request #32441 from composerinteralia/refute-notRafael França2018-04-043-8/+8
|\ \ \ \ | | | | | | | | | | Add custom RuboCop for `assert_not` over `refute`
| * | | | Autocorrect `refute` RuboCop violationsDaniel Colson2018-04-033-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 73e7aab behaved as expected on codeship, failing the build with exactly these RuboCop violations. Hopefully `rubocop -a` will have been enough to get a passing build!
* | | | | Add #dig to ActionDispatch::Request::Sessionclaudiob2018-04-041-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Summary The `session` object is not a real Hash but responds to many methods of Hash such as `[]`, `[]`, `fetch`, `has_key?`. Since Ruby 2.3, Hash also supports a `dig` method. This commit adds a `dig` method to `ActionDispatch::Request::Session` with the same behavior as `Hash#dig`. This is useful if you store a hash in your session, such as: ```ruby session[:user] = { id: 1, avatar_url: "http://example.org/nyancat.jpg" } ``` Then you can shorten your code from `session[:user][:avatar_url]` to `session.dig :user, :avatar_url`. ### Other Information I cherry-picked a commit from https://github.com/rails/rails/pull/23864, and modify a bit. The changes are below: * Converts only the first key to a string adjust to the `fetch` method. * Fixes a test case because we cannot use the indifferent access since ee5b621e2f8fde380ea4bc75b0b9d6f98499f511.
* | | | | Merge pull request #32336 from vincedevendra/allow_mutating_dig_return_valueAaron Patterson2018-04-021-0/+8
|\ \ \ \ \ | |/ / / / |/| | | | Make mutating params#dig return value mutate underlying params
| * | | | Make mutating params#dig mutate underlying paramsVince DeVendra2018-03-241-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When #dig was called on a params object and return either a Hash or an Array, and that value was subsquently mutated, it would not modify the containing params object. That means that the behavior of `params.dig(:a, :b)[:c] = 1` did not match either `params[:a][:b][:c] = 1` nor `hash.dig(:a, :b)[:c] = 1`. Similarly to `ActionController::Parameters#[]`, use `#convert_hashes_to_parameters` to pre-convert values and insert them in the receiving params object prior to returning them.
* | | | | Merge pull request #32277 from derekprior/dp-deprecate-force-sslGuillermo Iguaran2018-03-302-15/+29
|\ \ \ \ \ | |/ / / / |/| | | | Deprecate controller level force_ssl
| * | | | Deprecate controller level force_sslDerek Prior2018-03-302-15/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Today there are two common ways for Rails developers to force their applications to communicate over HTTPS: * `config.force_ssl` is a setting in environment configurations that enables the `ActionDispatch::SSL` middleware. With this middleware enabled, all HTTP communication to your application will be redirected to HTTPS. The middleware also takes care of other best practices by setting HSTS headers, upgrading all cookies to secure only, etc. * The `force_ssl` controller method redirects HTTP requests to certain controllers to HTTPS. As a consultant, I've seen many applications with misconfigured HTTPS setups due to developers adding `force_ssl` to `ApplicationController` and not enabling `config.force_ssl`. With this configuration, many application requests can be served over HTTP such as assets, requests that hit mounted engines, etc. In addition, because cookies are not upgraded to secure only in this configuration and HSTS headers are not set, it's possible for cookies that are meant to be secure to be sent over HTTP. The confusion between these two methods of forcing HTTPS is compounded by the fact that they share an identical name. This makes finding documentation on the "right" method confusing. HTTPS throughout is quickly becomming table stakes for all web sites. Sites are expected to operate over HTTPS for all communication, sensitive or otherwise. Let's encourage use of the broader-reaching `ActionDispatch::SSL` middleware and elminate this source of user confusion. If, for some reason, applications need to expose certain endpoints over HTTP they can do so by properly configuring `config.ssl_options`.
* | | | | Use ASCII-8BIT paths in ActionDispatch::StaticAndrew White2018-03-225-1/+12
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The rack gem returns PATH_INFO as an ASCII-8BIT encoded string but it was being converted to US-ASCII by the match? method because it was calling Rack::Utils.escape_path. To prevent incompatibile encoding warnings use ASCII-8BIT strings for the root path and let Ruby handle any filename encoding conversion. Fixes #32294, Closes #32314.
* | | | Check exclude before flagging cookies as secure in ActionDispatch::SSL (#32262)Catherine Khuu2018-03-151-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Check exclude before flagging cookies as secure. * Update comments in ActionDispatch::SSL. [Catherine Khuu + Rafael Mendonça França]
* | | | Fix routing inspector tests broken in ↵Kasper Timm Hansen2018-03-131-14/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://github.com/rails/rails/commit/6629d51a2756fadf961bb09df20579cacfef2c8e * Renames grep_pattern to grep throughout. * Fixes setup not calling super by calling setup with a block. * Converts test helper method to a private one, like we have it other places. * Uses keyword arguments to get around awkward draw({ grep: "x" }, Action…) construction.
* | | | Introduce `ActionDispatch::Routing::ConsoleFormatter::Base`bogdanvlviv2018-03-131-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Create `Base` and inherit `Sheet` and `Expanded` in order to - prevent code duplication. - Remove trailing "\n" for components of `Expanded`. - There is no need for `Expanded#header` to return `@buffer` so return `nil` instead. - Change `no_routes` message "No routes were found for this controller" since if use `-g`, it sounds incorrect. - Display `No routes were found for this controller.` if apply `-c`. - Display `No routes were found for this grep pattern.` if apply `-g`. Related to #32130
* | | | Merge pull request #32160 from bogdanvlviv/improve-rails-routes-expandedKasper Timm Hansen2018-03-111-5/+10
|\ \ \ \ | | | | | | | | | | Draw line of a route name to the end of row console on `rails routes --expanded`
| * | | | Draw line of a route name to the end of row console on `rails routes --expanded`bogdanvlviv2018-03-051-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to get width of console use `IO::console_size`, See https://ruby-doc.org/stdlib-2.4.1/libdoc/io/console/rdoc/IO.html#method-c-console_size Related to #32130
* | | | | Always yield a CSP policy instanceAndrew White2018-03-081-12/+58
| | | | | | | | | | | | | | | | | | | | | | | | | If the app has the CSP disabled globally allow a controller action to enable the policy for that request.
* | | | | Add the ability to disable the global CSP in a controllerAndrew White2018-03-081-0/+14
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | e.g: class LegacyPagesController < ApplicationController content_security_policy false, only: :index end
* | | | Ruby 2.4: take advantage of String#unpack1Jeremy Daer2018-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | https://bugs.ruby-lang.org/issues/12752 https://ruby-doc.org/core-2.4.0/String.html#method-i-unpack1
* | | | Add --expanded option to "rails routes"Benoit Tigeot2018-02-281-2/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using rails routes with small terminal or complicated routes it can be very difficult to understand where is the element listed in header. psql had the same issue, that's why they created "expanded mode" you can switch using `\x` or by starting psql with ``` -x --expanded Turn on the expanded table formatting mode. This is equivalent to the \x command. ``` The output is similar to one implemented here for rails routes: db_user-# \du List of roles -[ RECORD 1 ]---------------------------------------------- Role name | super Attributes | Superuser, Create role, Create DB Member of | {} -[ RECORD 2 ]---------------------------------------------- Role name | role Attributes | Superuser, Create role, Create DB, Replication Member of | {}
* | | | Uses the absolute path for system test screenshotsZamith2018-02-271-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: * When getting an error that generates a screenshot it would be helpful to be able to ctrl+click it to quickly open it in the browser, which does not work with relative paths This change addresses the need by: * Changing `image_path` to disregard the relative path and use the absolute one instead
* | | | Merge branch 'master' into update_default_hsts_max_ageGuillermo Iguaran2018-02-2439-260/+289
|\ \ \ \
| * \ \ \ Merge pull request #32018 from rails/add-nonce-support-to-cspAndrew White2018-02-221-0/+16
| |\ \ \ \ | | | | | | | | | | | | Add support for automatic nonce generation for Rails UJS
| | * | | | Add support for automatic nonce generation for Rails UJSAndrew White2018-02-191-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because the UJS library creates a script tag to process responses it normally requires the script-src attribute of the content security policy to include 'unsafe-inline'. To work around this we generate a per-request nonce value that is embedded in a meta tag in a similar fashion to how CSRF protection embeds its token in a meta tag. The UJS library can then read the nonce value and set it on the dynamically generated script tag to enable it to execute without needing 'unsafe-inline' enabled. Nonce generation isn't 100% safe - if your script tag is including user generated content in someway then it may be possible to exploit an XSS vulnerability which can take advantage of the nonce. It is however an improvement on a blanket permission for inline scripts. It is also possible to use the nonce within your own script tags by using `nonce: true` to set the nonce value on the tag, e.g <%= javascript_tag nonce: true do %> alert('Hello, World!'); <% end %> Fixes #31689.
| * | | | | We should call methods with `.method_name` not `::method_name`.utilum2018-02-222-5/+6
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | Found several instances. Follow up on 63d530c5e68a8cf53603744789f53ccbc7ac1a0e
| * | | | Remove trailing semi-colon from CSPAndrew White2018-02-191-32/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although the spec[1] is defined in such a way that a trailing semi-colon is valid it also doesn't allow a semi-colon by itself to indicate an empty policy. Therefore it's easier (and valid) just to omit it rather than to detect whether the policy is empty or not. [1]: https://www.w3.org/TR/CSP2/#policy-syntax
| * | | | Revert "Merge pull request #32045 from eagletmt/skip-csp-header"Andrew White2018-02-191-20/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 86f7c269073a3a9e6ddec9b957deaa2716f2627d, reversing changes made to 5ece2e4a4459065b5efd976aebd209bbf0cab89b. If a policy is set then we should generate it even if it's empty. However what is happening is that we're accidentally generating an empty policy when the initializer is commented out by default.
| * | | | Skip generating empty CSP header when no policy is configuredKohei Suzuki2018-02-181-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Rails.application.config.content_security_policy` is configured with no policies by default. In this case, Content-Security-Policy header should not be generated instead of generating the header with no directives. Firefox also warns "Content Security Policy: Couldn't process unknown directive ''".
| * | | | Rails 6 requires Ruby 2.4.1+Jeremy Daer2018-02-172-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug. References #32028
| * | | | Clean up and consolidate .gitignoresbogdanvlviv2018-02-171-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Global ignores at toplevel .gitignore * Component-specific ignores in each toplevel directory * Remove `actionview/test/tmp/.keep` for JRuby ``` rm actionview/test/tmp/ -fr cd actionview/ bundle exec jruby -Itest test/template/digestor_test.rb ``` Related to #11743, #30392. Closes #29978.
| * | | | Rails 6 requires Ruby 2.3+Jeremy Daer2018-02-171-16/+9
| | | | |
| * | | | Fix array routing constraintsfatkodima2018-02-171-2/+5
| | | | |
| * | | | Remove usage of strip_heredoc in the framework in favor of <<~Rafael Mendonça França2018-02-161-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Some places we can't remove because Ruby still don't have a method equivalent to strip_heredoc to be called in an already existent string.
| * | | | Make sure assert_recognizes can still find routes mounted after enginesRafael Mendonça França2018-02-091-0/+6
| |/ / / | | | | | | | | | | | | | | | | Before, if the application defined after an engine this method would not recognize the route since it was not defined insdie the engine.
| * | | Consistent behavior for session and cookies with to_h and to_hash methodIgor Kasyanchuk2018-01-312-0/+7
| | | |
| * | | Allow @ in X-Request-Id headerDaniel Colson2018-01-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It makes sense to be as strict as possible with headers from the outside world, but allowing @ to support Apache's mod_unique_id (see #31644) seems OK to me
| * | | Use assert_empty and assert_not_emptyDaniel Colson2018-01-259-17/+17
| | | |
| * | | Use assert_predicate and assert_not_predicateDaniel Colson2018-01-2526-174/+174
| | | |
| * | | Change refute to assert_notDaniel Colson2018-01-253-12/+12
| | | |
| * | | Use respond_to test helpersDaniel Colson2018-01-257-9/+9
| | | |
| * | | Merge pull request #31713 from aellispierce/refactor-browser-optionsEileen M. Uchitelle2018-01-171-3/+4
| |\ \ \ | | | | | | | | | | Move browser config to its own class
| | * | | Move browser checking to its own classAshley Ellis Pierce2018-01-151-3/+4
| | | | |
* | | | | Update default HSTS max-age value to 1 yearGrant Bourque2018-01-161-2/+2
|/ / / / | | | | | | | | | | | | | | | | - Update the default HSTS max-age value to 31536000 seconds (1 year) to meet the minimum max-age requirement for https://hstspreload.org/.
* | | | Add 'Referrer-Policy' header to default headers setGuillermo Iguaran2018-01-081-2/+4
| | | |
* | | | Merge pull request #31594 from yuki24/refactor-request-testEileen M. Uchitelle2018-01-041-89/+75
|\ \ \ \ | | | | | | | | | | Refactor tests for request parameters to use more realistic setup