-
Notifications
You must be signed in to change notification settings - Fork 10
Cleanup : Removing hardcoded strings #222
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4b176e4
removing hardcoded string
nishika26 b3daa64
test email
nishika26 b1de256
Merge branch 'main' into cleanup/hardcoded_string
nishika26 ba8daaf
Merge branch 'main' into cleanup/hardcoded_string
nishika26 2f53af0
removing unwanted values
nishika26 b310ab7
Merge branch 'main' into cleanup/hardcoded_string
nishika26 41ccb3d
test fixes
nishika26 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,37 +10,18 @@ DOMAIN=localhost | |
|
|
||
| # DOMAIN=localhost.tiangolo.com | ||
|
|
||
| # Used by the backend to generate links in emails to the frontend | ||
|
|
||
| FRONTEND_HOST=http://localhost:5173 | ||
|
|
||
| # In staging and production, set this env var to the frontend host, e.g. | ||
|
|
||
| # FRONTEND_HOST=https://dashboard.example.com | ||
|
|
||
| # Environment: local, staging, production | ||
|
|
||
| ENVIRONMENT=local | ||
|
|
||
| PROJECT_NAME="AI Platform" | ||
| STACK_NAME=ai-platform | ||
|
|
||
| # Backend | ||
|
|
||
| BACKEND_CORS_ORIGINS="http://localhost:5173" | ||
| #Backend | ||
| SECRET_KEY=changethis | ||
| [email protected] | ||
| FIRST_SUPERUSER_PASSWORD=changethis | ||
|
|
||
| # Emails | ||
|
|
||
| SMTP_HOST= | ||
| SMTP_USER= | ||
| SMTP_PASSWORD= | ||
| [email protected] | ||
| SMTP_TLS=True | ||
| SMTP_SSL=False | ||
| SMTP_PORT=587 | ||
| EMAIL_TEST_USER="[email protected]" | ||
|
|
||
| # Postgres | ||
|
|
||
|
|
@@ -62,6 +43,7 @@ DOCKER_IMAGE_FRONTEND=frontend | |
| AWS_ACCESS_KEY_ID= | ||
| AWS_SECRET_ACCESS_KEY= | ||
| AWS_DEFAULT_REGION=ap-south-1 | ||
| AWS_S3_BUCKET_PREFIX = "bucket-prefix-name" | ||
|
|
||
| # OpenAI | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,6 @@ | |
| from typing import Annotated, Any, Literal | ||
|
|
||
| from pydantic import ( | ||
| AnyUrl, | ||
| BeforeValidator, | ||
| EmailStr, | ||
| HttpUrl, | ||
| PostgresDsn, | ||
|
|
@@ -40,20 +38,8 @@ class Settings(BaseSettings): | |
| SECRET_KEY: str = secrets.token_urlsafe(32) | ||
| # 60 minutes * 24 hours * 1 days = 1 days | ||
| ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 1 | ||
| FRONTEND_HOST: str = "http://localhost:5173" | ||
| ENVIRONMENT: Literal["local", "staging", "production"] = "local" | ||
|
|
||
| BACKEND_CORS_ORIGINS: Annotated[ | ||
| list[AnyUrl] | str, BeforeValidator(parse_cors) | ||
| ] = [] | ||
|
|
||
| @computed_field # type: ignore[prop-decorator] | ||
| @property | ||
| def all_cors_origins(self) -> list[str]: | ||
| return [str(origin).rstrip("/") for origin in self.BACKEND_CORS_ORIGINS] + [ | ||
| self.FRONTEND_HOST | ||
| ] | ||
|
|
||
| PROJECT_NAME: str | ||
| SENTRY_DSN: HttpUrl | None = None | ||
| POSTGRES_SERVER: str | ||
|
|
@@ -74,40 +60,21 @@ def SQLALCHEMY_DATABASE_URI(self) -> PostgresDsn: | |
| path=self.POSTGRES_DB, | ||
| ) | ||
|
|
||
| SMTP_TLS: bool = True | ||
| SMTP_SSL: bool = False | ||
| SMTP_PORT: int = 587 | ||
| SMTP_HOST: str | None = None | ||
| SMTP_USER: str | None = None | ||
| SMTP_PASSWORD: str | None = None | ||
| EMAILS_FROM_EMAIL: EmailStr | None = None | ||
| EMAILS_FROM_NAME: EmailStr | None = None | ||
|
|
||
| @model_validator(mode="after") | ||
| def _set_default_emails_from(self) -> Self: | ||
| if not self.EMAILS_FROM_NAME: | ||
| self.EMAILS_FROM_NAME = self.PROJECT_NAME | ||
| return self | ||
|
|
||
| EMAIL_RESET_TOKEN_EXPIRE_HOURS: int = 48 | ||
| EMAIL_TEST_USER: EmailStr | ||
|
|
||
| @computed_field # type: ignore[prop-decorator] | ||
| @property | ||
| def emails_enabled(self) -> bool: | ||
| return bool(self.SMTP_HOST and self.EMAILS_FROM_EMAIL) | ||
|
|
||
| EMAIL_TEST_USER: EmailStr = "[email protected]" | ||
| FIRST_SUPERUSER: EmailStr | ||
| FIRST_SUPERUSER_PASSWORD: str | ||
|
|
||
| AWS_ACCESS_KEY_ID: str = "" | ||
| AWS_SECRET_ACCESS_KEY: str = "" | ||
| AWS_DEFAULT_REGION: str = "" | ||
| AWS_S3_BUCKET_PREFIX: str = "" | ||
|
|
||
| @computed_field # type: ignore[prop-decorator] | ||
| @property | ||
| def AWS_S3_BUCKET(self) -> str: | ||
| return f"ai-platform-documents-{self.ENVIRONMENT}" | ||
| return f"{self.AWS_S3_BUCKET_PREFIX}-{self.ENVIRONMENT}" | ||
|
|
||
| LOG_DIR: str = os.path.join(os.path.dirname(os.path.dirname(__file__)), "logs") | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,22 +45,6 @@ def test_use_access_token( | |
| assert "email" in result | ||
|
|
||
|
|
||
| def test_recovery_password( | ||
| client: TestClient, normal_user_token_headers: dict[str, str] | ||
| ) -> None: | ||
| with ( | ||
| patch("app.core.config.settings.SMTP_HOST", "smtp.example.com"), | ||
| patch("app.core.config.settings.SMTP_USER", "[email protected]"), | ||
| ): | ||
| email = "[email protected]" | ||
| r = client.post( | ||
| f"{settings.API_V1_STR}/password-recovery/{email}", | ||
| headers=normal_user_token_headers, | ||
| ) | ||
| assert r.status_code == 200 | ||
| assert r.json() == {"message": "Password recovery email sent"} | ||
|
|
||
|
|
||
| def test_recovery_password_user_not_exits( | ||
| client: TestClient, normal_user_token_headers: dict[str, str] | ||
| ) -> None: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,29 +33,6 @@ def test_get_users_normal_user_me( | |
| assert current_user["email"] == settings.EMAIL_TEST_USER | ||
|
|
||
|
|
||
| def test_create_user_new_email( | ||
| client: TestClient, superuser_token_headers: dict[str, str], db: Session | ||
| ) -> None: | ||
| with ( | ||
| patch("app.utils.send_email", return_value=None), | ||
| patch("app.core.config.settings.SMTP_HOST", "smtp.example.com"), | ||
| patch("app.core.config.settings.SMTP_USER", "[email protected]"), | ||
| ): | ||
| username = random_email() | ||
| password = random_lower_string() | ||
| data = {"email": username, "password": password} | ||
| r = client.post( | ||
| f"{settings.API_V1_STR}/users/", | ||
| headers=superuser_token_headers, | ||
| json=data, | ||
| ) | ||
| assert 200 <= r.status_code < 300 | ||
| created_user = r.json() | ||
| user = crud.get_user_by_email(session=db, email=username) | ||
| assert user | ||
| assert user.email == created_user["email"] | ||
|
|
||
|
|
||
| def test_get_existing_user( | ||
| client: TestClient, superuser_token_headers: dict[str, str], db: Session | ||
| ) -> None: | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the idea is also to check if we are using these variables and if not then remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is being used in test cases for user and login routes