feat(proxy): 增加代理池演练并修复账号密码提取,发布 0.5.1
This commit is contained in:
@@ -24,6 +24,35 @@ func TestIPZanRequestURLSetsRequestedCount(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIPZanRequestURLForcesJSONForAuthMode(t *testing.T) {
|
||||
raw := "https://service.ipzan.com/core-extract?num=1&mode=auth&format=txt&secret=x"
|
||||
got, err := NewIPZanProvider().RequestURL(raw, 8)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
u, err := url.Parse(got)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if mode := u.Query().Get("mode"); mode != "auth" {
|
||||
t.Fatalf("mode=%q, want auth", mode)
|
||||
}
|
||||
if format := u.Query().Get("format"); format != "json" {
|
||||
t.Fatalf("format=%q, want json", format)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIPZanParseRejectsAuthModeWithoutCredentials(t *testing.T) {
|
||||
body := []byte(`{"code":0,"status":200,"data":{"list":[{"ip":"1.2.3.4","port":8001}]}}`)
|
||||
_, err := NewIPZanProvider().Parse(
|
||||
"https://service.ipzan.com/core-extract?mode=auth&protocol=1",
|
||||
body,
|
||||
)
|
||||
if err == nil || !IsFatal(err) {
|
||||
t.Fatalf("expected fatal missing-credentials error, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIPZanParseTextMultiple(t *testing.T) {
|
||||
body := []byte("1.2.3.4:8001\r\n5.6.7.8:8002\r\n")
|
||||
got, err := NewIPZanProvider().Parse(
|
||||
|
||||
Reference in New Issue
Block a user