Commit 31c5d1b6 authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

fix compare between headers only with the same size

parent 5af7370d
......@@ -154,4 +154,49 @@ class TestPublishMessages < Test::Unit::TestCase
}
end
def config_test_ignore_event_id_header_parameter_with_not_match_exactly
@header_template = nil
@message_template = '{\"id\": \"~id~\", \"channel\": \"~channel~\", \"text\": \"~text~\", \"event_id\": \"~event-id~\"}'
end
def test_ignore_event_id_header_parameter_with_not_match_exactly
event_id = 'event_id_with_generic_text_01'
headers = {'accept' => 'text/html'}
body = 'test message'
channel = 'ch_test_set_an_event_id_to_the_message_through_header_parameter'
response = ''
EventMachine.run {
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
sub.stream { | chunk |
response = JSON.parse(chunk)
assert_equal(1, response["id"].to_i, "Wrong data received")
assert_equal(channel, response["channel"], "Wrong data received")
assert_equal(body, response["text"], "Wrong data received")
assert_equal("", response["event_id"], "Wrong data received")
EventMachine.stop
}
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-Ids' => event_id), :body => body, :timeout => 30
add_test_timeout
}
EventMachine.run {
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
sub.stream { | chunk |
response = JSON.parse(chunk)
assert_equal(2, response["id"].to_i, "Wrong data received")
assert_equal(channel, response["channel"], "Wrong data received")
assert_equal(body, response["text"], "Wrong data received")
assert_equal("", response["event_id"], "Wrong data received")
EventMachine.stop
}
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers.merge('Event-I' => event_id), :body => body, :timeout => 30
add_test_timeout
}
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment