-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from TykTechnologies/TT-8971
[TT-8971] Fixing connection strings with +srv bug
- Loading branch information
Showing
2 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,36 @@ func TestParsePassword(t *testing.T) { | |
originalConnString: "mongodb://user:p@ss:/?#[]wor/d@localhost:27017,localhost:27018", | ||
expectedConnString: "mongodb://user:p%40ss%3A%2F%3F%23%5B%5Dwor%2Fd@localhost:27017,localhost:27018", | ||
}, | ||
{ | ||
name: "srv connection string", | ||
originalConnString: "mongodb+srv://tyk:[email protected]/tyk?w=majority", | ||
expectedConnString: "mongodb+srv://tyk:[email protected]/tyk?w=majority", | ||
}, | ||
{ | ||
name: "srv connection string with special characters", | ||
originalConnString: "mongodb+srv://tyk:p@[email protected]/tyk?w=majority", | ||
expectedConnString: "mongodb+srv://tyk:p%[email protected]/tyk?w=majority", | ||
}, | ||
{ | ||
name: "connection string without username", | ||
originalConnString: "mongodb://:password@localhost:27017/test", | ||
expectedConnString: "mongodb://:password@localhost:27017/test", | ||
}, | ||
{ | ||
name: "connection string without password", | ||
originalConnString: "mongodb://user:@localhost:27017/test", | ||
expectedConnString: "mongodb://user:@localhost:27017/test", | ||
}, | ||
{ | ||
name: "connection string without host", | ||
originalConnString: "mongodb://user:password@/test", | ||
expectedConnString: "mongodb://user:password@/test", | ||
}, | ||
{ | ||
name: "connection string without database", | ||
originalConnString: "mongodb://user:password@localhost:27017", | ||
expectedConnString: "mongodb://user:password@localhost:27017", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
|