Skip to content

Commit

Permalink
Change login password field to SecretStr and update docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
TheByronHimes committed Jan 12, 2024
1 parent 01fa26f commit c101b2a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
13 changes: 6 additions & 7 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,23 @@ services:
# (Adding the "ports" property to this file will not forward from a Codespace.)

zookeeper:
image: confluentinc/cp-zookeeper:7.3.1
# used ports: 2181
image: confluentinc/cp-zookeeper:7.5.1
environment:
ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000

kafka:
image: confluentinc/cp-server:7.3.1
restart: always
image: confluentinc/cp-server:7.5.1
restart: unless-stopped
depends_on:
- zookeeper
# used ports: 9092
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_DELETE_TOPIC_ENABLE: "true"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_CONFLUENT_LICENSE_TOPIC_REPLICATION_FACTOR: 1
Expand Down
9 changes: 6 additions & 3 deletions src/ns/adapters/outbound/smtp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import ssl
from email.message import EmailMessage

from pydantic import Field
from pydantic import Field, SecretStr
from pydantic_settings import BaseSettings

from ns.ports.outbound.smtp_client import SmtpClientPort
Expand All @@ -31,7 +31,7 @@ class SmtpClientConfig(BaseSettings):
smtp_host: str = Field(..., description="The mail server host to connect to")
smtp_port: int = Field(..., description="The port for the mail server connection")
login_user: str = Field(..., description="The login username or email")
login_password: str = Field(..., description="The login password")
login_password: SecretStr = Field(..., description="The login password")
use_starttls: bool = Field(
default=True, description="Boolean flag indicating the use of STARTTLS"
)
Expand All @@ -57,7 +57,10 @@ def send_email_message(self, message: EmailMessage):
context = ssl.create_default_context()
server.starttls(context=context)
try:
server.login(self._config.login_user, self._config.login_password)
server.login(
self._config.login_user,
self._config.login_password.get_secret_value(),
)
except smtplib.SMTPAuthenticationError as err:
raise self.FailedLoginError() from err

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ def get_config(
smtp_host="127.0.0.1",
smtp_port=get_free_port(),
login_user="test@example.com",
login_password="test123",
login_password="test123", # type: ignore
use_starttls=False,
)
2 changes: 1 addition & 1 deletion tests/fixtures/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def __init__(self, *, config: Config):
"""Assign config"""
self._config = config
self.login = self._config.login_user
self.password = self._config.login_password
self.password = self._config.login_password.get_secret_value()

def _record_email(
self, *, expected_email: EmailMessage, controller: Controller
Expand Down

0 comments on commit c101b2a

Please sign in to comment.