diff --git a/client_test.go b/client_test.go index 16ec031..1c0641a 100644 --- a/client_test.go +++ b/client_test.go @@ -1836,7 +1836,7 @@ func TestClient_DialSendConcurrent_local(t *testing.T) { } } -func TestClient_AuthSCRAMSHA1PLUS_tlsexporter(t *testing.T) { +func TestClient_AuthSCRAMSHAXPLUS_tlsexporter(t *testing.T) { if os.Getenv("TEST_ONLINE_SCRAM") == "" { t.Skipf("TEST_ONLINE_SCRAM is not set. Skipping online SCRAM tests") } @@ -1844,45 +1844,71 @@ func TestClient_AuthSCRAMSHA1PLUS_tlsexporter(t *testing.T) { username := os.Getenv("TEST_USER_SCRAM") password := os.Getenv("TEST_PASS_SCRAM") - client, err := NewClient(hostname, WithTLSPortPolicy(TLSMandatory), - WithSMTPAuth(SMTPAuthSCRAMSHA1PLUS), - WithUsername(username), WithPassword(password)) - if err != nil { - t.Errorf("unable to create new client: %s", err) - return + tests := []struct { + name string + authtype SMTPAuthType + }{ + {"SCRAM-SHA-1-PLUS", SMTPAuthSCRAMSHA1PLUS}, + {"SCRAM-SHA-256-PLUS", SMTPAuthSCRAMSHA256PLUS}, } - if err = client.DialWithContext(context.Background()); err != nil { - t.Errorf("failed to dial to test server: %s", err) - } - if err = client.Close(); err != nil { - t.Errorf("failed to close server connection: %s", err) + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + client, err := NewClient(hostname, + WithTLSPortPolicy(TLSMandatory), + WithSMTPAuth(tt.authtype), + WithUsername(username), WithPassword(password)) + if err != nil { + t.Errorf("unable to create new client: %s", err) + return + } + if err = client.DialWithContext(context.Background()); err != nil { + t.Errorf("failed to dial to test server: %s", err) + } + if err = client.Close(); err != nil { + t.Errorf("failed to close server connection: %s", err) + } + }) } } -func TestClient_AuthSCRAMSHA1PLUS_tlsunique(t *testing.T) { +func TestClient_AuthSCRAMSHAXPLUS_tlsunique(t *testing.T) { if os.Getenv("TEST_ONLINE_SCRAM") == "" { t.Skipf("TEST_ONLINE_SCRAM is not set. Skipping online SCRAM tests") } hostname := os.Getenv("TEST_HOST_SCRAM") username := os.Getenv("TEST_USER_SCRAM") password := os.Getenv("TEST_PASS_SCRAM") - tlsConfig := &tls.Config{} tlsConfig.MaxVersion = tls.VersionTLS12 tlsConfig.ServerName = hostname - client, err := NewClient(hostname, WithTLSPortPolicy(TLSMandatory), - WithTLSConfig(tlsConfig), - WithSMTPAuth(SMTPAuthSCRAMSHA1PLUS), - WithUsername(username), WithPassword(password)) - if err != nil { - t.Errorf("unable to create new client: %s", err) - return + + tests := []struct { + name string + authtype SMTPAuthType + }{ + {"SCRAM-SHA-1-PLUS", SMTPAuthSCRAMSHA1PLUS}, + {"SCRAM-SHA-256-PLUS", SMTPAuthSCRAMSHA256PLUS}, } - if err = client.DialWithContext(context.Background()); err != nil { - t.Errorf("failed to dial to test server: %s", err) - } - if err = client.Close(); err != nil { - t.Errorf("failed to close server connection: %s", err) + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + client, err := NewClient(hostname, + WithTLSPortPolicy(TLSMandatory), + WithTLSConfig(tlsConfig), + WithSMTPAuth(tt.authtype), + WithUsername(username), WithPassword(password)) + if err != nil { + t.Errorf("unable to create new client: %s", err) + return + } + if err = client.DialWithContext(context.Background()); err != nil { + t.Errorf("failed to dial to test server: %s", err) + } + if err = client.Close(); err != nil { + t.Errorf("failed to close server connection: %s", err) + } + }) } }