-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(smtp): use usestarttls
(match the docs)
#252
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package smtp | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/smtp" | ||
"net/url" | ||
|
@@ -42,9 +43,10 @@ var _ = Describe("the SMTP service", func() { | |
}) | ||
When("parsing the configuration URL", func() { | ||
It("should be identical after de-/serialization", func() { | ||
testURL := "smtp://user:[email protected]:2225/?auth=None&encryption=ExplicitTLS&fromaddress=sender%40example.com&fromname=Sender&starttls=No&subject=Subject&toaddresses=rec1%40example.com%2Crec2%40example.com&usehtml=Yes" | ||
testURL := "smtp://user:[email protected]:2225/?auth=None&encryption=ExplicitTLS&fromaddress=sender%40example.com&fromname=Sender&subject=Subject&toaddresses=rec1%40example.com%2Crec2%40example.com&usehtml=Yes&usestarttls=No" | ||
|
||
url, err := url.Parse(testURL) | ||
fmt.Println(url) | ||
Expect(err).NotTo(HaveOccurred(), "parsing") | ||
|
||
config := &Config{} | ||
|
@@ -53,6 +55,7 @@ var _ = Describe("the SMTP service", func() { | |
Expect(err).NotTo(HaveOccurred(), "verifying") | ||
|
||
outputURL := config.GetURL() | ||
fmt.Printf("\n\n%s\n%s\n\n-", outputURL, testURL) | ||
|
||
Expect(outputURL.String()).To(Equal(testURL)) | ||
|
||
|
@@ -95,9 +98,9 @@ var _ = Describe("the SMTP service", func() { | |
testutils.TestConfigSetInvalidQueryValue(config, "smtp://example.com/[email protected]&[email protected]&foo=bar") | ||
}) | ||
|
||
It("should have the exped number of fields and enums", func() { | ||
It("should have the expected number of fields and enums", func() { | ||
testutils.TestConfigGetEnumsCount(config, 2) | ||
testutils.TestConfigGetFieldsCount(config, 11) | ||
testutils.TestConfigGetFieldsCount(config, 12) | ||
}) | ||
}) | ||
|
||
|
@@ -189,7 +192,7 @@ var _ = Describe("the SMTP service", func() { | |
When("given a typical usage case configuration URL", func() { | ||
|
||
It("should send notifications without any errors", func() { | ||
testURL := "smtp://user:[email protected]:2225/?startTLS=no&[email protected]&[email protected],[email protected]&useHTML=yes" | ||
testURL := "smtp://user:[email protected]:2225/?useStartTLS=no&[email protected]&[email protected],[email protected]&useHTML=yes" | ||
err := testIntegration(testURL, []string{ | ||
"250-mx.google.com at your service", | ||
"250-SIZE 35651584", | ||
|
@@ -217,7 +220,7 @@ var _ = Describe("the SMTP service", func() { | |
When("given a configuration URL with authentication disabled", func() { | ||
|
||
It("should send notifications without any errors", func() { | ||
testURL := "smtp://example.com:2225/?startTLS=no&[email protected]&[email protected]&useHTML=no" | ||
testURL := "smtp://example.com:2225/?useStartTLS=no&[email protected]&[email protected]&useHTML=no" | ||
err := testIntegration(testURL, []string{ | ||
"250-mx.google.com at your service", | ||
"250-SIZE 35651584", | ||
|
@@ -240,7 +243,7 @@ var _ = Describe("the SMTP service", func() { | |
When("given a configuration URL with StartTLS but it is not supported", func() { | ||
|
||
It("should send notifications without any errors", func() { | ||
testURL := "smtp://example.com:2225/?startTLS=yes&[email protected]&[email protected]&useHTML=no" | ||
testURL := "smtp://example.com:2225/?useStartTLS=yes&[email protected]&[email protected]&useHTML=no" | ||
err := testIntegration(testURL, []string{ | ||
"250-mx.google.com at your service", | ||
"250-SIZE 35651584", | ||
|
@@ -263,7 +266,7 @@ var _ = Describe("the SMTP service", func() { | |
When("server communication fails", func() { | ||
|
||
It("should fail when not being able to enable StartTLS", func() { | ||
testURL := "smtp://example.com:2225/?startTLS=yes&auth=none&[email protected]&[email protected]&useHTML=no" | ||
testURL := "smtp://example.com:2225/?useStartTLS=yes&auth=none&[email protected]&[email protected]&useHTML=no" | ||
err := testIntegration(testURL, []string{ | ||
"250-mx.google.com at your service", | ||
"250-SIZE 35651584", | ||
|
@@ -281,7 +284,7 @@ var _ = Describe("the SMTP service", func() { | |
}) | ||
|
||
It("should fail when authentication type is invalid", func() { | ||
testURL := "smtp://example.com:2225/?startTLS=no&auth=bad&[email protected]&[email protected]&useHTML=no" | ||
testURL := "smtp://example.com:2225/?useStartTLS=no&auth=bad&[email protected]&[email protected]&useHTML=no" | ||
err := testIntegration(testURL, []string{}, "", "") | ||
if msg, test := standard.IsTestSetupFailure(err); test { | ||
Skip(msg) | ||
|
@@ -292,7 +295,7 @@ var _ = Describe("the SMTP service", func() { | |
}) | ||
|
||
It("should fail when not being able to use authentication type", func() { | ||
testURL := "smtp://example.com:2225/?startTLS=no&auth=crammd5&[email protected]&[email protected]&useHTML=no" | ||
testURL := "smtp://example.com:2225/?useStartTLS=no&auth=crammd5&[email protected]&[email protected]&useHTML=no" | ||
err := testIntegration(testURL, []string{ | ||
"250-mx.google.com at your service", | ||
"250-SIZE 35651584", | ||
|
@@ -309,7 +312,7 @@ var _ = Describe("the SMTP service", func() { | |
}) | ||
|
||
It("should fail when not being able to send to recipient", func() { | ||
testURL := "smtp://example.com:2225/?startTLS=no&auth=none&[email protected]&[email protected]&useHTML=no" | ||
testURL := "smtp://example.com:2225/?useStartTLS=no&auth=none&[email protected]&[email protected]&useHTML=no" | ||
err := testIntegration(testURL, []string{ | ||
"250-mx.google.com at your service", | ||
"250-SIZE 35651584", | ||
|
@@ -326,7 +329,7 @@ var _ = Describe("the SMTP service", func() { | |
}) | ||
|
||
It("should fail when the recipient is not accepted", func() { | ||
testURL := "smtp://example.com:2225/?startTLS=no&auth=none&[email protected]&[email protected]&useHTML=no" | ||
testURL := "smtp://example.com:2225/?useStartTLS=no&auth=none&[email protected]&[email protected]&useHTML=no" | ||
err := testSendRecipient(testURL, []string{ | ||
"250 mx.google.com at your service", | ||
"250 Sender OK", | ||
|
@@ -341,7 +344,7 @@ var _ = Describe("the SMTP service", func() { | |
}) | ||
|
||
It("should fail when the server does not accept the data stream", func() { | ||
testURL := "smtp://example.com:2225/?startTLS=no&auth=none&[email protected]&[email protected]&useHTML=no" | ||
testURL := "smtp://example.com:2225/?useStartTLS=no&auth=none&[email protected]&[email protected]&useHTML=no" | ||
err := testSendRecipient(testURL, []string{ | ||
"250 mx.google.com at your service", | ||
"250 Sender OK", | ||
|
@@ -357,7 +360,7 @@ var _ = Describe("the SMTP service", func() { | |
}) | ||
|
||
It("should fail when the server does not accept the data stream content", func() { | ||
testURL := "smtp://example.com:2225/?startTLS=no&auth=none&[email protected]&[email protected]&useHTML=no" | ||
testURL := "smtp://example.com:2225/?useStartTLS=no&auth=none&[email protected]&[email protected]&useHTML=no" | ||
err := testSendRecipient(testURL, []string{ | ||
"250 mx.google.com at your service", | ||
"250 Sender OK", | ||
|
@@ -374,7 +377,7 @@ var _ = Describe("the SMTP service", func() { | |
}) | ||
|
||
It("should fail when the server does not close the connection gracefully", func() { | ||
testURL := "smtp://example.com:2225/?startTLS=no&auth=none&[email protected]&[email protected]&useHTML=no" | ||
testURL := "smtp://example.com:2225/?useStartTLS=no&auth=none&[email protected]&[email protected]&useHTML=no" | ||
err := testIntegration(testURL, []string{ | ||
"250-mx.google.com at your service", | ||
"250-SIZE 35651584", | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed why I had to move this to the end. This is Go doing its usual alphabetising of a map right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, actually Go randomizes the map order. But to make the tests repeatable, we sort the keys in alphabetical order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, must be the yaml encoder that alphabetises my maps then. Unless I have been extremely 'lucky' to have it alphabetised correctly every time I checked after a save
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it does, it has it's own map impl: https://pkg.go.dev/gopkg.in/yaml.v2#MapSlice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish v3 has a MapSlice so that I could choose the order when I save it. Had to make it save the file, then go through and check whether the blocks have been written in the correct order (they won't have been...), then bubble sort those blocks back to how it should be and save again! I did spend a while on ordering the maps, but then found out they were alphabetised and am calling that good enough