Permalink
Browse files

Cater to mIRC by accepting colon-concatenated username and password i…

…n the PASS command
  • Loading branch information...
1 parent 3d9f7ef commit 6abaa7f7c3dd0e62a5bb50961fc5c4a2a637e800 @raws raws committed Nov 30, 2011
Showing with 39 additions and 0 deletions.
  1. +3 −0 lib/hector/concerns/authentication.rb
  2. +36 −0 test/integration/connection_test.rb
@@ -34,6 +34,9 @@ def set_identity
if @identity = identity
cancel_timeout
set_session
+ elsif @password.include?(":")
+ @username, @password = @password.split(":")
+ set_identity
else
error InvalidPassword
end
@@ -32,6 +32,42 @@ class ConnectionTest < IntegrationTest
assert_not_closed c
end
end
+
+ test :"sending a concatenated username and password with PASS should create a session" do
+ connection.tap do |c|
+ pass! c, "sam:secret"
+ user! c
+ nick! c
+
+ assert_not_nil c.session
+ assert_welcomed c
+ assert_not_closed c
+ end
+ end
+
+ test :"sending a username and password with PASS should create a session even if USER credentials are incorrect" do
+ connection.tap do |c|
+ pass! c, "sam:secret"
+ user! c, "invalid"
+ nick! c
+
+ assert_not_nil c.session
+ assert_welcomed c
+ assert_not_closed c
+ end
+ end
+
+ test :"sending an invalid concatenated username and password with PASS should respond with a 464" do
+ connection.tap do |c|
+ pass! c, "sam:invalid"
+ user! c
+ nick! c
+
+ assert_nil c.session
+ assert_invalid_password c
+ assert_closed c
+ end
+ end
test :"sending an unknown command before registration should result in immediate disconnection" do
connection.tap do |c|

0 comments on commit 6abaa7f

Please sign in to comment.