-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: add tests for legacy encoding
- Loading branch information
1 parent
bda257f
commit 923a974
Showing
1 changed file
with
25 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,31 @@ func TestParseShadowsocksURLUserInfoEncoded(t *testing.T) { | |
require.Equal(t, "HTTP/1.1 ", string(config.prefix)) | ||
} | ||
|
||
func TestParseShadowsocksURLUserInfoLegacyEncoded(t *testing.T) { | ||
encoded := base64.StdEncoding.EncodeToString([]byte("aes-256-gcm:shadowsocks")) | ||
urls, err := parseConfig("ss://" + string(encoded) + "@example.com:1234?prefix=HTTP%2F1.1%20" + "#outline-123") | ||
require.NoError(t, err) | ||
require.Equal(t, 1, len(urls)) | ||
|
||
config, err := parseShadowsocksURL(urls[0]) | ||
|
||
require.NoError(t, err) | ||
require.Equal(t, "example.com:1234", config.serverAddress) | ||
require.Equal(t, "HTTP/1.1 ", string(config.prefix)) | ||
} | ||
|
||
func TestLegacyEncodedShadowsocksURL(t *testing.T) { | ||
configString := "ss://[email protected]:1234" | ||
urls, err := parseConfig(configString) | ||
require.NoError(t, err) | ||
require.Equal(t, 1, len(urls)) | ||
|
||
config, err := parseShadowsocksURL(urls[0]) | ||
|
||
require.NoError(t, err) | ||
require.Equal(t, "example.com:1234", config.serverAddress) | ||
} | ||
|
||
func TestParseShadowsocksURLNoEncoding(t *testing.T) { | ||
configString := "ss://aes-256-gcm:[email protected]:1234" | ||
urls, err := parseConfig(configString) | ||
|