Full support the legacy URI which doesn't follow RFC3986.
It means the password here should be plain text, not percent-encoded.
This commit is contained in:
@ -40,48 +40,6 @@ class ServerProfileTests: XCTestCase {
|
||||
XCTAssertEqual(newProfile?.remark, profile.remark)
|
||||
}
|
||||
|
||||
func testInitWithPlainURL() {
|
||||
let url = URL(string: "ss://aes-256-cfb:password@example.com:8388")!
|
||||
|
||||
let profile = ServerProfile(url: url)
|
||||
|
||||
XCTAssertNotNil(profile)
|
||||
|
||||
XCTAssertEqual(profile?.serverHost, "example.com")
|
||||
XCTAssertEqual(profile?.serverPort, 8388)
|
||||
XCTAssertEqual(profile?.method, "aes-256-cfb")
|
||||
XCTAssertEqual(profile?.password, "password")
|
||||
XCTAssertEqual(profile?.remark, "")
|
||||
}
|
||||
|
||||
func testInitWithPlainURLandQuery() {
|
||||
let url = URL(string: "ss://aes-256-cfb:password@example.com:8388?Remark=Prism&OTA=true")!
|
||||
|
||||
let profile = ServerProfile(url: url)
|
||||
|
||||
XCTAssertNotNil(profile)
|
||||
|
||||
XCTAssertEqual(profile?.serverHost, "example.com")
|
||||
XCTAssertEqual(profile?.serverPort, 8388)
|
||||
XCTAssertEqual(profile?.method, "aes-256-cfb")
|
||||
XCTAssertEqual(profile?.password, "password")
|
||||
XCTAssertEqual(profile?.remark, "Prism")
|
||||
}
|
||||
|
||||
func testInitWithPlainURLandAnotherQuery() {
|
||||
let url = URL(string: "ss://aes-256-cfb:password@example.com:8388?Remark=Prism&OTA=0")!
|
||||
|
||||
let profile = ServerProfile(url: url)
|
||||
|
||||
XCTAssertNotNil(profile)
|
||||
|
||||
XCTAssertEqual(profile?.serverHost, "example.com")
|
||||
XCTAssertEqual(profile?.serverPort, 8388)
|
||||
XCTAssertEqual(profile?.method, "aes-256-cfb")
|
||||
XCTAssertEqual(profile?.password, "password")
|
||||
XCTAssertEqual(profile?.remark, "Prism")
|
||||
}
|
||||
|
||||
func testInitWithBase64EncodedURL() {
|
||||
// "ss://aes-256-cfb:password@example.com:8388"
|
||||
let url = URL(string: "ss://YWVzLTI1Ni1jZmI6cGFzc3dvcmRAZXhhbXBsZS5jb206ODM4OA")!
|
||||
@ -120,6 +78,19 @@ class ServerProfileTests: XCTestCase {
|
||||
XCTAssertNotNil(profile)
|
||||
XCTAssertEqual(profile?.remark, "example-server")
|
||||
}
|
||||
|
||||
func testInitWithLegacyBase64EncodedURLWithSymboInPassword() {
|
||||
// Note that the legacy URI doesn't follow RFC3986. It means the password here
|
||||
// should be plain text, not percent-encoded.
|
||||
// Ref: https://shadowsocks.org/en/config/quick-guide.html
|
||||
// `ss://bf-cfb:test/!@#:@192.168.100.1:8888`
|
||||
let url = URL(string: "ss://YmYtY2ZiOnRlc3QvIUAjOkAxOTIuMTY4LjEwMC4xOjg4ODg#example")!
|
||||
|
||||
let profile = ServerProfile(url: url)
|
||||
|
||||
XCTAssertNotNil(profile)
|
||||
XCTAssertEqual(profile?.password, "test/!@#:")
|
||||
}
|
||||
|
||||
func testInitWithEmptyURL() {
|
||||
let url = URL(string: "ss://")!
|
||||
|
Reference in New Issue
Block a user