Repository: emersion/go-smtp
Pull request #74 (2019-11-21 12:20:01)

client: Remove Quit calls from Auth

codecov[bot]: # [Codecov](https://codecov.io/gh/emersion/go-smtp/pull/74?src=pr&el=h1) Report
> Merging [#74](https://codecov.io/gh/emersion/go-smtp/pull/74?src=pr&el=desc) into [master](https://codecov.io/gh/emersion/go-smtp/commit/1190f0d8d61eb91efbc9f30c0c49930fe78193dd?src=pr&el=desc) will **decrease** coverage by `0.19%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/emersion/go-smtp/pull/74/graphs/tree.svg?width=650&token=vj7HO8ABwC&height=150&src=pr)](https://codecov.io/gh/emersion/go-smtp/pull/74?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##           master      #74     +/-   ##
=========================================
- Coverage   63.52%   63.32%   -0.2%     
=========================================
  Files           8        8             
  Lines         869      867      -2     
=========================================
- Hits          552      549      -3     
  Misses        233      233             
- Partials       84       85      +1
```


| [Impacted Files](https://codecov.io/gh/emersion/go-smtp/pull/74?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [client.go](https://codecov.io/gh/emersion/go-smtp/pull/74/diff?src=pr&el=tree#diff-Y2xpZW50Lmdv) | `63.73% <ø> (-0.61%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/emersion/go-smtp/pull/74?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/emersion/go-smtp/pull/74?src=pr&el=footer). Last update [1190f0d...176205c](https://codecov.io/gh/emersion/go-smtp/pull/74?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/client.go b/client.go
index f370b26..ab421f0 100644
--- a/client.go
+++ b/client.go
@@ -242,7 +242,6 @@ func (c *Client) Verify(addr string) error {
 }
 
 // Auth authenticates a client using the provided authentication mechanism.
-// A failed authentication closes the connection.
 // Only servers that advertise the AUTH extension support this function.
 //
 // If server returns an error, it will be of type *SMTPError.
@@ -253,7 +252,6 @@ func (c *Client) Auth(a sasl.Client) error {
 	encoding := base64.StdEncoding
 	mech, resp, err := a.Start()
 	if err != nil {
-		c.Quit()
 		return err
 	}
 	resp64 := make([]byte, encoding.EncodedLen(len(resp)))
@@ -280,7 +278,6 @@ func (c *Client) Auth(a sasl.Client) error {
 		if err != nil {
 			// abort the AUTH
 			c.cmd(501, "*")
-			c.Quit()
 			break
 		}
 		if resp == nil {


Test patch:
diff --git a/client_test.go b/client_test.go
index fcb32db..315c41c 100644
--- a/client_test.go
+++ b/client_test.go
@@ -41,7 +41,7 @@ func TestClientAuthTrimSpace(t *testing.T) {
 	c.didHello = true
 	c.Auth(toServerEmptyAuth{})
 	c.Close()
-	if got, want := wrote.String(), "AUTH FOOAUTH\r\n*\r\nQUIT\r\n"; got != want {
+	if got, want := wrote.String(), "AUTH FOOAUTH\r\n*\r\n"; got != want {
 		t.Errorf("wrote %q; want %q", got, want)
 	}
 }
@@ -643,7 +643,6 @@ var authFailedServer = `220 hello world
 var authFailedClient = `EHLO localhost
 AUTH PLAIN AHVzZXIAcGFzcw==
 *
-QUIT
 `
 
 func TestTLSClient(t *testing.T) {