beetle 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/beetle.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "beetle"
3
- s.version = "0.2.3"
3
+ s.version = "0.2.4"
4
4
 
5
5
  s.required_rubygems_version = ">= 1.3.1"
6
6
  s.authors = ["Stefan Kaes", "Pascal Friederich", "Ali Jelveh", "Sebastian Roebke"]
@@ -64,6 +64,7 @@ module Beetle
64
64
  def pong(payload)
65
65
  id = payload["id"]
66
66
  token = payload["token"]
67
+ return unless validate_pong_client_id(id)
67
68
  logger.info "Received pong message from id '#{id}' with token '#{token}'"
68
69
  return unless redeem_token(token)
69
70
  @client_pong_ids_received << id
@@ -164,6 +165,15 @@ module Beetle
164
165
  redis.unknowns.include?(current_master) ? redis.slaves_of(current_master).first : current_master
165
166
  end
166
167
 
168
+ def validate_pong_client_id(client_id)
169
+ unless known_client = @client_ids.include?(client_id)
170
+ msg = "Received pong message from unknown client '#{client_id}'"
171
+ logger.error(msg)
172
+ beetle.publish(:system_notification, {"message" => msg}.to_json)
173
+ end
174
+ known_client
175
+ end
176
+
167
177
  def redeem_token(token)
168
178
  valid_token = token == @current_token
169
179
  logger.info "Ignored message (token was '#{token.inspect}', but expected '#{@current_token.inspect}')" unless valid_token
@@ -275,4 +275,22 @@ module Beetle
275
275
  info
276
276
  end
277
277
  end
278
+
279
+ class RedisConfigurationServerSystemNotificationAndLoggingTest < Test::Unit::TestCase
280
+ def setup
281
+ Beetle.config.redis_configuration_client_ids = "rc-client-1,rc-client-2"
282
+ @server = RedisConfigurationServer.new
283
+ @server.stubs(:beetle).returns(stub(:publish))
284
+ @server.stubs(:logger).returns(stub)
285
+ EventMachine.stubs(:add_timer).yields
286
+ end
287
+
288
+ test "should log and send a system notification when pong message from unknown client received" do
289
+ payload = {"id" => "unknown-client", "token" => @server.current_token}
290
+ msg = "Received pong message from unknown client 'unknown-client'"
291
+ @server.beetle.expects(:publish).with(:system_notification, ({:message => msg}).to_json)
292
+ @server.logger.expects(:error).with(msg)
293
+ @server.pong(payload)
294
+ end
295
+ end
278
296
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beetle
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Stefan Kaes
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-07-27 00:00:00 +02:00
21
+ date: 2010-08-06 00:00:00 +02:00
22
22
  default_executable: beetle
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency