mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-05 05:07:38 +08:00
59 lines
1.0 KiB
Go
59 lines
1.0 KiB
Go
package goftp
|
|
|
|
import "testing"
|
|
|
|
//import "fmt"
|
|
|
|
var goodServer string
|
|
var uglyServer string
|
|
var badServer string
|
|
|
|
func init() {
|
|
//ProFTPD 1.3.5 Server (Debian)
|
|
goodServer = "bo.mirror.garr.it:21"
|
|
|
|
//Symantec EMEA FTP Server
|
|
badServer = "ftp.packardbell.com:21"
|
|
|
|
//Unknown server
|
|
uglyServer = "ftp.musicbrainz.org:21"
|
|
}
|
|
|
|
func standard(host string) (msg string) {
|
|
var err error
|
|
var connection *FTP
|
|
|
|
if connection, err = Connect(host); err != nil {
|
|
return "Can't connect ->" + err.Error()
|
|
}
|
|
if err = connection.Login("anonymous", "anonymous"); err != nil {
|
|
return "Can't login ->" + err.Error()
|
|
}
|
|
if _, err = connection.List(""); err != nil {
|
|
return "Can't list ->" + err.Error()
|
|
}
|
|
connection.Close()
|
|
return ""
|
|
}
|
|
|
|
func TestLogin_good(t *testing.T) {
|
|
str := standard(goodServer)
|
|
if len(str) > 0 {
|
|
t.Error(str)
|
|
}
|
|
}
|
|
|
|
func TestLogin_bad(t *testing.T) {
|
|
str := standard(badServer)
|
|
if len(str) > 0 {
|
|
t.Error(str)
|
|
}
|
|
}
|
|
|
|
func TestLogin_ugly(t *testing.T) {
|
|
str := standard(uglyServer)
|
|
if len(str) > 0 {
|
|
t.Error(str)
|
|
}
|
|
}
|