func TestInexistentKeyPair(t *testing.T) { srv := xmpp.Server{} err := srv.SetKeyPair("nofile.cert", "nofile.key") if err == nil { t.Errorf("Server should throw an exception if certificate or key are missing") } }
func TestFunctional(t *testing.T) { srv := xmpp.Server{} err := srv.SetKeyPair("test.cert", "test.key") if err != nil { t.Errorf("Could not load certificates: %s", err) } srv.SetAuthFunc(authenticate) err_chan := make(chan error) go func() { // Let's use another port in case xmpp is already open err_chan <- srv.ListenAndServe("tcp", ":5223") }() <-time.After(1 * time.Second) go clientXmpp(t, err_chan) select { case <-time.After(1 * time.Second): case err := <-err_chan: if err != nil { t.Errorf("Error occurred while listening/serving: %s", err) } } }
func ExampleXmppServer() { srv := xmpp.Server{} srv.SetKeyPair("test.cert", "test.key") srv.SetAuthFunc(authenticate) }