~samwhited/xmpp

xmpp/component/integration_test.go -rw-r--r-- 1.0 KiB
e9b0a2deSam Whited docs: do a quick editing pass over the docs a day 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
// 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 component_test

import (
	"context"
	"testing"

	"mellium.im/xmpp/component"
	"mellium.im/xmpp/internal/integration"
	"mellium.im/xmpp/internal/integration/prosody"
	"mellium.im/xmpp/jid"
)

const (
	domain = "component.localhost"
	secret = "fo0b4r"
)

func TestIntegrationComponentClient(t *testing.T) {
	prosodyRun := prosody.Test(context.TODO(), t,
		integration.Log(),
		prosody.ListenC2S(),
		prosody.Component(domain, secret, ""),
	)
	prosodyRun(integrationComponentClient)
}

func integrationComponentClient(ctx context.Context, t *testing.T, cmd *integration.Cmd) {
	j := jid.MustParse(domain)
	conn, err := cmd.ComponentConn(ctx)
	if err != nil {
		t.Errorf("error dialing connection: %v", err)
	}
	_, err = component.NewSession(context.Background(), j, []byte(secret), conn)
	if err != nil {
		t.Errorf("error negotiating session: %v", err)
	}
}