~samwhited/xmpp

ref: c98da397314a57419fb1041f927b83246ed7366d xmpp/sasl_integration_test.go -rw-r--r-- 1.1 KiB
c98da397Sam Whited carbons: new package 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2020 The Mellium Contributors.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

//go:build integration
// +build integration

package xmpp_test

import (
	"context"
	"testing"

	"mellium.im/xmpp/internal/integration"
	"mellium.im/xmpp/internal/integration/mcabber"
	"mellium.im/xmpp/internal/integration/mellium"
	"mellium.im/xmpp/jid"
)

func TestMain(m *testing.M) {
	mellium.TestMain(m)
}

func TestIntegrationSASLClient(t *testing.T) {
	const pass = "testpass"
	melliumRun := mellium.Test(context.TODO(), t,
		integration.Cert("localhost"),
		mellium.ConfigFile(mellium.Config{
			ListenC2S: true,
		}),
		integration.User(jid.MustParse("me@localhost"), pass),
	)
	melliumRun(integrationSASLClient)
}

func integrationSASLClient(ctx context.Context, t *testing.T, cmd *integration.Cmd) {
	j, pass := cmd.User()
	p := cmd.C2SPort()
	mcabberRun := mcabber.Test(context.TODO(), t,
		mcabber.ConfigFile(mcabber.Config{
			JID:      j,
			Password: pass,
			Port:     p,
		}),
	)
	mcabberRun(func(ctx context.Context, t *testing.T, cmd *integration.Cmd) {
		t.Log("Connected successfully!")
	})
}