From 1af8eeb971642a6687cde0931f686ea2cc4a088c Mon Sep 17 00:00:00 2001 From: jcadam14 <41971533+jcadam14@users.noreply.github.com> Date: Thu, 4 Apr 2024 00:26:46 -0400 Subject: [PATCH] Removed Sender from service (#29) --- README.md | 3 +-- src/regtech_mail_api/api.py | 4 +--- src/regtech_mail_api/models.py | 2 -- tests/test_authentication.py | 1 - tests/test_send.py | 2 -- 5 files changed, 2 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index fda8a71..fff1dee 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ poetry run pytest ## API The API endpoints require authentication to access. The service uses the [regtech-api-commons](https://github.com/cfpb/regtech-api-commons) library to utilize OAuth2 authentication, currently using Keycloak. -To use either endpoint, you must first get an access token from Keycloak. The service will then use the name and email attributes from the token to populate the Sender field in the email. +To use either endpoint, you must first get an access token from Keycloak. The Contact Name and Email, derived from the Access Token, will be put into the body of the email. To get an access token, run the following curl command, using the Keycloak user you wish to test with (see [LOCAL_DEV_COMPOSE](https://github.com/cfpb/sbl-project/blob/main/LOCAL_DEV_COMPOSE.md) for launching Keycloak): @@ -70,7 +70,6 @@ http://localhost:8765/send | jq '.' "subject": "Institution Profile Change", "body": "lei: 1234567890ABCDEFGHIJ\ninstitution_name_1: Fintech 1\ntin_1: 12-3456789\nrssd_1: 1234567", "from_addr": "noreply@localhost.localdomain", - "sender": " <>", "to": [ "cases@localhost.localdomain" ], diff --git a/src/regtech_mail_api/api.py b/src/regtech_mail_api/api.py index 60f7ccd..d89b973 100644 --- a/src/regtech_mail_api/api.py +++ b/src/regtech_mail_api/api.py @@ -67,8 +67,6 @@ async def send_email(request: Request): type = request.headers["case-type"] subject = f"[DEV BETA] SBL User Request for {type}" - sender = f"{sender_name} <{sender_addr}>" if sender_name else sender_addr - form_data = await request.form() body_lines = [f"{k}: {v}" for k, v in form_data.items()] @@ -76,7 +74,7 @@ async def send_email(request: Request): email_body += f"Contact Name: {sender_name}\n\n" email_body += "\n".join(body_lines) - email = Email(subject, email_body, settings.from_addr, sender, to={settings.to}) + email = Email(subject, email_body, settings.from_addr, to={settings.to}) mailer.send(email) diff --git a/src/regtech_mail_api/models.py b/src/regtech_mail_api/models.py index 981ee7a..72d6de7 100644 --- a/src/regtech_mail_api/models.py +++ b/src/regtech_mail_api/models.py @@ -7,7 +7,6 @@ class Email: subject: str body: str from_addr: str - sender: str to: set[str] cc: set[str] | None = None bcc: set[str] | None = None @@ -16,7 +15,6 @@ def to_email_message(self) -> EmailMessage: message = EmailMessage() message["Subject"] = self.subject message["From"] = self.from_addr - message["Sender"] = self.sender message["To"] = ",".join(self.to) if self.cc: diff --git a/tests/test_authentication.py b/tests/test_authentication.py index f49f08a..d861c49 100644 --- a/tests/test_authentication.py +++ b/tests/test_authentication.py @@ -67,7 +67,6 @@ def test_authed_endpoints( "subject": "Institution Profile Change", "body": "lei: 1234567890ABCDEFGHIJ\ninstitution_name_1: Fintech 1\ntin_1: 12-3456789\nrssd_1: 1234567", "from_addr": "test@cfpb.gov", - "sender": "Jane Doe ", "to": ["cases@localhost.localdomain"], "cc": None, "bcc": None, diff --git a/tests/test_send.py b/tests/test_send.py index 2c3d77a..3a3f987 100644 --- a/tests/test_send.py +++ b/tests/test_send.py @@ -60,7 +60,6 @@ def test_send_no_profile( "subject": "[DEV BETA] SBL User Request for Institution Profile Change", "body": "Contact Email: test@cfpb.gov\nContact Name: \n\nlei: 1234567890ABCDEFGHIJ\ninstitution_name_1: Fintech 1\ntin_1: 12-3456789\nrssd_1: 1234567", "from_addr": "test@cfpb.gov", - "sender": "test@cfpb.gov", "to": ["cases@localhost.localdomain"], "cc": None, "bcc": None, @@ -91,7 +90,6 @@ def test_send( "subject": "[DEV BETA] SBL User Request for Institution Profile Change", "body": "Contact Email: test@cfpb.gov\nContact Name: Test User\n\nlei: 1234567890ABCDEFGHIJ\ninstitution_name_1: Fintech 1\ntin_1: 12-3456789\nrssd_1: 1234567", "from_addr": "test@cfpb.gov", - "sender": "Test User ", "to": ["cases@localhost.localdomain"], "cc": None, "bcc": None,