Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a16290e7 authored by Jan Hilberath's avatar Jan Hilberath
Browse files

fix(test): use "ehlo.thunderbird.net" as EHLO/HELO hostname

parent d150b302
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ class SmtpServerSettingsValidatorTest {
    fun `valid server settings with password should return Success`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250-ENHANCEDSTATUSCODES")
            output("250-AUTH PLAIN LOGIN")
@@ -85,7 +85,7 @@ class SmtpServerSettingsValidatorTest {
        )
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250-ENHANCEDSTATUSCODES")
            output("250-AUTH PLAIN LOGIN OAUTHBEARER")
@@ -119,7 +119,7 @@ class SmtpServerSettingsValidatorTest {
    fun `authentication error should return AuthenticationError`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250-ENHANCEDSTATUSCODES")
            output("250-AUTH PLAIN LOGIN")
@@ -178,7 +178,7 @@ class SmtpServerSettingsValidatorTest {
    fun `missing capability should return MissingServerCapabilityError`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello 127.0.0.1")
            output("250 HELP")
            expect("QUIT")
@@ -209,7 +209,7 @@ class SmtpServerSettingsValidatorTest {
        trustedSocketFactory.injectClientCertificateError(ClientCertificateError.RetrievalFailure)
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello 127.0.0.1")
            output("250-STARTTLS")
            output("250 HELP")
@@ -242,7 +242,7 @@ class SmtpServerSettingsValidatorTest {
        trustedSocketFactory.injectClientCertificateError(ClientCertificateError.CertificateExpired)
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello 127.0.0.1")
            output("250-STARTTLS")
            output("250 HELP")
@@ -275,7 +275,7 @@ class SmtpServerSettingsValidatorTest {
        fakeTrustManager.shouldThrowException = true
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello 127.0.0.1")
            output("250-STARTTLS")
            output("250 HELP")
+27 −27
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ class SmtpTransportTest {
    fun `open() should issue EHLO command`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 OK")
        }
@@ -66,7 +66,7 @@ class SmtpTransportTest {
    fun `open() without AUTH LOGIN extension should connect when not using authentication`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 OK")
        }
@@ -82,7 +82,7 @@ class SmtpTransportTest {
    fun `open() with AUTH PLAIN extension`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH PLAIN LOGIN")
            expect("AUTH PLAIN AHVzZXIAcGFzc3dvcmQ=")
@@ -100,7 +100,7 @@ class SmtpTransportTest {
    fun `open() with AUTH LOGIN extension`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH LOGIN")
            expect("AUTH LOGIN")
@@ -122,7 +122,7 @@ class SmtpTransportTest {
    fun `open() without LOGIN and PLAIN AUTH extensions should throw`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH")
            expect("QUIT")
@@ -143,7 +143,7 @@ class SmtpTransportTest {
    fun `open() with CRAM-MD5 AUTH extension`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH CRAM-MD5")
            expect("AUTH CRAM-MD5")
@@ -163,7 +163,7 @@ class SmtpTransportTest {
    fun `open() without CRAM-MD5 AUTH extension should throw`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH PLAIN LOGIN")
            expect("QUIT")
@@ -184,7 +184,7 @@ class SmtpTransportTest {
    fun `open() with OAUTHBEARER method`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH OAUTHBEARER")
            expect("AUTH OAUTHBEARER bixhPXVzZXIsAWF1dGg9QmVhcmVyIG9sZFRva2VuAQE=")
@@ -202,7 +202,7 @@ class SmtpTransportTest {
    fun `open() with OAUTHBEARER method when XOAUTH2 method is also available`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH XOAUTH2 OAUTHBEARER")
            expect("AUTH OAUTHBEARER bixhPXVzZXIsAWF1dGg9QmVhcmVyIG9sZFRva2VuAQE=")
@@ -220,7 +220,7 @@ class SmtpTransportTest {
    fun `open() with XOAUTH2 extension`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH XOAUTH2")
            expect("AUTH XOAUTH2 dXNlcj11c2VyAWF1dGg9QmVhcmVyIG9sZFRva2VuAQE=")
@@ -238,7 +238,7 @@ class SmtpTransportTest {
    fun `open() with XOAUTH2 extension should throw on 401 response`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250-ENHANCEDSTATUSCODES")
            output("250 AUTH XOAUTH2")
@@ -272,7 +272,7 @@ class SmtpTransportTest {
    fun `open() with XOAUTH2 extension should invalidate and retry on 400 response`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH XOAUTH2")
            expect("AUTH XOAUTH2 dXNlcj11c2VyAWF1dGg9QmVhcmVyIG9sZFRva2VuAQE=")
@@ -300,7 +300,7 @@ class SmtpTransportTest {
    fun `open() with XOAUTH2 extension should invalidate and retry on invalid JSON response`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH XOAUTH2")
            expect("AUTH XOAUTH2 dXNlcj11c2VyAWF1dGg9QmVhcmVyIG9sZFRva2VuAQE=")
@@ -328,7 +328,7 @@ class SmtpTransportTest {
    fun `open() with XOAUTH2 extension should invalidate and retry on missing status JSON response`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH XOAUTH2")
            expect("AUTH XOAUTH2 dXNlcj11c2VyAWF1dGg9QmVhcmVyIG9sZFRva2VuAQE=")
@@ -356,7 +356,7 @@ class SmtpTransportTest {
    fun `open() with XOAUTH2 extension should throw on multiple failures`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250-ENHANCEDSTATUSCODES")
            output("250 AUTH XOAUTH2")
@@ -392,7 +392,7 @@ class SmtpTransportTest {
    fun `open() with XOAUTH2 extension should throw on failure to fetch token`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH XOAUTH2")
            expect("QUIT")
@@ -416,7 +416,7 @@ class SmtpTransportTest {
    fun `open() without OAUTHBEARER extension should throw`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH PLAIN LOGIN")
            expect("QUIT")
@@ -437,7 +437,7 @@ class SmtpTransportTest {
    fun `open() with AUTH EXTERNAL extension`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH EXTERNAL")
            expect("AUTH EXTERNAL dXNlcg==")
@@ -455,7 +455,7 @@ class SmtpTransportTest {
    fun `open() without AUTH EXTERNAL extension should throw`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")
            output("250 AUTH")
            expect("QUIT")
@@ -476,9 +476,9 @@ class SmtpTransportTest {
    fun `open() with EHLO failing should try HELO`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("502 5.5.1, Unrecognized command.")
            expect("HELO [127.0.0.1]")
            expect("HELO ehlo.thunderbird.net")
            output("250 localhost")
        }
        val transport = startServerAndCreateSmtpTransportWithoutAuthentication(server)
@@ -493,7 +493,7 @@ class SmtpTransportTest {
    fun `open() with support for ENHANCEDSTATUSCODES should throw strip enhanced status codes from error message`() {
        val server = MockSmtpServer()
        server.output("220 localhost Simple Mail Transfer Service Ready")
        server.expect("EHLO [127.0.0.1]")
        server.expect("EHLO ehlo.thunderbird.net")
        server.output("250-localhost Hello client.localhost")
        server.output("250-ENHANCEDSTATUSCODES")
        server.output("250 AUTH XOAUTH2")
@@ -526,7 +526,7 @@ class SmtpTransportTest {
    fun `open() with many extensions should parse all`() {
        val server = MockSmtpServer().apply {
            output("220 smtp.gmail.com ESMTP x25sm19117693wrx.27 - gsmtp")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-smtp.gmail.com at your service, [86.147.34.216]")
            output("250-SIZE 35882577")
            output("250-8BITMIME")
@@ -550,14 +550,14 @@ class SmtpTransportTest {
    fun `open() with STARTTLS`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello 127.0.0.1")
            output("250-STARTTLS")
            output("250 HELP")
            expect("STARTTLS")
            output("220 Ready to start TLS")
            startTls()
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello 127.0.0.1")
            output("250 AUTH PLAIN LOGIN")
            expect("AUTH PLAIN AHVzZXIAcGFzc3dvcmQ=")
@@ -579,7 +579,7 @@ class SmtpTransportTest {
    fun `open() with STARTTLS but without STARTTLS capability should throw`() {
        val server = MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello 127.0.0.1")
            output("250 HELP")
            expect("QUIT")
@@ -940,7 +940,7 @@ class SmtpTransportTest {
    private fun createServerAndSetupForPlainAuthentication(vararg extensions: String): MockSmtpServer {
        return MockSmtpServer().apply {
            output("220 localhost Simple Mail Transfer Service Ready")
            expect("EHLO [127.0.0.1]")
            expect("EHLO ehlo.thunderbird.net")
            output("250-localhost Hello client.localhost")

            for (extension in extensions) {