aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch
Commit message (Collapse)AuthorAgeFilesLines
* Introduce ActionDispatch::DebugExceptions interceptorsGenadi Samokovarov2018-04-201-0/+24
| | | | | | | | | | | | | | Plugins interacting with the exceptions caught and displayed by ActionDispatch::DebugExceptions currently have to monkey patch it to get the much needed exception for their calculation. With DebugExceptions.register_interceptor, plugin authors can hook into DebugExceptions and process the exception, before being rendered. They can store it into the request and process it on the way back of the middleware chain execution or act on it straight in the interceptor. The interceptors can be play blocks, procs, lambdas or any object that responds to `#call`.
* Replace `assert !` with `assert_not`Daniel Colson2018-04-196-11/+11
| | | | | 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
|
* Add WebSocket URI support to CSP DSL mappingsStephen Solis2018-04-121-0/+6
|
* 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-041-1/+1
|\ | | | | Add custom RuboCop for `assert_not` over `refute`
| * Autocorrect `refute` RuboCop violationsDaniel Colson2018-04-031-1/+1
| | | | | | | | | | | | 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.
* Use ASCII-8BIT paths in ActionDispatch::StaticAndrew White2018-03-221-1/+10
| | | | | | | | | | 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
* 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-2412-98/+136
|\
| * 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.
| * 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 ''".
| * Fix array routing constraintsfatkodima2018-02-171-2/+5
| |
| * 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-252-3/+3
| |
| * Use assert_predicate and assert_not_predicateDaniel Colson2018-01-255-55/+55
| |
| * Use respond_to test helpersDaniel Colson2018-01-253-4/+4
| |
| * 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
| |
* | Use more realistic setup rather than stubbingYuki Nishijima2017-12-291-89/+75
|/ | | | | | | | | | These assertions did matter due to the inconsistent behavior of [the #parameters method][1]. Today, it behaves consistently and they could be removed. Also, one of the methods was stubbed somewhat incorrectly, so it is better not to stub and instead, make them close to more realistic use cases. [1]: https://github.com/rails/rails/pull/13999#issuecomment-34601746
* Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the futureRyuta Kamizono2017-12-141-1/+1
| | | | Follow up of #31432.
* Enable `Layout/SpaceBeforeComma` rubocop rule, and fixed moreRyuta Kamizono2017-12-121-1/+1
| | | | Follow up of #31390.
* Change the system tests to set Puma as default server only when the user ↵Guillermo Iguaran2017-12-091-1/+18
| | | | haven't specified manually another server.
* Add secure `X-Download-Options` and `X-Permitted-Cross-Domain-Policies` to ↵Guillermo Iguaran2017-12-091-2/+6
| | | | default headers set.
* Add headless firefox driver to System Testsbogdanvlviv2017-12-072-0/+14
|
* Fix CSP copy boolean directives (#31326)Simon Dawson2017-12-051-0/+9
| | | Use Object#deep_dup to safely duplicate policy values
* Embrace the instantiation in loving parens <3Kasper Timm Hansen2017-12-031-1/+2
|
* Merge pull request #31146 from ↵Kasper Timm Hansen2017-12-031-41/+83
|\ | | | | | | | | mikeycgto/actiondispatch-cookie-store-test-updates Update cookie_store_test to use encrypted cookies
| * Update cookie_store_test to use encrypted cookiesMichael Coyne2017-11-271-41/+83
| | | | | | | | | | | | | | This now modernizes these tests to use encrypted cookies instead of using secret_token HMACs. This commit also adds a tests to ensure session cookies with :expires_after set are invalidated and no longer accepted when the time has elapsed.
* | Make screenshots default to "simple" formateileencodes2017-11-291-0/+7
| | | | | | | | | | | | | | | | | | Not everyone uses iTerm2 and whereas Terminal.app on a mac just ignores that and outputs the path, other terminals like those on Ubuntu do not. A friendlier default is one that works by default. Closes #31159 Closes #30957
* | Fix tests: Remove ogx mime type from testsGuillermo Iguaran2017-11-291-1/+1
| |
* | Register most popular audio/video/font mime types supported by modern browsersGuillermo Iguaran2017-11-281-6/+6
| |
* | Fix optimized url helpers when using relative url rootAndrew White2017-11-281-0/+37
|/ | | | Fixes #31220.