RUBY-350 allow ':' in usernames in URI
This commit is contained in:
parent
9aae390eec
commit
63ca1c7648
|
@ -20,7 +20,7 @@ module Mongo
|
||||||
class URIParser
|
class URIParser
|
||||||
|
|
||||||
DEFAULT_PORT = 27017
|
DEFAULT_PORT = 27017
|
||||||
MONGODB_URI_MATCHER = /(([-.\w]+):([^@,]+)@)?((?:(?:[-.\w]+)(?::(?:[\w]+))?,?)+)(\/([-\w]+))?/
|
MONGODB_URI_MATCHER = /(([-.\w:]+):([^@,]+)@)?((?:(?:[-.\w]+)(?::(?:[\w]+))?,?)+)(\/([-\w]+))?/
|
||||||
MONGODB_URI_SPEC = "mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/database]"
|
MONGODB_URI_SPEC = "mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/database]"
|
||||||
SPEC_ATTRS = [:nodes, :auths]
|
SPEC_ATTRS = [:nodes, :auths]
|
||||||
OPT_ATTRS = [:connect, :replicaset, :slaveok, :safe, :w, :wtimeout, :fsync]
|
OPT_ATTRS = [:connect, :replicaset, :slaveok, :safe, :w, :wtimeout, :fsync]
|
||||||
|
|
|
@ -36,6 +36,11 @@ class TestThreading < Test::Unit::TestCase
|
||||||
assert_equal "s-_3#%R.t", parser.auths[0]["password"]
|
assert_equal "s-_3#%R.t", parser.auths[0]["password"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_complex_usernames
|
||||||
|
parser = Mongo::URIParser.new('mongodb://b:ob:secret.word@a.example.com:27018/test')
|
||||||
|
assert_equal "b:ob", parser.auths[0]["username"]
|
||||||
|
end
|
||||||
|
|
||||||
def test_passwords_contain_no_commas
|
def test_passwords_contain_no_commas
|
||||||
assert_raise MongoArgumentError do
|
assert_raise MongoArgumentError do
|
||||||
Mongo::URIParser.new('mongodb://bob:a,b@a.example.com:27018/test')
|
Mongo::URIParser.new('mongodb://bob:a,b@a.example.com:27018/test')
|
||||||
|
|
Loading…
Reference in New Issue