go-ircevent/irc_sasl_test.go

44 lines
1.0 KiB
Go
Raw Normal View History

2016-07-21 20:55:31 +00:00
package irc
import (
"crypto/tls"
"os"
"testing"
"time"
)
// set SASLLogin and SASLPassword environment variables before testing
func TestConnectionSASL(t *testing.T) {
SASLServer := "irc.freenode.net:7000"
SASLLogin := os.Getenv("SASLLogin")
SASLPassword := os.Getenv("SASLPassword")
if SASLLogin == "" {
2016-07-25 11:27:37 +00:00
t.Skip("Define SASLLogin and SASLPasword environment varables to test SASL")
2016-07-21 20:55:31 +00:00
}
2018-05-14 18:45:57 +00:00
if testing.Short() {
t.Skip("skipping test in short mode.")
}
2016-07-21 20:55:31 +00:00
irccon := IRC("go-eventirc", "go-eventirc")
irccon.VerboseCallbackHandler = true
irccon.Debug = true
irccon.UseTLS = true
irccon.UseSASL = true
irccon.SASLLogin = SASLLogin
irccon.SASLPassword = SASLPassword
irccon.TLSConfig = &tls.Config{InsecureSkipVerify: true}
irccon.AddCallback("001", func(e *Event) { irccon.Join("#go-eventirc") })
irccon.AddCallback("366", func(e *Event) {
irccon.Privmsg("#go-eventirc", "Test Message SASL\n")
time.Sleep(2 * time.Second)
irccon.Quit()
})
err := irccon.Connect(SASLServer)
if err != nil {
t.Fatalf("SASL failed: %s", err)
2016-07-21 20:55:31 +00:00
}
irccon.Loop()
}