~samwhited/xmpp

ref: 467e8c4a0b977d765eadf64f02ebb5edee0ce805 xmpp/component/integration_test.go -rw-r--r-- 1.0 KiB
467e8c4aSam Whited component: add integration tests 11 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
// 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.

//+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.NewClientSession(context.Background(), j, []byte(secret), conn, false)
	if err != nil {
		t.Errorf("error negotiating session: %v", err)
	}
}