Commit Graph

123 Commits

Author SHA1 Message Date
bogdanvlviv
6673cf7071
Use require_relative instead of require with full path 2017-06-14 12:10:17 +03:00
bogdanvlviv
40bdbce191
Define path with __dir__
".. with __dir__ we can restore order in the Universe." - by @fxn

Related to 5b8738c2df003a96f0e490c43559747618d10f5f
2017-05-23 00:53:51 +03:00
Matthew Draper
fd097cff79 Work around all the things 2017-04-06 07:19:58 +09:30
Matthew Draper
c866cf9df8 Avoid "can't modify frozen IOError" failures
https://bugs.ruby-lang.org/issues/13239
2017-04-05 06:27:52 +09:30
Matthew Draper
62a8e838e0 Fix a race in ActionCable stream tests
These tests double-stub connection.pubsub, so we need to ensure the
first call's completed before we set up for the second.
2017-03-23 05:52:38 +10:30
Matthew Draper
3721b859b6 Deprecate the EventedRedis subscription adapter
Unlike Faye support, it seems a bit too documented to remove without
warning. So, here's a warning.
2017-02-23 10:48:30 +10:30
yuuji.yaginuma
c42bd31977 correctly check error message
`assert_raise` does not check error message. However, in some tests,
it seems like expecting error message checking with `assert_raise`.
Instead of specifying an error message in `assert_raise`, modify to use
another assert to check the error message.
2017-01-25 09:58:15 +09:00
Chad Ingram
a9c4dcee8d Add channel_prefix support to ActionCable redis/evented_redis adapters. 2017-01-17 23:21:39 -05:00
Duncan Grazier
23e3e2bc2b ActionCable should not raise when a connection is already open
ActionCable was throwing a "Existing connection must be closed before
opening" exception which was being picked up as a production issue in
our error monitoring software. Since this happens pretty often on any
device that allows the browser to sleep (mobile) this error was getting
triggered often.

This change removes the exception, but keeps logging the occurrence. We
now return `false` to let the caller now that `open` failed.
2017-01-06 12:49:58 -05:00
Akira Matsuda
79c17a2d91 Privatize unneededly protected methods in Action Cable tests 2016-12-24 00:15:24 +09:00
Matthew Draper
162e889f16 Prevent race condition when launching EventMachine reactor
reactor_running? will be true just after the thread enters
EventMachine.run; reactor_thread only gets set after the internal
initialize_event_machine method has been called, the C extension is set
up, and it is entering its run loop.
2016-11-30 22:55:04 +10:30
Javan Makhmali
7083fa27a4 Add more Action Cable JavaScript tests 2016-11-21 09:50:00 -05:00
Rafael Mendonça França
fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
Matthew Draper
dae4044734 Permit same-origin connections by default
WebSocket always defers the decision to the server, because it didn't
have to deal with legacy compatibility... but the same-origin policy is
still a reasonable default.

Origin checks do not protect against a directly connecting attacker --
they can lie about their host, but can also lie about their origin.
Origin checks protect against a connection from 3rd-party controlled
script in a context where a victim browser's cookies will be passed
along. And if an attacker has breached that protection, they've already
compromised the HTTP session, so treating the WebSocket connection in
the same way seems reasonable.

In case this logic proves incorrect (or anyone just wants to be more
paranoid), we retain a config option to disable it.
2016-10-11 12:51:10 +10:30
Matthew Draper
f8c53eff7b Merge pull request #26568 from skateman/cable-sameorigin-as-host
Optionally allow ActionCable requests from the same host as origin
2016-10-11 12:28:38 +10:30
Matthew Draper
1fe967d0c9 Wait for the socket to be closed asynchronously 2016-10-06 13:12:35 +10:30
Matthew Draper
acd7ba795e Use a branch of websocket-client-simple, to work around read/close race 2016-10-06 12:51:26 +10:30
Matthew Draper
39fb3069f8 Don't shut down adapters that haven't been set
We hit when we skip the PostgreSQL adapter.
2016-10-04 06:40:38 +10:30
Jon Moss
d1cc11a360 Add tests for Server::Base#restart 2016-10-02 09:02:01 -04:00
Matthew Draper
7c812c2401 Use websocket-client-simple instead of Faye as a websockets client
Mostly, this is just to avoid EventMachine. But there's also an argument
to be made that we're better off using a different protocol library for
our test suite than the one we use to implement the server.
2016-10-02 12:25:33 +10:30
Matthew Draper
a5abc310cd Shut down EventMachine before re-enabling warnings 2016-10-02 12:25:33 +10:30
Matthew Draper
3e779d3c67 In-line the configuration points that only existed for Faye support 2016-10-01 15:36:26 +09:30
Matthew Draper
d44177d45e Remove Faye mode
No deprecation, because it was never documented.
2016-10-01 15:35:59 +09:30
Matthew Draper
9588a3d66d Merge pull request #26547 from palkan/fix/actioncable-confirmation-race-condition
Avoid race condition on subscription confirmation
2016-10-01 15:18:39 +09:30
Matthew Draper
5d92089bca Buffer writes to the cable sockets
Otherwise, they can sometimes block, leading to reduced system
throughput.
2016-09-28 06:44:23 +09:30
palkan
3e68d8b872 Add Channel#ensure_confirmation_sent; call #subscribe_to_channel after initializing 2016-09-22 20:25:09 +03:00
Dávid Halász
268c340b09 Optionally allow ActionCable requests from the same host as origin
When the `allow_same_origin_as_host` is set to `true`, the request
forgery protection permits `HTTP_ORIGIN` values starting with the
corresponding `proto://` prefix followed by `HTTP_HOST`. This way
it is not required to specify the list of allowed URLs.
2016-09-21 16:10:46 +02:00
palkan
03a209e92a [Fix #25381] Avoid race condition on subscription confirmation 2016-09-20 19:42:24 +03:00
Jon Moss
831e2c8d1b Prevent invocation of channel action if rejected connection
Fixes #23757.

Before this commit, even if `reject` was called in the `subscribe`
method for an Action Cable channel, all actions on that channel could
still be invoked. This calls a `return` if a rejected connection tries
to invoke any actions on the channel.
2016-08-19 13:00:39 -04:00
Rafael Mendonça França
55f9b8129a
Add three new rubocop rules
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces

Fix all violations in the repository.
2016-08-16 04:30:11 -03:00
Xavier Noria
46f511685c revises more Lint/EndAlignment offenses 2016-08-08 18:25:11 +02:00
Ryuta Kamizono
762e3f05f3 Add Style/EmptyLines in .rubocop.yml and remove extra empty lines 2016-08-07 17:50:59 +09:00
Xavier Noria
b326e82dc0 applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
Xavier Noria
80e66cc4d9 normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
Xavier Noria
411ccbdab2 remove redundant curlies from hash arguments 2016-08-06 19:44:11 +02:00
Xavier Noria
f8477f13bf applies new string literal convention in actioncable/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:15:15 +02:00
Matthew Draper
08a9074613 Merge pull request #24988 from mwear/action_cable_broadcast_notifications
Add ActiveSupport::Notifications hook to ActionCable::Server.broadcast
2016-07-04 08:44:14 +09:30
Matthew Draper
550303c05c Merge pull request #25030 from mmmpa/pull_request
ActionCable, sometimes add_channel is not called.
2016-07-04 08:39:02 +09:30
Tinco Andringa
3120b51de7 close hijacked i/o socket after use (fixes #25613) 2016-07-01 23:03:30 +02:00
Kasper Timm Hansen
754e5bdf87 Make client test run individually.
Require our dependency and forgo the core ext version.
2016-06-28 18:54:30 +02:00
Gaurav Sharma
4db92eed3b client test have not using Pathname and hashwithindifferent access 2016-06-26 01:49:54 +05:30
Matthew Draper
a8df1bc345 Properly support reloading for Action Cable channels 2016-06-02 04:08:48 +09:30
Javan Makhmali
410a32ffbd Add helper for testing against a mock WebSocket and server 2016-05-31 13:06:11 -04:00
Jon Moss
fb0f0c7f6e Reorganize MockWebSocket 2016-05-31 13:06:11 -04:00
Jon Moss
66901c1849 Add configuration for WebSocket and logger
[Javan Makhmali, Jon Moss]
2016-05-31 13:06:08 -04:00
mmmpa
711d232f93 Add guard to broadcast. 2016-05-26 05:22:56 +09:00
Matthew Wear
f3ba0c1dd3 Add ActiveSupport::Notifications hook to Broadcaster#broadcast
This addition of this notification hook will give users better visibility
into the messages being sent over the PubSub adapter.
2016-05-12 10:56:35 -07:00
Javan Makhmali
71d4066972 Kick off initial JavaScript tests 2016-05-09 09:36:53 -04:00
Jeremy Daer
3ba0eec20c
Cable: Extract stream handler construction
* Use separate stream handler builders for easy override and testing.
* Fix worker pool execution that was silently failing since it only
  expected connection receivers.

Sparked by code in #24162.
2016-04-18 23:29:51 -07:00
Jeremy Daer
983b743c8c
Cable: Periodic timers refresh
* Rewrite docs
* Support blocks in addition to method names and Proc args
* Check for valid arguments
* Convert `periodically :method_name` to Proc callbacks
* Drop periodic runner methods from the worker pool
* Ensure we clear active periodic timers after shutdown
2016-04-18 13:08:22 -07:00