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

Mail Results - Disable Plugin #6001

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

harvey0100
Copy link
Contributor

Plugin was attempting SMTP connections regardless
of if the plugin config was using defaults.
Now checks on pre/post checks to stop attempted
SMTP connections before the plugin was disabled.

Copy link
Contributor

@clebergnu clebergnu left a comment

Choose a reason for hiding this comment

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

Hi @harvey0100 ,

Thanks for this. It seems to do what's needed, but as you can see in the inline comment, it looks like there's some duplication of similar code.

Please let me know if I'm missing something.

Thanks again!

@@ -160,6 +160,10 @@ def _send_email(smtp, sender, rcpt, msg):

@staticmethod
def _smtp_login_and_send(job, msg):
if not job.config.get("plugins.mail.server"):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why only plugins.mail.server is checked here? AFAICT, all of the configuration (server, port, sender, password) will be needed, right?

If that's the case, a check such as:

server, port, sender, password = Mail._get_smtp_config(job)
if not all([server, port, sender, password]):
   ...

That suggestion of mine looks a lot _validate_email_config() so it seems like it could be refactored a bit and used here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Cleber, thanks for the feedback i've implemented the validate email config inside of login_and_send to refactor now. Looks like it is all working as intended :)

Plugin was attemtping SMTP connections regardless
of if the plugin config was using defaults.
Now checks on pre/post checks to stop attempted
SMTP connections before the plugin was disabled.

Signed-off-by: Harvey Lynden <[email protected]>
Copy link
Contributor

@clebergnu clebergnu left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@clebergnu clebergnu merged commit 6d70beb into avocado-framework:master Aug 22, 2024
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants