-
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 #76 from TykTechnologies/TT-8978
[TT-8978] Fixing CosmosDB URL bug
- Loading branch information
Showing
4 changed files
with
43 additions
and
13 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
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 |
---|---|---|
|
@@ -62,7 +62,7 @@ func TestIsCosmosDB(t *testing.T) { | |
} | ||
} | ||
|
||
func TestParsePassword(t *testing.T) { | ||
func TestEncodeConnectionString(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
originalConnString string | ||
|
@@ -80,8 +80,8 @@ func TestParsePassword(t *testing.T) { | |
}, | ||
{ | ||
name: "valid connection string with @ and /", | ||
originalConnString: "mongodb://user:p@sswor/d@localhost:27017/test", | ||
expectedConnString: "mongodb://user:p%40sswor%2Fd@localhost:27017/test", | ||
originalConnString: "mongodb://u=s@r:p@sswor/d@localhost:27017/test", | ||
expectedConnString: "mongodb://u%3Ds%40r:p%40sswor%2Fd@localhost:27017/test", | ||
}, | ||
{ | ||
name: "valid connection string with @ and / and '?' outside of the credentials part", | ||
|
@@ -138,11 +138,16 @@ func TestParsePassword(t *testing.T) { | |
originalConnString: "mongodb://user:password@localhost:27017", | ||
expectedConnString: "mongodb://user:password@localhost:27017", | ||
}, | ||
{ | ||
name: "cosmosdb url", | ||
originalConnString: "mongodb://4-0-qa:[email protected]:10/a1?maxIdleTimeMS=120000&appName=@4-testing@", | ||
expectedConnString: "mongodb://4-0-qa:zFAQ%3D%[email protected]:10/a1?maxIdleTimeMS=120000&appName=@4-testing@", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
connString := ParsePassword(test.originalConnString) | ||
connString := EncodeConnectionString(test.originalConnString) | ||
assert.Equal(t, test.expectedConnString, connString) | ||
}) | ||
} | ||
|