Release 1.6.1: fix subscription button stuck disabled and improve import parsing.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package subscription
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"encoding/base64"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseBodyPlain(t *testing.T) {
|
||||
body := `# comment
|
||||
@@ -15,3 +19,42 @@ naive+https://u:p@n.example.com#naive1
|
||||
t.Fatalf("got %d items", len(items))
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseBodyBase64(t *testing.T) {
|
||||
plain := "hysteria2://secret@host.example:443/?sni=host.example#HY\nhttps://user:pass@naive.example.com#NV\n"
|
||||
body := base64.StdEncoding.EncodeToString([]byte(plain))
|
||||
items, err := ParseBody(body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(items) != 2 {
|
||||
t.Fatalf("got %d items: %+v", len(items), items)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseBodyClashYAML(t *testing.T) {
|
||||
body := `
|
||||
proxies:
|
||||
- name: "DE HY2"
|
||||
type: hysteria2
|
||||
server: de.example.com
|
||||
port: 443
|
||||
password: secret
|
||||
sni: de.example.com
|
||||
obfs: salamander
|
||||
obfs-password: obfspass
|
||||
`
|
||||
items, err := ParseBody(body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(items) != 1 {
|
||||
t.Fatalf("got %d", len(items))
|
||||
}
|
||||
if items[0].Protocol != "hysteria2" {
|
||||
t.Fatalf("proto %s", items[0].Protocol)
|
||||
}
|
||||
if !strings.Contains(items[0].URI, "de.example.com:443") {
|
||||
t.Fatalf("uri %s", items[0].URI)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user