Skip to content
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 2 commits into from May 27, 2022
Merged

fix(smtp): use usestarttls (match the docs) #252

merged 2 commits into from May 27, 2022

Conversation

JosephKav
Copy link
Contributor

@JosephKav JosephKav commented May 26, 2022

The smtp docs mention UseStartTLS, but it doesn't accept usestarttls, it wants starttls. As UseStartTLS is the Go var, it was probably designed to be usestarttls as the key, so here's a PR for that.

Thanks to @samcro1967 for spotting this in the issue for my PR that added Shoutrrr
release-argus/Argus#33 (comment)

Wasn't sure about how/whether you'd want to keep support for starttls for a while as it would show in the docs if I put it under keys, right?

@codecov
Copy link

codecov bot commented May 26, 2022

Codecov Report

Merging #252 (66cb389) into main (468d552) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #252   +/-   ##
=======================================
  Coverage   77.73%   77.73%           
=======================================
  Files          96       96           
  Lines        2866     2866           
=======================================
  Hits         2228     2228           
  Misses        468      468           
  Partials      170      170           
Impacted Files Coverage Δ
pkg/services/smtp/smtp_config.go 87.09% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 468d552...66cb389. Read the comment docs.

@@ -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:password@example.com: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:password@example.com:2225/?auth=None&encryption=ExplicitTLS&fromaddress=sender%40example.com&fromname=Sender&subject=Subject&toaddresses=rec1%40example.com%2Crec2%40example.com&usehtml=Yes&usestarttls=No"
Copy link
Contributor Author

@JosephKav JosephKav May 26, 2022

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?

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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

Copy link
Contributor Author

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

JosephKav added a commit to release-argus/Argus that referenced this pull request May 27, 2022
email was using `toaddress` instead of `toaddresses`
added internal conversion from `usestarttls` to `starttls` for `notify`
containrrr/shoutrrr#252
Copy link
Member

@piksel piksel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding this!

It's an oversight in the docs generation. When the key doesn't match the field name it should make a note of that, instead of just assuming they will be same.

In any case, this looks good, apart from the breaking change, but that's easily fixed.

@@ -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:password@example.com: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:password@example.com:2225/?auth=None&encryption=ExplicitTLS&fromaddress=sender%40example.com&fromname=Sender&subject=Subject&toaddresses=rec1%40example.com%2Crec2%40example.com&usehtml=Yes&usestarttls=No"
Copy link
Member

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.

pkg/services/smtp/smtp_config.go Outdated Show resolved Hide resolved
pkg/services/smtp/smtp_config.go Outdated Show resolved Hide resolved
@JosephKav JosephKav requested a review from piksel May 27, 2022 10:25
@piksel piksel merged commit 98cdc23 into containrrr:main May 27, 2022
@piksel
Copy link
Member

piksel commented May 27, 2022

@all-contributors add @JosephKav for bug

@allcontributors
Copy link
Contributor

@piksel

I've put up a pull request to add @JosephKav! 🎉

JosephKav added a commit to release-argus/Argus that referenced this pull request May 30, 2022
- `url_fields.username`, not `params.username`
- fix some errors to show it's in params, not url_fields
- remove internal conversion to `starttls` for email as shoutrrr fixed it
containrrr/shoutrrr#252
JosephKav added a commit to release-argus/Argus that referenced this pull request May 30, 2022
…77)

* build(deps): bump github.com/containrrr/shoutrrr from 0.5.3 to 0.6.0

Bumps [github.com/containrrr/shoutrrr](https://github.com/containrrr/shoutrrr) from 0.5.3 to 0.6.0.
- [Release notes](https://github.com/containrrr/shoutrrr/releases)
- [Changelog](https://github.com/containrrr/shoutrrr/blob/main/goreleaser.yml)
- [Commits](containrrr/shoutrrr@v0.5.3...v0.6.0)

---
updated-dependencies:
- dependency-name: github.com/containrrr/shoutrrr
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix(notify): mattermost username harddefault + error printing

- `url_fields.username`, not `params.username`
- fix some errors to show it's in params, not url_fields
- remove internal conversion to `starttls` for email as shoutrrr fixed it
containrrr/shoutrrr#252
- `-test.notify` uses defaults+harddefaults

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joseph Kavanagh <Joseph@kav.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants