strelka 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ChangeLog +156 -9
- data/History.rdoc +15 -0
- data/IDEAS.rdoc +17 -1
- data/MILESTONES.rdoc +1 -1
- data/Manifest.txt +10 -2
- data/Plugins.rdoc +4 -4
- data/README.rdoc +3 -3
- data/Rakefile +5 -4
- data/bin/strelka +19 -10
- data/contrib/hoetemplate/data/project/apps/file_name_app +1 -0
- data/contrib/hoetemplate/lib/file_name.rb.erb +3 -2
- data/examples/apps/hello-world +1 -0
- data/examples/apps/ws-chat +69 -0
- data/examples/apps/ws-echo +61 -0
- data/examples/gen-config.rb +6 -5
- data/lib/strelka/app/auth.rb +2 -2
- data/lib/strelka/app/errors.rb +1 -1
- data/lib/strelka/app/filters.rb +3 -2
- data/lib/strelka/app/negotiation.rb +2 -2
- data/lib/strelka/app/parameters.rb +1 -2
- data/lib/strelka/app/restresources.rb +3 -2
- data/lib/strelka/app/routing.rb +1 -1
- data/lib/strelka/app/sessions.rb +2 -2
- data/lib/strelka/app/templating.rb +7 -3
- data/lib/strelka/app.rb +5 -145
- data/lib/strelka/behavior/plugin.rb +4 -4
- data/lib/strelka/discovery.rb +211 -0
- data/lib/strelka/httprequest.rb +1 -0
- data/lib/strelka/httpresponse/negotiation.rb +7 -1
- data/lib/strelka/mixins.rb +4 -1
- data/lib/strelka/paramvalidator.rb +1 -1
- data/lib/strelka/plugins.rb +8 -6
- data/lib/strelka/websocketserver/routing.rb +116 -0
- data/lib/strelka/websocketserver.rb +147 -0
- data/lib/strelka.rb +5 -4
- data/spec/{lib/constants.rb → constants.rb} +3 -2
- data/spec/{lib/helpers.rb → helpers.rb} +15 -14
- data/spec/strelka/app/auth_spec.rb +145 -142
- data/spec/strelka/app/errors_spec.rb +20 -26
- data/spec/strelka/app/filters_spec.rb +67 -54
- data/spec/strelka/app/negotiation_spec.rb +8 -14
- data/spec/strelka/app/parameters_spec.rb +23 -29
- data/spec/strelka/app/restresources_spec.rb +98 -100
- data/spec/strelka/app/routing_spec.rb +57 -57
- data/spec/strelka/app/sessions_spec.rb +11 -17
- data/spec/strelka/app/templating_spec.rb +36 -40
- data/spec/strelka/app_spec.rb +48 -147
- data/spec/strelka/authprovider/basic_spec.rb +5 -11
- data/spec/strelka/authprovider/hostaccess_spec.rb +9 -15
- data/spec/strelka/authprovider_spec.rb +3 -9
- data/spec/strelka/cookie_spec.rb +32 -38
- data/spec/strelka/cookieset_spec.rb +31 -37
- data/spec/strelka/discovery_spec.rb +144 -0
- data/spec/strelka/exceptions_spec.rb +2 -8
- data/spec/strelka/httprequest/acceptparams_spec.rb +74 -83
- data/spec/strelka/httprequest/auth_spec.rb +5 -15
- data/spec/strelka/httprequest/negotiation_spec.rb +93 -103
- data/spec/strelka/httprequest/session_spec.rb +12 -22
- data/spec/strelka/httprequest_spec.rb +1 -7
- data/spec/strelka/httpresponse/negotiation_spec.rb +84 -76
- data/spec/strelka/httpresponse/session_spec.rb +25 -35
- data/spec/strelka/httpresponse_spec.rb +20 -26
- data/spec/strelka/mixins_spec.rb +66 -61
- data/spec/strelka/multipartparser_spec.rb +31 -37
- data/spec/strelka/paramvalidator_spec.rb +389 -373
- data/spec/strelka/plugins_spec.rb +17 -23
- data/spec/strelka/router/default_spec.rb +32 -38
- data/spec/strelka/router/exclusive_spec.rb +28 -34
- data/spec/strelka/router_spec.rb +2 -8
- data/spec/strelka/session/db_spec.rb +17 -15
- data/spec/strelka/session/default_spec.rb +22 -28
- data/spec/strelka/session_spec.rb +3 -9
- data/spec/strelka/websocketserver/routing_spec.rb +119 -0
- data/spec/strelka/websocketserver_spec.rb +149 -0
- data/spec/strelka_spec.rb +11 -13
- data.tar.gz.sig +3 -3
- metadata +22 -14
- metadata.gz.sig +0 -0
@@ -1,16 +1,10 @@
|
|
1
1
|
# -*- rspec -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
|
7
|
-
$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
|
8
|
-
}
|
4
|
+
require_relative '../../helpers'
|
9
5
|
|
10
6
|
require 'rspec'
|
11
7
|
|
12
|
-
require 'spec/lib/helpers'
|
13
|
-
|
14
8
|
require 'strelka'
|
15
9
|
require 'strelka/session/default'
|
16
10
|
|
@@ -43,13 +37,13 @@ describe Strelka::Session::Default do
|
|
43
37
|
original = Strelka::Session.create( 'default', 'the_session_id' )
|
44
38
|
copy = original.dup
|
45
39
|
copy[:foom] = 1
|
46
|
-
original[:foom].
|
40
|
+
expect( original[:foom] ).to eq( {} )
|
47
41
|
end
|
48
42
|
|
49
43
|
|
50
44
|
it "can be configured to store its session ID in a different cookie" do
|
51
45
|
described_class.configure( :cookie_name => 'buh-mahlon' )
|
52
|
-
described_class.cookie_name.
|
46
|
+
expect( described_class.cookie_name ).to eq( 'buh-mahlon' )
|
53
47
|
end
|
54
48
|
|
55
49
|
it "can load sessions from and save sessions to its in-memory store" do
|
@@ -57,26 +51,26 @@ describe Strelka::Session::Default do
|
|
57
51
|
described_class.save_session_data( 'the_key', session_data )
|
58
52
|
|
59
53
|
loaded = described_class.load_session_data( 'the_key' )
|
60
|
-
loaded.
|
61
|
-
loaded.
|
54
|
+
expect( loaded ).to_not equal( session_data )
|
55
|
+
expect( loaded ).to eq( session_data )
|
62
56
|
end
|
63
57
|
|
64
58
|
it "generates a session-id if one isn't available in the request" do
|
65
59
|
req = @request_factory.get( '/hungry/what-is-in-a-fruit-bowl?' )
|
66
|
-
described_class.get_session_id(
|
60
|
+
expect( described_class.get_session_id(req) ).to match( /^[[:xdigit:]]+$/ )
|
67
61
|
end
|
68
62
|
|
69
63
|
it "rejects invalid session-ids" do
|
70
64
|
session_cookie = "%s=gibberish" % [ @cookie_name ]
|
71
65
|
req = @request_factory.get( '/hungry/what-is-in-a-fruit-bowl?', :cookie => session_cookie )
|
72
|
-
described_class.get_session_id(
|
66
|
+
expect( described_class.get_session_id(req) ).to match( /^[[:xdigit:]]+$/ )
|
73
67
|
end
|
74
68
|
|
75
69
|
it "accepts and reuses an existing valid session-id" do
|
76
70
|
session_id = '3422067061a5790be374c81118d9ed3f'
|
77
71
|
session_cookie = "%s=%s" % [ @cookie_name, session_id ]
|
78
72
|
req = @request_factory.get( '/hungry/what-is-in-a-fruit-bowl?', :cookie => session_cookie )
|
79
|
-
described_class.get_session_id(
|
73
|
+
expect( described_class.get_session_id(req) ).to eq( session_id )
|
80
74
|
end
|
81
75
|
|
82
76
|
it "knows that a request has a session if it has a cookie with an existing session id" do
|
@@ -84,7 +78,7 @@ describe Strelka::Session::Default do
|
|
84
78
|
described_class.sessions[ session_id ] = {}
|
85
79
|
session_cookie = "%s=%s" % [ @cookie_name, session_id ]
|
86
80
|
req = @request_factory.get( '/hungry/what-is-in-a-fruit-bowl?', :cookie => session_cookie )
|
87
|
-
described_class.
|
81
|
+
expect( described_class ).to have_session_for( req )
|
88
82
|
end
|
89
83
|
|
90
84
|
it "can save itself to the store and set the response's session ID" do
|
@@ -96,8 +90,8 @@ describe Strelka::Session::Default do
|
|
96
90
|
|
97
91
|
session.save( response )
|
98
92
|
|
99
|
-
described_class.sessions.
|
100
|
-
response.header_data.
|
93
|
+
expect( described_class.sessions ).to eq( { session_id => session_data } )
|
94
|
+
expect( response.header_data ).to match( /Set-Cookie: #{@cookie_name}=#{session_id}/i )
|
101
95
|
end
|
102
96
|
|
103
97
|
it "can remove itself from the store and expire the response's session ID" do
|
@@ -109,8 +103,8 @@ describe Strelka::Session::Default do
|
|
109
103
|
|
110
104
|
session.destroy( response )
|
111
105
|
|
112
|
-
described_class.sessions.
|
113
|
-
response.header_data.
|
106
|
+
expect( described_class.sessions ).to_not include({ session_id => session_data })
|
107
|
+
expect( response.header_data ).to match( /Set-Cookie: #{@cookie_name}=#{session_id}/i )
|
114
108
|
end
|
115
109
|
|
116
110
|
describe "with no namespace set (the 'nil' namespace)" do
|
@@ -134,8 +128,8 @@ describe Strelka::Session::Default do
|
|
134
128
|
|
135
129
|
subject.namespace = nil
|
136
130
|
|
137
|
-
subject[:foo][:number].
|
138
|
-
subject[:bar][:number].
|
131
|
+
expect( subject[:foo][:number] ).to eq( 18 )
|
132
|
+
expect( subject[:bar][:number] ).to eq( 28 )
|
139
133
|
end
|
140
134
|
|
141
135
|
it "accesses namespaces via a struct-like interface" do
|
@@ -145,9 +139,9 @@ describe Strelka::Session::Default do
|
|
145
139
|
subject.testkey = true
|
146
140
|
subject.namespace = nil
|
147
141
|
|
148
|
-
subject.meat[ :testkey ].
|
149
|
-
subject.greet[ :testkey ].
|
150
|
-
subject.pork[ :testkey ].
|
142
|
+
expect( subject.meat[ :testkey ] ).to be_true
|
143
|
+
expect( subject.greet[ :testkey ] ).to be_true
|
144
|
+
expect( subject.pork[ :testkey ] ).to be_nil
|
151
145
|
end
|
152
146
|
end
|
153
147
|
|
@@ -169,15 +163,15 @@ describe Strelka::Session::Default do
|
|
169
163
|
subject[:number] = 18
|
170
164
|
subject[:not_a_number] = 'woo'
|
171
165
|
|
172
|
-
subject[:number].
|
173
|
-
subject[:not_a_number].
|
166
|
+
expect( subject[:number] ).to eq( 18 )
|
167
|
+
expect( subject[:not_a_number] ).to eq( 'woo' )
|
174
168
|
end
|
175
169
|
|
176
170
|
it "accesses values via a struct-like interface" do
|
177
171
|
subject.testkey = true
|
178
172
|
|
179
|
-
subject.testkey.
|
180
|
-
subject.i_do_not_exist.
|
173
|
+
expect( subject.testkey ).to be_true
|
174
|
+
expect( subject.i_do_not_exist ).to be_nil
|
181
175
|
end
|
182
176
|
end
|
183
177
|
|
@@ -1,16 +1,10 @@
|
|
1
1
|
# -*- rspec -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
7
|
-
$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
|
8
|
-
}
|
4
|
+
require_relative '../helpers'
|
9
5
|
|
10
6
|
require 'rspec'
|
11
7
|
|
12
|
-
require 'spec/lib/helpers'
|
13
|
-
|
14
8
|
require 'strelka'
|
15
9
|
require 'strelka/session'
|
16
10
|
|
@@ -32,7 +26,7 @@ describe Strelka::Session do
|
|
32
26
|
|
33
27
|
|
34
28
|
it "looks for plugins under strelka/session" do
|
35
|
-
described_class.plugin_prefixes.
|
29
|
+
expect( described_class.plugin_prefixes ).to include( 'strelka/session' )
|
36
30
|
end
|
37
31
|
|
38
32
|
|
@@ -50,7 +44,7 @@ describe Strelka::Session do
|
|
50
44
|
|
51
45
|
it "can be asked to load an instance of itself by session ID" do
|
52
46
|
# By default, loading always fails
|
53
|
-
described_class.load( 'the_session_id' ).
|
47
|
+
expect( described_class.load( 'the_session_id' ) ).to be_nil()
|
54
48
|
end
|
55
49
|
|
56
50
|
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
# encoding: utf-8
|
4
|
+
|
5
|
+
require_relative '../../helpers'
|
6
|
+
|
7
|
+
require 'rspec'
|
8
|
+
|
9
|
+
require 'strelka'
|
10
|
+
require 'strelka/plugins'
|
11
|
+
require 'strelka/websocketserver/routing'
|
12
|
+
|
13
|
+
require 'strelka/behavior/plugin'
|
14
|
+
|
15
|
+
|
16
|
+
#####################################################################
|
17
|
+
### C O N T E X T S
|
18
|
+
#####################################################################
|
19
|
+
|
20
|
+
describe Strelka::WebSocketServer::Routing do
|
21
|
+
|
22
|
+
before( :all ) do
|
23
|
+
setup_logging()
|
24
|
+
@frame_factory = Mongrel2::WebSocketFrameFactory.new( route: '/chat' )
|
25
|
+
end
|
26
|
+
|
27
|
+
after( :all ) do
|
28
|
+
reset_logging()
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
it_should_behave_like( "A Strelka Plugin" )
|
33
|
+
|
34
|
+
|
35
|
+
describe "an including App" do
|
36
|
+
|
37
|
+
before( :each ) do
|
38
|
+
@app = Class.new( Strelka::WebSocketServer ) do
|
39
|
+
plugin :routing
|
40
|
+
def initialize( appid='chat-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
|
41
|
+
super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
it "has an Hash of raw routes" do
|
48
|
+
expect( @app.op_callbacks ).to be_a( Hash )
|
49
|
+
end
|
50
|
+
|
51
|
+
it "knows what its route methods are" do
|
52
|
+
expect( @app.op_callbacks ).to eq( {} )
|
53
|
+
@app.class_eval do
|
54
|
+
on_text() {}
|
55
|
+
on_binary() {}
|
56
|
+
on_ping() {}
|
57
|
+
end
|
58
|
+
|
59
|
+
expect( @app.op_callbacks.keys ).to eq([ :text, :binary, :ping ])
|
60
|
+
end
|
61
|
+
|
62
|
+
it "allows the declaration of custom opcodes" do
|
63
|
+
@app.opcodes( 0x3 => :nick )
|
64
|
+
@app.class_eval do
|
65
|
+
on_nick() {}
|
66
|
+
end
|
67
|
+
expect( @app.op_callbacks ).to have( 1 ).member
|
68
|
+
expect( @app.op_callbacks[ :nick ] ).to be_a( UnboundMethod )
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
it "dispatches TEXT frames to a text handler if one is declared" do
|
73
|
+
@app.class_eval do
|
74
|
+
on_text do |frame|
|
75
|
+
res = frame.response
|
76
|
+
res.puts( "#{frame.body.read} Yep!" )
|
77
|
+
return res
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
frame = @frame_factory.text( "/chat", "Clowns?" )
|
82
|
+
response = @app.new.handle_websocket( frame )
|
83
|
+
|
84
|
+
expect( response ).to be_a( Mongrel2::WebSocket::Frame )
|
85
|
+
expect( response.opcode ).to eq( :text )
|
86
|
+
response.body.rewind
|
87
|
+
expect( response.body.read ).to eq( "Clowns? Yep!\n" )
|
88
|
+
end
|
89
|
+
|
90
|
+
it "dispatches custom frame type to its handler if one is declared" do
|
91
|
+
@app.class_eval do
|
92
|
+
opcodes 0xB => :refresh
|
93
|
+
|
94
|
+
on_refresh do |frame|
|
95
|
+
return frame.response
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
frame = @frame_factory.create( '/chat', '', 0xB )
|
100
|
+
response = @app.new.handle_websocket( frame )
|
101
|
+
|
102
|
+
expect( response ).to be_a( Mongrel2::WebSocket::Frame )
|
103
|
+
expect( response.opcode ).to eq( :reserved )
|
104
|
+
expect( response.numeric_opcode ).to eq( 0xB )
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
it "falls back to the defaults if a handler isn't declared for a frame" do
|
109
|
+
frame = @frame_factory.text( '/chat', '' )
|
110
|
+
response = @app.new.handle_websocket( frame )
|
111
|
+
|
112
|
+
expect( response ).to be_a( Mongrel2::WebSocket::Frame )
|
113
|
+
expect( response.opcode ).to eq( :close )
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
# encoding: utf-8
|
4
|
+
|
5
|
+
require_relative '../helpers'
|
6
|
+
|
7
|
+
require 'rspec'
|
8
|
+
require 'zmq'
|
9
|
+
require 'mongrel2'
|
10
|
+
|
11
|
+
require 'strelka'
|
12
|
+
require 'strelka/websocketserver'
|
13
|
+
|
14
|
+
|
15
|
+
#####################################################################
|
16
|
+
### C O N T E X T S
|
17
|
+
#####################################################################
|
18
|
+
|
19
|
+
describe Strelka::WebSocketServer do
|
20
|
+
|
21
|
+
before( :all ) do
|
22
|
+
setup_logging( :fatal )
|
23
|
+
@initial_registry = described_class.loaded_plugins.dup
|
24
|
+
@frame_factory = Mongrel2::WebSocketFrameFactory.new( route: '/chat' )
|
25
|
+
Mongrel2::Config.db = Mongrel2::Config.in_memory_db
|
26
|
+
Mongrel2::Config.init_database
|
27
|
+
|
28
|
+
# Skip loading the 'strelka' gem, which probably doesn't exist in the right version
|
29
|
+
# in the dev environment
|
30
|
+
strelkaspec = make_gemspec( 'strelka', Strelka::VERSION, false )
|
31
|
+
loaded_specs = Gem.instance_variable_get( :@loaded_specs )
|
32
|
+
loaded_specs['strelka'] = strelkaspec
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
before( :each ) do
|
37
|
+
described_class.loaded_plugins.clear
|
38
|
+
@app = Class.new( described_class ) do
|
39
|
+
def initialize( appid=TEST_APPID, sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
|
40
|
+
super
|
41
|
+
end
|
42
|
+
def set_signal_handlers; end
|
43
|
+
def start_accepting_requests; end
|
44
|
+
def restore_signal_handlers; end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
after( :each ) do
|
49
|
+
@app = nil
|
50
|
+
end
|
51
|
+
|
52
|
+
after( :all ) do
|
53
|
+
described_class.loaded_plugins = @initial_registry
|
54
|
+
reset_logging()
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
#
|
59
|
+
# Control frame defaults
|
60
|
+
#
|
61
|
+
|
62
|
+
it "returns a PONG for PING frames" do
|
63
|
+
ping = @frame_factory.ping( '/chat' )
|
64
|
+
res = @app.new.handle_websocket( ping )
|
65
|
+
|
66
|
+
expect( res ).to be_a( Mongrel2::WebSocket::Frame )
|
67
|
+
expect( res.opcode ).to eq( :pong )
|
68
|
+
expect( res.socket_id ).to eq( ping.socket_id )
|
69
|
+
end
|
70
|
+
|
71
|
+
it "ignores PONG frames" do
|
72
|
+
pong = @frame_factory.pong( '/chat' )
|
73
|
+
res = @app.new.handle_websocket( pong )
|
74
|
+
|
75
|
+
expect( res ).to be_nil()
|
76
|
+
end
|
77
|
+
|
78
|
+
it "closes the connection on CLOSE frames" do
|
79
|
+
app = @app.new
|
80
|
+
close = @frame_factory.close( '/chat' )
|
81
|
+
|
82
|
+
expect( app.conn ).to receive( :reply_close ).with( close )
|
83
|
+
|
84
|
+
res = app.handle_websocket( close )
|
85
|
+
expect( res ).to be_nil()
|
86
|
+
end
|
87
|
+
|
88
|
+
it "closes the connection with an appropriate error for reserved control opcodes" do
|
89
|
+
reserved = @frame_factory.create( '/chat', '', 0xB )
|
90
|
+
res = @app.new.handle_websocket( reserved )
|
91
|
+
|
92
|
+
expect( res ).to be_a( Mongrel2::WebSocket::Frame )
|
93
|
+
expect( res.opcode ).to eq( :close )
|
94
|
+
res.payload.rewind
|
95
|
+
expect( res.payload.read ).to match( /Unhandled data type/i )
|
96
|
+
expect( res.socket_id ).to eq( reserved.socket_id )
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# Content frame defaults
|
101
|
+
#
|
102
|
+
|
103
|
+
it "replies with a close frame with a bad data type error for TEXT frames" do
|
104
|
+
app = @app.new
|
105
|
+
frame = @frame_factory.text( '/chat' )
|
106
|
+
|
107
|
+
res = app.handle_websocket( frame )
|
108
|
+
expect( res ).to be_a( Mongrel2::WebSocket::Frame )
|
109
|
+
expect( res.opcode ).to eq( :close )
|
110
|
+
res.payload.rewind
|
111
|
+
expect( res.payload.read ).to match( /Unhandled data type/i )
|
112
|
+
end
|
113
|
+
|
114
|
+
it "replies with a close frame with a bad data type error for BINARY frames" do
|
115
|
+
app = @app.new
|
116
|
+
frame = @frame_factory.binary( '/chat' )
|
117
|
+
|
118
|
+
res = app.handle_websocket( frame )
|
119
|
+
expect( res ).to be_a( Mongrel2::WebSocket::Frame )
|
120
|
+
expect( res.opcode ).to eq( :close )
|
121
|
+
res.payload.rewind
|
122
|
+
expect( res.payload.read ).to match( /Unhandled data type/i )
|
123
|
+
end
|
124
|
+
|
125
|
+
it "replies with a close frame with a bad data type error for CONTINUATION frames" do
|
126
|
+
app = @app.new
|
127
|
+
frame = @frame_factory.continuation( '/chat' )
|
128
|
+
|
129
|
+
res = app.handle_websocket( frame )
|
130
|
+
expect( res ).to be_a( Mongrel2::WebSocket::Frame )
|
131
|
+
expect( res.opcode ).to eq( :close )
|
132
|
+
res.payload.rewind
|
133
|
+
expect( res.payload.read ).to match( /Unhandled data type/i )
|
134
|
+
end
|
135
|
+
|
136
|
+
it "closes the connection with an appropriate error for reserved content opcodes" do
|
137
|
+
reserved = @frame_factory.create( '/chat', '', 0x3 )
|
138
|
+
res = @app.new.handle_websocket( reserved )
|
139
|
+
|
140
|
+
expect( res ).to be_a( Mongrel2::WebSocket::Frame )
|
141
|
+
expect( res.opcode ).to eq( :close )
|
142
|
+
res.payload.rewind
|
143
|
+
expect( res.payload.read ).to match( /Unhandled data type/i )
|
144
|
+
expect( res.socket_id ).to eq( reserved.socket_id )
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
end
|
149
|
+
|
data/spec/strelka_spec.rb
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
#!/usr/bin/env rspec -cfd -b
|
2
2
|
|
3
|
-
|
4
|
-
require 'pathname'
|
5
|
-
basedir = Pathname( __FILE__ ).dirname.parent
|
6
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
7
|
-
}
|
3
|
+
require_relative 'helpers'
|
8
4
|
|
9
5
|
require 'rspec'
|
10
|
-
require 'spec/lib/helpers'
|
11
6
|
require 'strelka'
|
12
7
|
|
13
8
|
describe Strelka do
|
@@ -23,24 +18,27 @@ describe Strelka do
|
|
23
18
|
|
24
19
|
describe "version methods" do
|
25
20
|
it "returns a version string if asked" do
|
26
|
-
described_class.version_string.
|
21
|
+
expect( described_class.version_string ).to match( /\w+ [\d.]+/ )
|
27
22
|
end
|
28
23
|
|
29
24
|
|
30
25
|
it "returns a version string with a build number if asked" do
|
31
|
-
described_class.version_string(true)
|
26
|
+
expect( described_class.version_string(true) ).
|
27
|
+
to match(/\w+ [\d.]+ \(build [[:xdigit:]]+\)/)
|
32
28
|
end
|
33
29
|
end
|
34
30
|
|
35
31
|
it "provides syntactic sugar for looking up an app class by name" do
|
36
32
|
mox_app = nil
|
37
|
-
|
33
|
+
expect( Pathname ).to receive( :glob ).
|
34
|
+
with( 'data/*/{apps,handlers}/**/*' ).
|
38
35
|
and_return([ Pathname('data/mox/apps/moxthefox') ])
|
39
|
-
Kernel.stub( :load ).with( File.expand_path 'data/mox/apps/moxthefox' ).and_return do
|
40
|
-
mox_app = Class.new( Strelka::App )
|
41
|
-
end
|
42
36
|
|
43
|
-
|
37
|
+
expect( Kernel ).to receive( :load ).
|
38
|
+
with( File.expand_path 'data/mox/apps/moxthefox' ).
|
39
|
+
and_return { mox_app = Class.new(Strelka::App) }
|
40
|
+
|
41
|
+
expect( described_class::App('moxthefox') ).to be( mox_app )
|
44
42
|
end
|
45
43
|
|
46
44
|
end
|
data.tar.gz.sig
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
�
|
1
|
+
���["*?(���7�P�qΤļ�L �:��6�raa��]����T�s0��8�^����������P��$��/[� R�! \��>�g_�u�����Y@k��G��A
|
2
|
+
Fs;۬�q����p��j/@x_?�0�}��)ҍ�槦���c9*��5�pi��ƮjZ�j�/w��X5<G[� F�莝���Ԑt�e�q����@�\��
|
3
|
+
7|Mg�����n�^�l�/�!�-t�b�1|�_
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strelka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mahlon E. Smith
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
6mKCwjpegytE0oifXfF8k75A9105cBnNiMZOe1tXiqYc/exCgWvbggurzDOcRkZu
|
32
32
|
/YSusaiDXHKU2O3Akc3htA==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2013-
|
34
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: configurability
|
@@ -109,14 +109,14 @@ dependencies:
|
|
109
109
|
requirements:
|
110
110
|
- - ~>
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: '0.
|
112
|
+
version: '0.40'
|
113
113
|
type: :runtime
|
114
114
|
prerelease: false
|
115
115
|
version_requirements: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
117
|
- - ~>
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version: '0.
|
119
|
+
version: '0.40'
|
120
120
|
- !ruby/object:Gem::Dependency
|
121
121
|
name: pluggability
|
122
122
|
requirement: !ruby/object:Gem::Requirement
|
@@ -235,28 +235,28 @@ dependencies:
|
|
235
235
|
requirements:
|
236
236
|
- - ~>
|
237
237
|
- !ruby/object:Gem::Version
|
238
|
-
version: '0.
|
238
|
+
version: '0.3'
|
239
239
|
type: :development
|
240
240
|
prerelease: false
|
241
241
|
version_requirements: !ruby/object:Gem::Requirement
|
242
242
|
requirements:
|
243
243
|
- - ~>
|
244
244
|
- !ruby/object:Gem::Version
|
245
|
-
version: '0.
|
245
|
+
version: '0.3'
|
246
246
|
- !ruby/object:Gem::Dependency
|
247
|
-
name:
|
247
|
+
name: hoe-bundler
|
248
248
|
requirement: !ruby/object:Gem::Requirement
|
249
249
|
requirements:
|
250
250
|
- - ~>
|
251
251
|
- !ruby/object:Gem::Version
|
252
|
-
version: '
|
252
|
+
version: '1.2'
|
253
253
|
type: :development
|
254
254
|
prerelease: false
|
255
255
|
version_requirements: !ruby/object:Gem::Requirement
|
256
256
|
requirements:
|
257
257
|
- - ~>
|
258
258
|
- !ruby/object:Gem::Version
|
259
|
-
version: '
|
259
|
+
version: '1.2'
|
260
260
|
- !ruby/object:Gem::Dependency
|
261
261
|
name: simplecov
|
262
262
|
requirement: !ruby/object:Gem::Requirement
|
@@ -291,14 +291,14 @@ dependencies:
|
|
291
291
|
requirements:
|
292
292
|
- - ~>
|
293
293
|
- !ruby/object:Gem::Version
|
294
|
-
version: '3.
|
294
|
+
version: '3.7'
|
295
295
|
type: :development
|
296
296
|
prerelease: false
|
297
297
|
version_requirements: !ruby/object:Gem::Requirement
|
298
298
|
requirements:
|
299
299
|
- - ~>
|
300
300
|
- !ruby/object:Gem::Version
|
301
|
-
version: '3.
|
301
|
+
version: '3.7'
|
302
302
|
description: |-
|
303
303
|
Strelka is a framework for creating and deploying
|
304
304
|
Mongrel2[http://mongrel2.org/] web applications in Ruby.
|
@@ -352,6 +352,8 @@ files:
|
|
352
352
|
- examples/apps/hello-world
|
353
353
|
- examples/apps/sessions-demo
|
354
354
|
- examples/apps/upload-demo
|
355
|
+
- examples/apps/ws-chat
|
356
|
+
- examples/apps/ws-echo
|
355
357
|
- examples/config.yml
|
356
358
|
- examples/gen-config.rb
|
357
359
|
- examples/static/examples.css
|
@@ -380,6 +382,7 @@ files:
|
|
380
382
|
- lib/strelka/constants.rb
|
381
383
|
- lib/strelka/cookie.rb
|
382
384
|
- lib/strelka/cookieset.rb
|
385
|
+
- lib/strelka/discovery.rb
|
383
386
|
- lib/strelka/exceptions.rb
|
384
387
|
- lib/strelka/httprequest.rb
|
385
388
|
- lib/strelka/httprequest/acceptparams.rb
|
@@ -400,6 +403,9 @@ files:
|
|
400
403
|
- lib/strelka/session/db.rb
|
401
404
|
- lib/strelka/session/default.rb
|
402
405
|
- lib/strelka/testing.rb
|
406
|
+
- lib/strelka/websocketserver.rb
|
407
|
+
- lib/strelka/websocketserver/routing.rb
|
408
|
+
- spec/constants.rb
|
403
409
|
- spec/data/error.tmpl
|
404
410
|
- spec/data/forms/2_images.form
|
405
411
|
- spec/data/forms/singleupload.form
|
@@ -412,8 +418,7 @@ files:
|
|
412
418
|
- spec/data/forms/testform_truncated_metadata.form
|
413
419
|
- spec/data/layout.tmpl
|
414
420
|
- spec/data/main.tmpl
|
415
|
-
- spec/
|
416
|
-
- spec/lib/helpers.rb
|
421
|
+
- spec/helpers.rb
|
417
422
|
- spec/strelka/app/auth_spec.rb
|
418
423
|
- spec/strelka/app/errors_spec.rb
|
419
424
|
- spec/strelka/app/filters_spec.rb
|
@@ -429,6 +434,7 @@ files:
|
|
429
434
|
- spec/strelka/authprovider_spec.rb
|
430
435
|
- spec/strelka/cookie_spec.rb
|
431
436
|
- spec/strelka/cookieset_spec.rb
|
437
|
+
- spec/strelka/discovery_spec.rb
|
432
438
|
- spec/strelka/exceptions_spec.rb
|
433
439
|
- spec/strelka/httprequest/acceptparams_spec.rb
|
434
440
|
- spec/strelka/httprequest/auth_spec.rb
|
@@ -448,6 +454,8 @@ files:
|
|
448
454
|
- spec/strelka/session/db_spec.rb
|
449
455
|
- spec/strelka/session/default_spec.rb
|
450
456
|
- spec/strelka/session_spec.rb
|
457
|
+
- spec/strelka/websocketserver/routing_spec.rb
|
458
|
+
- spec/strelka/websocketserver_spec.rb
|
451
459
|
- spec/strelka_spec.rb
|
452
460
|
homepage: http://deveiate.org/projects/Strelka
|
453
461
|
licenses:
|
@@ -475,7 +483,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
475
483
|
version: '0'
|
476
484
|
requirements: []
|
477
485
|
rubyforge_project: strelka
|
478
|
-
rubygems_version: 2.
|
486
|
+
rubygems_version: 2.1.10
|
479
487
|
signing_key:
|
480
488
|
specification_version: 4
|
481
489
|
summary: Strelka is a framework for creating and deploying Mongrel2[http://mongrel2.org/]
|
metadata.gz.sig
CHANGED
Binary file
|