~samwhited/xmpp

7208e44ee826e79c33e561e205f04fb85d93562d — Sam Whited 8 months ago be5a7d9 compression_tests
DNM
2 files changed, 59 insertions(+), 1 deletions(-)

A compress/integration_test.go
M internal/integration/ejabberd/config.go
A compress/integration_test.go => compress/integration_test.go +55 -0
@@ 0,0 1,55 @@
// 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 compress_test

import (
	"context"
	"crypto/tls"
	"testing"

	"mellium.im/sasl"
	"mellium.im/xmpp"
	"mellium.im/xmpp/compress"
	"mellium.im/xmpp/internal/integration"
	"mellium.im/xmpp/internal/integration/ejabberd"
	"mellium.im/xmpp/internal/integration/prosody"
)

func TestIntegrationCompression(t *testing.T) {
	prosodyRun := prosody.Test(context.TODO(), t,
		//integration.Log(),
		prosody.ListenC2S(),
		prosody.StreamCompression(),
	)
	prosodyRun(integrationCompress)

	ejabberdRun := ejabberd.Test(context.TODO(), t,
		integration.Log(),
		ejabberd.ListenC2S(),
		//ejabberd.StreamCompression(),
	)
	ejabberdRun(integrationCompress)
}

func integrationCompress(ctx context.Context, t *testing.T, cmd *integration.Cmd) {
	j, pass := cmd.User()
	session, err := cmd.DialClient(ctx, j, t,
		compress.New(),
		xmpp.StartTLS(&tls.Config{
			InsecureSkipVerify: true,
		}),
		xmpp.SASL("", pass, sasl.Plain),
		xmpp.BindResource(),
	)
	if err != nil {
		t.Fatalf("error connecting: %v", err)
	}
	_, ok := session.Feature(compress.NSFeatures)
	if !ok {
		t.Fatal("stream compression was not negotiated")
	}
}

M internal/integration/ejabberd/config.go => internal/integration/ejabberd/config.go +4 -1
@@ 16,6 16,7 @@ type Config struct {
	S2SSocket  string
	CompSocket string
	Component  map[string]string
	Zlib       bool
}

const inetrc = `{lookup,["file","native"]}.


@@ 46,7 47,8 @@ listen:
    max_stanza_size: 262144
    shaper: c2s_shaper
    access: c2s
    starttls_required: true
		{{ if not .Zlib}}starttls_required: true{{ end }}
		{{ if .Zlib }}zlib: true{{ end }}
{{- end }}
{{- if .S2SSocket }}
  -


@@ 54,6 56,7 @@ listen:
    ip: "::1"
    module: ejabberd_s2s_in
    max_stanza_size: 524288
		{{ if .Zlib }}zlib: true{{ end }}
{{- end }}
{{- if .CompSocket }}
  -