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

Smtp integration #32

Open
wants to merge 119 commits into
base: main
Choose a base branch
from
Open

Smtp integration #32

wants to merge 119 commits into from

Conversation

alithethird
Copy link
Contributor

@alithethird alithethird commented Jan 30, 2025

Overview

Add SMTP integration to 12 Factor apps.

Rationale

User story:
As a user, I need to email my clients for application notifications. I would need SMTP credentials to add email integration to my app so that I can send emails to my clients using the credentials.

Juju Events Changes

Observe smtp_data_available event.

Module Changes

Add 3 new classes to store SMTP credentials.

  • SmtpParameters
  • AuthType
  • TransportSecurity

These classes are copied from smtp library to store smtp credentials correctly.

Add new attribute smtp_parameters to IntegrationsState class to store a SmtpParameters instance.

Add new function _init_smtp in PaasCharm class to handle smtp integration initialization.

Add a couple of unit tests for all frameworks.

Checklist

@alithethird alithethird marked this pull request as draft February 26, 2025 06:11
@alithethird alithethird marked this pull request as ready for review February 27, 2025 08:02
The validated Authentication type.
"""
if auth_type == AuthType.NONE:
return None
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not understand what we are doing in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we don't do this we have to check for it when generating environment variables from it. I think handling this in here is the cleanest way so we don't have to import this class into other places in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we don't turn it into None, we either create a env variable with the value none or we check the auth_type to see if its not none then create the enb variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had discussion with Greg about this. This is more like a property so I will make this a property and set it None when auth_type is string none

Copy link
Contributor

Test results for commit acc491c

Test coverage for acc491c

Name                                          Stmts   Miss Branch BrPart  Cover   Missing
-----------------------------------------------------------------------------------------
src/paas_app_charmer/__init__.py                  2      0      0      0   100%
src/paas_app_charmer/django/__init__.py           2      0      0      0   100%
src/paas_app_charmer/django/charm.py              2      0      0      0   100%
src/paas_app_charmer/fastapi/__init__.py          2      0      0      0   100%
src/paas_app_charmer/fastapi/charm.py             2      0      0      0   100%
src/paas_app_charmer/flask/__init__.py            2      0      0      0   100%
src/paas_app_charmer/flask/charm.py               2      0      0      0   100%
src/paas_app_charmer/go/__init__.py               2      0      0      0   100%
src/paas_app_charmer/go/charm.py                  2      0      0      0   100%
src/paas_charm/__init__.py                       32     17      0      0    47%   13-14, 19-20, 26-27, 33-37, 43-44, 50-51, 57-58
src/paas_charm/_gunicorn/__init__.py              0      0      0      0   100%
src/paas_charm/_gunicorn/charm.py                42      0      6      0   100%
src/paas_charm/_gunicorn/webserver.py            90      4     16      1    95%   209, 221-227
src/paas_charm/_gunicorn/workload_config.py       8      0      0      0   100%
src/paas_charm/_gunicorn/wsgi_app.py             21      0      2      0   100%
src/paas_charm/app.py                           175      0     64      4    98%   115->exit, 172->178, 282->284, 284->287
src/paas_charm/charm.py                         309     40     64      5    87%   35-36, 43-44, 51-52, 60-61, 176-177, 199-200, 220-221, 271-272, 292-293, 339, 349-350, 352-353, 382-386, 456, 460, 554-555, 560, 565, 570, 580, 585, 590, 595, 600, 625, 660
src/paas_charm/charm_state.py                   210     14     30      5    92%   39-41, 48-50, 57-59, 66-68, 254, 357, 581, 598, 630-631
src/paas_charm/charm_utils.py                    23      0      0      0   100%
src/paas_charm/database_migration.py             35      0      2      0   100%
src/paas_charm/databases.py                      25      2      6      1    90%   89-90
src/paas_charm/django/__init__.py                 2      0      0      0   100%
src/paas_charm/django/charm.py                   50      4      8      2    90%   49, 124, 139-140
src/paas_charm/exceptions.py                      5      0      0      0   100%
src/paas_charm/fastapi/__init__.py                2      0      0      0   100%
src/paas_charm/fastapi/charm.py                  31      0      0      0   100%
src/paas_charm/flask/__init__.py                  2      0      0      0   100%
src/paas_charm/flask/charm.py                    26      0      0      0   100%
src/paas_charm/framework.py                      23      4     12      2    77%   36, 49-51
src/paas_charm/go/__init__.py                     2      0      0      0   100%
src/paas_charm/go/charm.py                       29      0      0      0   100%
src/paas_charm/observability.py                  24      3      4      1    86%   42->46, 73-77
src/paas_charm/rabbitmq.py                       78      2     22      5    93%   117->exit, 122->exit, 157->exit, 159-160, 181->175
src/paas_charm/secret_storage.py                 50      2     14      4    91%   55->54, 56->58, 86, 105
src/paas_charm/utils.py                          54      5     16      3    89%   94-95, 113, 117, 142
-----------------------------------------------------------------------------------------
TOTAL                                          1366     97    266     33    92%

Static code analysis report

Run started:2025-02-28 11:30:11.388870

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 2930
  Total lines skipped (#nosec): 1
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 2

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants