Skip to content

Commit

Permalink
Tests: add tests for legacy encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
amircybersec committed Oct 14, 2024
1 parent bda257f commit 923a974
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions x/configurl/shadowsocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 923a974

Please sign in to comment.