Skip to content

Commit

Permalink
xmpp: test SCRAM-SHA-1-PLUS on TLS 1.3
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Whited <[email protected]>
  • Loading branch information
SamWhited committed Dec 4, 2024
1 parent fee27d0 commit 0b8ab53
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions sasl_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@ package xmpp_test

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

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

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

func TestIntegrationSASLClient(t *testing.T) {
func TestIntegrationSASLServer(t *testing.T) {
const pass = "testpass"
melliumRun := mellium.Test(context.TODO(), t,
integration.Cert("localhost"),
Expand All @@ -30,10 +34,10 @@ func TestIntegrationSASLClient(t *testing.T) {
}),
integration.User(jid.MustParse("me@localhost"), pass),
)
melliumRun(integrationSASLClient)
melliumRun(integrationSASLServer)
}

func integrationSASLClient(ctx context.Context, t *testing.T, cmd *integration.Cmd) {
func integrationSASLServer(ctx context.Context, t *testing.T, cmd *integration.Cmd) {
j, pass := cmd.User()
p := cmd.C2SPort()
mcabberRun := mcabber.Test(context.TODO(), t,
Expand All @@ -47,3 +51,29 @@ func integrationSASLClient(ctx context.Context, t *testing.T, cmd *integration.C
t.Log("Connected successfully!")
})
}

func TestIntegrationSASLClient(t *testing.T) {
// TODO (#441): unskip once we have a new release of Prosody.
t.Skip("Needs prosody nightly or a new release.")
prosodyRun := prosody.Test(context.TODO(), t,
integration.Log(),
integration.LogXML(),
prosody.ListenC2S(),
)
prosodyRun(integrationSASLClient)
}

func integrationSASLClient(ctx context.Context, t *testing.T, cmd *integration.Cmd) {
j, pass := cmd.User()
_, err := cmd.DialClient(ctx, j, t,
xmpp.StartTLS(&tls.Config{
MinVersion: tls.VersionTLS13,
InsecureSkipVerify: true,
}),
xmpp.SASL("", pass, sasl.ScramSha1Plus),
xmpp.BindResource(),
)
if err != nil {
t.Fatalf("error connecting: %v", err)
}
}

0 comments on commit 0b8ab53

Please sign in to comment.