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

Added create transactions #4

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
omit =
*/tests/*
*/__init__.py
api/solomon/infrastructure/*
api/solomon/models.py
app/solomon/infrastructure/*
app/solomon/models.py
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r api/requirements.txt
pip install -r app/requirements.txt

- name: Run migrations
run: |
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM python:3.11-slim-buster as base
WORKDIR /app

# Install dependencies
COPY api/requirements.txt .
COPY app/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy project files
Expand All @@ -17,4 +17,4 @@ FROM base as production
EXPOSE 8000

# Run the application
CMD ["uvicorn", "api.solomon.main:app", "--host", "0.0.0.0", "--port", "8000"]
CMD ["uvicorn", "app.solomon.main:app", "--host", "0.0.0.0", "--port", "8000"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ migration:
alembic revision --autogenerate -m "$(name)"

run-local:
uvicorn api.solomon.main:app --reload
uvicorn app.solomon.main:app --reload

test:
pytest -vv $(file) --cov-report term-missing --cov=. --cov-config=.coveragerc
Expand Down
2 changes: 1 addition & 1 deletion alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[alembic]
# path to migration scripts
script_location = api/solomon/migrations
script_location = app/solomon/migrations

# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
Expand Down
2 changes: 0 additions & 2 deletions api/solomon/models.py

This file was deleted.

28 changes: 0 additions & 28 deletions api/solomon/transactions/application/factories.py

This file was deleted.

26 changes: 0 additions & 26 deletions api/solomon/transactions/domain/models.py

This file was deleted.

8 changes: 0 additions & 8 deletions api/solomon/transactions/infrastructure/factories.py

This file was deleted.

28 changes: 0 additions & 28 deletions api/solomon/transactions/presentation/models.py

This file was deleted.

4 changes: 0 additions & 4 deletions api/solomon/users/infrastructure/factories.py

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions api/tests/solomon/transactions/conftest.py

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from fastapi import Depends

from api.solomon.auth.application.services import AuthService
from api.solomon.users.infrastructure.factories import get_user_repository
from api.solomon.users.infrastructure.repositories import UserRepository
from app.solomon.auth.application.services import AuthService
from app.solomon.users.infrastructure.factories import get_user_repository
from app.solomon.users.infrastructure.repositories import UserRepository


def get_auth_service(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@
import time
from typing import Any

import bcrypt
import jwt
from fastapi import Depends, HTTPException
from fastapi.security import HTTPBearer
from jwt import PyJWTError
from passlib.context import CryptContext
from starlette.status import HTTP_401_UNAUTHORIZED

from api.solomon.auth.domain.exceptions import ExpiredTokenError
from api.solomon.auth.presentation.models import UserTokenAuthenticated
from api.solomon.infrastructure.config import EXPIRES_AT, SECRET_KEY
from api.solomon.users.infrastructure.factories import get_user_repository
from api.solomon.users.infrastructure.repositories import UserRepository

pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
from app.solomon.auth.domain.exceptions import ExpiredTokenError
from app.solomon.auth.presentation.models import UserTokenAuthenticated
from app.solomon.infrastructure.config import EXPIRES_AT, SECRET_KEY
from app.solomon.users.infrastructure.factories import get_user_repository
from app.solomon.users.infrastructure.repositories import UserRepository

security = HTTPBearer()

Expand All @@ -34,7 +32,8 @@ def generate_hashed_password(password: str) -> str:
str
The hashed password.
"""
return pwd_context.hash(password)
hashed_password = bcrypt.hashpw(password.encode(), bcrypt.gensalt())
return hashed_password.decode()


def is_password_valid(plain_password: str, hashed_password: str) -> bool:
Expand All @@ -53,7 +52,7 @@ def is_password_valid(plain_password: str, hashed_password: str) -> bool:
bool
True if the password is valid, False otherwise.
"""
return pwd_context.verify(plain_password, hashed_password)
return bcrypt.checkpw(plain_password.encode(), hashed_password.encode())


def generate_token(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from fastapi.security import HTTPBearer

from api.solomon.auth.application.security import (
from app.solomon.auth.application.security import (
generate_token,
is_password_valid,
)
from api.solomon.auth.domain.exceptions import AuthenticationError
from api.solomon.auth.presentation.models import (
from app.solomon.auth.domain.exceptions import AuthenticationError
from app.solomon.auth.presentation.models import (
LoginCreate,
UserLoggedinResponse,
)
from api.solomon.users.infrastructure.repositories import UserRepository
from app.solomon.users.infrastructure.repositories import UserRepository

security = HTTPBearer()

Expand Down
Loading
Loading