-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for ssl dial string #184
Changes from all commits
9c82eb4
afa44b2
4e03a55
f784dc1
aa05fa4
d244ec2
ed07eb9
a304309
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,15 @@ func (s *S) TestPing(c *C) { | |
c.Assert(stats.ReceivedOps, Equals, 1) | ||
} | ||
|
||
func (s *S) TestPingSsl(c *C) { | ||
c.Skip("this test requires the usage of the system provided certificates") | ||
session, err := mgo.Dial("localhost:40001?ssl=true") | ||
c.Assert(err, IsNil) | ||
defer session.Close() | ||
|
||
c.Assert(session.Ping(), IsNil) | ||
} | ||
|
||
func (s *S) TestDialIPAddress(c *C) { | ||
session, err := mgo.Dial("127.0.0.1:40001") | ||
c.Assert(err, IsNil) | ||
|
@@ -135,6 +144,25 @@ func (s *S) TestURLParsing(c *C) { | |
} | ||
} | ||
|
||
func (s *S) TestURLSsl(c *C) { | ||
type test struct { | ||
url string | ||
nilDialServer bool | ||
} | ||
|
||
tests := []test{ | ||
{"localhost:40001", true}, | ||
{"localhost:40001?ssl=false", true}, | ||
{"localhost:40001?ssl=true", false}, | ||
} | ||
|
||
for _, test := range tests { | ||
info, err := mgo.ParseURL(test.url) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to dial to the SSL-enabled node in the test harness ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you give me an example ? I'm not used to test harness. Also how can I run the tests locally please ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! Something like: session, err := mgo.Dial(test.url)
c.Assert(err, IsNil)
c.Assert(session.Ping(), IsNil) Running the tests locally can be tricky if you're on a BSD derivative like OS X, but if you're on linux you should be OK with installing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done aa05fa4 (wasn't able to run it locally, even with |
||
c.Assert(err, IsNil) | ||
c.Assert(info.DialServer == nil, Equals, test.nilDialServer) | ||
} | ||
} | ||
|
||
func (s *S) TestURLReadPreference(c *C) { | ||
type test struct { | ||
url string | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@domodwyer I added
&& info.DialServer == nil
here, to ensure we don't override user's settings.