From 6c4b58b594e2bdcf3815022123735157e278ab0d Mon Sep 17 00:00:00 2001 From: Bharath Chadarajupalli Date: Tue, 6 Feb 2024 01:46:06 -0800 Subject: [PATCH 1/5] @W-14870747 - Dependecy updates and disabling Socalapp in db --- config/settings/base.py | 1 + docs/api/schema.yml | 34 ++-- locales_dev/en/translation.json | 3 - metecho/api/models.py | 10 +- metecho/oauth2/adapter.py | 2 +- metecho/oauth2/github/tests/views.py | 2 +- metecho/oauth2/github/views.py | 3 - metecho/oauth2/salesforce/tests/provider.py | 18 +- metecho/oauth2/salesforce/views.py | 3 - metecho/oauth2/tests/adapter.py | 2 +- metecho/oauth2/views.py | 19 -- requirements/dev.txt | 180 ++++++++--------- requirements/prod.in | 8 +- requirements/prod.txt | 205 +++++++++++--------- 14 files changed, 248 insertions(+), 242 deletions(-) diff --git a/config/settings/base.py b/config/settings/base.py index 84c207b14..362d65179 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -121,6 +121,7 @@ def safe_key() -> str: MIDDLEWARE = [ "metecho.logging_middleware.LoggingMiddleware", "sfdo_template_helpers.admin.middleware.AdminRestrictMiddleware", + "allauth.account.middleware.AccountMiddleware", "django.middleware.security.SecurityMiddleware", "whitenoise.middleware.WhiteNoiseMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", diff --git a/docs/api/schema.yml b/docs/api/schema.yml index 185c6833b..73d6546ee 100644 --- a/docs/api/schema.yml +++ b/docs/api/schema.yml @@ -1871,6 +1871,11 @@ components: - Review - Merged type: string + description: |- + * `Planned` - Planned + * `In progress` - In Progress + * `Review` - Review + * `Merged` - Merged FullUser: type: object properties: @@ -1940,8 +1945,6 @@ components: self_guided_tour_enabled: type: boolean self_guided_tour_state: - type: object - additionalProperties: {} nullable: true organizations: type: array @@ -2078,9 +2081,7 @@ components: properties: enabled: type: boolean - state: - type: object - additionalProperties: {} + state: {} MinimalUser: type: object properties: @@ -2118,6 +2119,10 @@ components: - QA - Playground type: string + description: |- + * `Dev` - Dev + * `QA` - QA + * `Playground` - Playground PaginatedEpicList: type: object properties: @@ -2277,8 +2282,6 @@ components: description: type: string ignored_changes_write: - type: object - additionalProperties: {} writeOnly: true org_config_name: type: string @@ -2481,11 +2484,17 @@ components: - Approved - Changes requested type: string + description: |- + * `Approved` - Approved + * `Changes requested` - Changes Requested RoleEnum: enum: - assigned_qa - assigned_dev type: string + description: |- + * `assigned_qa` - assigned_qa + * `assigned_dev` - assigned_dev ScratchOrg: type: object properties: @@ -2612,8 +2621,6 @@ components: type: boolean readOnly: true installed_packages: - type: object - additionalProperties: {} readOnly: true is_omnistudio_installed: type: boolean @@ -2672,8 +2679,6 @@ components: description: type: string ignored_changes_write: - type: object - additionalProperties: {} writeOnly: true org_config_name: type: string @@ -2773,8 +2778,6 @@ components: format: uri readOnly: true commits: - type: object - additionalProperties: {} readOnly: true origin_sha: type: string @@ -2909,6 +2912,11 @@ components: - Completed - Canceled type: string + description: |- + * `Planned` - Planned + * `In progress` - In Progress + * `Completed` - Completed + * `Canceled` - Canceled securitySchemes: cookieAuth: type: apiKey diff --git a/locales_dev/en/translation.json b/locales_dev/en/translation.json index c47eb20ae..a26806896 100644 --- a/locales_dev/en/translation.json +++ b/locales_dev/en/translation.json @@ -59,7 +59,6 @@ "Complete a Task": "Complete a Task", "Completed item": "Completed item", "Confirm": "Confirm", - "Confirm Changing Developer and Deleting Dev Org": "Confirm Changing Developer and Deleting Dev Org", "Confirm Deleting Account": "Confirm Deleting Account", "Confirm Deleting Epic": "Confirm Deleting Epic", "Confirm Deleting Org With Unretrieved Changes": "Confirm Deleting Org With Unretrieved Changes", @@ -174,7 +173,6 @@ "GitHub Repository Name": "GitHub Repository Name", "Go Back": "Go Back", "Heading": "Heading", - "Health Check": "Health Check", "Hello! What can Metecho help you do today?": "Hello! What can Metecho help you do today?", "Help Walkthrough": "Help Walkthrough", "Home": "Home", @@ -397,7 +395,6 @@ "Tester": "Tester", "Tester & Test Org": "Tester & Test Org", "The current scratch org cannot be transferred to the selected GitHub user. Remove the scratch org before transferring this task or correct the following issues: {{issueDescription}}": "The current scratch org cannot be transferred to the selected GitHub user. Remove the scratch org before transferring this task or correct the following issues: {{issueDescription}}", - "The existing Dev Org for this Task has unretrieved changes. Changing the assigned Developer will also delete the Org, and any changes will be lost. Are you sure you want to do that?": "The existing Dev Org for this Task has unretrieved changes. Changing the assigned Developer will also delete the Org, and any changes will be lost. Are you sure you want to do that?", "The existing Dev Org for this Task has unretrieved changes. Removing the assigned Developer will also delete the Org, and any changes will be lost. Are you sure you want to do that?": "The existing Dev Org for this Task has unretrieved changes. Removing the assigned Developer will also delete the Org, and any changes will be lost. Are you sure you want to do that?", "The last line of the log is “{{message}}” If you need support, your scratch org id is {{orgId}}.": "The last line of the log is “{{message}}” If you need support, your scratch org id is {{orgId}}.", "There are no available Epic Collaborators.": "There are no available Epic Collaborators.", diff --git a/metecho/api/models.py b/metecho/api/models.py index 17b30bf32..90c944413 100644 --- a/metecho/api/models.py +++ b/metecho/api/models.py @@ -11,7 +11,7 @@ from django.contrib.auth.models import AbstractUser from django.contrib.auth.models import UserManager as BaseUserManager from django.contrib.sites.models import Site -from django.core.exceptions import ValidationError +from django.core.exceptions import ValidationError, MultipleObjectsReturned from django.core.mail import send_mail from django.core.serializers.json import DjangoJSONEncoder from django.db import models, transaction @@ -240,6 +240,10 @@ def avatar_url(self) -> Optional[str]: return self.github_account.get_avatar_url() except (AttributeError, KeyError, TypeError): return None + # if social app exists in both db and settings retrun sample url + except (MultipleObjectsReturned): + return "https://example.com/avatar/" + @property def org_id(self) -> Optional[str]: @@ -716,8 +720,10 @@ def __str__(self): return self.name def save(self, *args, **kwargs): + if not self.id: + super().save(*args, **kwargs) self.update_status() - return super().save(*args, **kwargs) + return super().save() def subscribable_by(self, user): # pragma: nocover return True diff --git a/metecho/oauth2/adapter.py b/metecho/oauth2/adapter.py index 0c2728772..c492b01c3 100644 --- a/metecho/oauth2/adapter.py +++ b/metecho/oauth2/adapter.py @@ -9,4 +9,4 @@ class CustomSocialAccountAdapter(DefaultSocialAccountAdapter): def authentication_error(self, *args, **kwargs): """Make sure that auth errors get logged""" logger.error(f"Social Account authentication error: {args}, {kwargs}") - return super().authentication_error(*args, **kwargs) + return super().on_authentication_error(*args, **kwargs) diff --git a/metecho/oauth2/github/tests/views.py b/metecho/oauth2/github/tests/views.py index 621d4ce71..9b975f905 100644 --- a/metecho/oauth2/github/tests/views.py +++ b/metecho/oauth2/github/tests/views.py @@ -10,7 +10,7 @@ class TestGitHubOAuth2Adapter: @pytest.mark.django_db def test_complete_login(self, mocker, rf): mocker.patch("metecho.oauth2.github.views.GitHubOAuth2Adapter.complete_login") - token = mock.MagicMock(app=SocialApp(provider="github")) + token = mock.MagicMock() request = rf.get("/") adapter = CustomGitHubOAuth2Adapter(request) adapter.complete_login(request, None, token) diff --git a/metecho/oauth2/github/views.py b/metecho/oauth2/github/views.py index e8a5081c8..dd4f569a6 100644 --- a/metecho/oauth2/github/views.py +++ b/metecho/oauth2/github/views.py @@ -3,7 +3,6 @@ from ..views import ( LoggingOAuth2CallbackView, LoggingOAuth2LoginView, - ensure_socialapp_in_db, ) @@ -11,8 +10,6 @@ class CustomGitHubOAuth2Adapter(GitHubOAuth2Adapter): """GitHub adapter that can handle the app being configured in settings""" def complete_login(self, request, app, token, **kwargs): - # make sure token is attached to a SocialApp in the db - ensure_socialapp_in_db(token) return super().complete_login(request, app, token, **kwargs) diff --git a/metecho/oauth2/salesforce/tests/provider.py b/metecho/oauth2/salesforce/tests/provider.py index 47252ee93..2f92bd5dd 100644 --- a/metecho/oauth2/salesforce/tests/provider.py +++ b/metecho/oauth2/salesforce/tests/provider.py @@ -1,14 +1,24 @@ +import pytest from ..provider import CustomSalesforceProvider -def test_get_auth_params(rf): +@pytest.mark.django_db +def test_get_auth_params(rf, social_app_factory): request = rf.get("/") - result = CustomSalesforceProvider(request).get_auth_params(request, None) + app = social_app_factory( + provider="salesforce", + ) + provider = CustomSalesforceProvider(request, app) + result = provider.get_auth_params(request, None) assert "prompt" in result and result["prompt"] == "login" -def test_extract_uid(rf): +@pytest.mark.django_db +def test_extract_uid(rf, social_app_factory): request = rf.get("/") - provider = CustomSalesforceProvider(request) + app = social_app_factory( + provider="salesforce", + ) + provider = CustomSalesforceProvider(request, app) result = provider.extract_uid({"organization_id": "ORG", "user_id": "USER"}) assert result == "ORG/USER" diff --git a/metecho/oauth2/salesforce/views.py b/metecho/oauth2/salesforce/views.py index fa2c5cd35..9a391854b 100644 --- a/metecho/oauth2/salesforce/views.py +++ b/metecho/oauth2/salesforce/views.py @@ -13,7 +13,6 @@ from ..views import ( LoggingOAuth2CallbackView, LoggingOAuth2LoginView, - ensure_socialapp_in_db, ) logger = logging.getLogger(__name__) @@ -66,8 +65,6 @@ def get_org_details(self, extra_data, token): return resp.json() def complete_login(self, request, app, token, **kwargs): - # make sure token is attached to a SocialApp in the db - ensure_socialapp_in_db(token) token = fernet_decrypt(token.token) headers = {"Authorization": f"Bearer {token}"} diff --git a/metecho/oauth2/tests/adapter.py b/metecho/oauth2/tests/adapter.py index 4e7c35c3a..e32c4cf94 100644 --- a/metecho/oauth2/tests/adapter.py +++ b/metecho/oauth2/tests/adapter.py @@ -3,7 +3,7 @@ def test_authentication_error_logs(mocker): mocker.patch( - "allauth.socialaccount.adapter.DefaultSocialAccountAdapter.authentication_error" + "allauth.socialaccount.adapter.DefaultSocialAccountAdapter.on_authentication_error" ) # noqa error = mocker.patch("metecho.oauth2.adapter.logger.error") adapter = CustomSocialAccountAdapter() diff --git a/metecho/oauth2/views.py b/metecho/oauth2/views.py index 6aaf03949..ada5bfd25 100644 --- a/metecho/oauth2/views.py +++ b/metecho/oauth2/views.py @@ -1,7 +1,5 @@ import logging -from allauth.socialaccount import providers -from allauth.socialaccount.models import SocialApp from allauth.socialaccount.providers.oauth2.views import ( OAuth2CallbackView, OAuth2LoginView, @@ -11,23 +9,6 @@ logger = logging.getLogger(__name__) -def ensure_socialapp_in_db(token): - """Make sure that token is attached to a SocialApp in the db. - - Since we are using SocialApps constructed from settings, - there are none in the db for tokens to be related to - unless we create them here. - """ - if token.app.pk is None: - provider = providers.registry.by_id(token.app.provider) - app, created = SocialApp.objects.get_or_create( - provider=provider.id, - name=provider.name, - client_id="-", - ) - token.app = app - - class LoggingOAuth2LoginView(OAuth2LoginView): def dispatch(self, request, *args, **kwargs): ret = super().dispatch(request, *args, **kwargs) diff --git a/requirements/dev.txt b/requirements/dev.txt index 96cd767cb..c4a976b20 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -4,60 +4,59 @@ # # pip-compile --output-file=requirements/dev.txt requirements/dev.in # -alabaster==0.7.12 +alabaster==0.7.16 # via sphinx -asgiref==3.5.2 +asgiref==3.7.2 # via # -c requirements/prod.txt # daphne # django -asttokens==2.0.5 +asttokens==2.4.1 # via stack-data -attrs==21.4.0 +attrs==23.2.0 # via # -c requirements/prod.txt # automat # flake8-bugbear - # pytest # service-identity # twisted -autobahn==22.6.1 +autobahn==23.6.2 # via # -c requirements/prod.txt # daphne -automat==20.2.0 +automat==22.10.0 # via # -c requirements/prod.txt # twisted -babel==2.10.3 +babel==2.14.0 # via sphinx -backcall==0.2.0 - # via ipython -black==22.6.0 +black==24.1.1 # via -r requirements/dev.in -certifi==2022.12.7 +certifi==2023.7.22 # via # -c requirements/prod.txt # requests -cffi==1.15.1 +cffi==1.16.0 # via # -c requirements/prod.txt # cryptography -charset-normalizer==3.0.1 +charset-normalizer==3.2.0 # via # -c requirements/prod.txt # requests -click==8.1.3 +click==8.1.6 # via # -c requirements/prod.txt # black -constantly==15.1.0 +constantly==23.10.4 # via # -c requirements/prod.txt # twisted -coverage[toml]==6.4.2 - # via pytest-cov -cryptography==39.0.1 +coverage[toml]==7.4.1 + # via + # coverage + # pytest-cov +cryptography==41.0.7 # via # -c requirements/prod.txt # autobahn @@ -69,11 +68,11 @@ daphne==3.0.2 # -r requirements/dev.in decorator==5.1.1 # via ipython -django==4.0.6 +django==4.2.9 # via # -c requirements/prod.txt # django-extensions -django-extensions==3.2.0 +django-extensions==3.2.3 # via -r requirements/dev.in doc8==0.11.2 # via -r requirements/dev.in @@ -84,21 +83,25 @@ docutils==0.16 # myst-parser # restructuredtext-lint # sphinx -executing==0.9.0 +exceptiongroup==1.2.0 + # via + # ipython + # pytest +executing==2.0.1 # via stack-data -factory-boy==3.2.1 +factory-boy==3.3.0 # via # -r requirements/dev.in # pytest-factoryboy -faker==17.0.0 +faker==19.3.0 # via # -c requirements/prod.txt # factory-boy -flake8==4.0.1 +flake8==7.0.0 # via # -r requirements/dev.in # flake8-bugbear -flake8-bugbear==22.7.1 +flake8-bugbear==24.1.17 # via -r requirements/dev.in hyperlink==21.0.0 # via @@ -113,7 +116,7 @@ idna==3.4 # twisted imagesize==1.4.1 # via sphinx -incremental==21.3.0 +incremental==22.10.0 # via # -c requirements/prod.txt # twisted @@ -121,102 +124,94 @@ inflection==0.5.1 # via # -c requirements/prod.txt # pytest-factoryboy -iniconfig==1.1.1 +iniconfig==2.0.0 # via pytest -ipython==8.4.0 +ipython==8.21.0 # via -r requirements/dev.in -isort==5.10.1 +isort==5.13.2 # via -r requirements/dev.in -jedi==0.18.1 +jedi==0.19.1 # via ipython jinja2==3.1.2 # via # -c requirements/prod.txt # myst-parser # sphinx -markdown-it-py==2.1.0 +markdown-it-py==2.2.0 # via # -c requirements/prod.txt # mdit-py-plugins # myst-parser -markupsafe==2.1.2 +markupsafe==2.1.3 # via # -c requirements/prod.txt # jinja2 -matplotlib-inline==0.1.3 +matplotlib-inline==0.1.6 # via ipython -mccabe==0.6.1 +mccabe==0.7.0 # via flake8 -mdit-py-plugins==0.3.0 +mdit-py-plugins==0.3.5 # via myst-parser mdurl==0.1.2 # via # -c requirements/prod.txt # markdown-it-py -mypy-extensions==0.4.3 +mypy-extensions==1.0.0 # via black -myst-parser==0.18.0 +myst-parser==1.0.0 # via -r requirements/dev.in -packaging==21.3 +packaging==23.2 # via - # -c requirements/prod.txt + # black # pytest # pytest-sugar # sphinx parso==0.8.3 # via jedi -pathspec==0.9.0 +pathspec==0.12.1 # via black -pbr==5.9.0 +pbr==6.0.0 # via stevedore -pexpect==4.8.0 +pexpect==4.9.0 # via ipython -pickleshare==0.7.5 - # via ipython -platformdirs==2.5.2 +platformdirs==4.2.0 # via black -pluggy==1.0.0 +pluggy==1.4.0 # via pytest -prompt-toolkit==3.0.30 +prompt-toolkit==3.0.43 # via ipython ptyprocess==0.7.0 # via pexpect pure-eval==0.2.2 # via stack-data -py==1.11.0 - # via pytest -pyasn1==0.4.8 +pyasn1==0.5.1 # via # -c requirements/prod.txt # pyasn1-modules # service-identity -pyasn1-modules==0.2.8 +pyasn1-modules==0.3.0 # via # -c requirements/prod.txt # service-identity -pycodestyle==2.8.0 +pycodestyle==2.11.1 # via flake8 pycparser==2.21 # via # -c requirements/prod.txt # cffi -pyflakes==2.4.0 +pyflakes==3.2.0 # via flake8 -pygments==2.14.0 +pygments==2.17.2 # via # -c requirements/prod.txt # doc8 # ipython # sphinx -pyopenssl==23.0.0 +pyopenssl==24.0.0 # via # -c requirements/prod.txt # twisted -pyparsing==3.0.9 - # via - # -c requirements/prod.txt - # packaging -pytest==7.1.2 +pytest==7.4.4 # via # -r requirements/dev.in # pytest-asyncio @@ -226,41 +221,37 @@ pytest==7.1.2 # pytest-lazy-fixture # pytest-mock # pytest-sugar -pytest-asyncio==0.19.0 +pytest-asyncio==0.23.4 # via -r requirements/dev.in -pytest-cov==3.0.0 +pytest-cov==4.1.0 # via -r requirements/dev.in -pytest-django==4.5.2 +pytest-django==4.8.0 # via -r requirements/dev.in -pytest-factoryboy==2.5.0 +pytest-factoryboy==2.6.0 # via -r requirements/dev.in pytest-lazy-fixture==0.6.3 # via -r requirements/dev.in -pytest-mock==3.8.2 +pytest-mock==3.12.0 # via -r requirements/dev.in -pytest-sugar==0.9.5 +pytest-sugar==1.0.0 # via -r requirements/dev.in python-dateutil==2.8.2 # via # -c requirements/prod.txt # faker -pytz==2022.7.1 - # via - # -c requirements/prod.txt - # babel -pyyaml==6.0 +pyyaml==6.0.1 # via # -c requirements/prod.txt # myst-parser remote-pdb==2.1.0 # via -r requirements/dev.in -requests==2.28.2 +requests==2.29.0 # via # -c requirements/prod.txt # sphinx restructuredtext-lint==1.4.0 # via doc8 -service-identity==21.1.0 +service-identity==24.1.0 # via # -c requirements/prod.txt # twisted @@ -270,69 +261,70 @@ six==1.16.0 # asttokens # automat # python-dateutil - # service-identity # sphinxcontrib-httpdomain snowballstemmer==2.2.0 # via sphinx -sphinx==5.1.0 +sphinx==5.3.0 # via # -r requirements/dev.in # myst-parser # sphinxcontrib-httpdomain -sphinxcontrib-applehelp==1.0.2 +sphinxcontrib-applehelp==1.0.8 # via sphinx -sphinxcontrib-devhelp==1.0.2 +sphinxcontrib-devhelp==1.0.6 # via sphinx -sphinxcontrib-htmlhelp==2.0.0 +sphinxcontrib-htmlhelp==2.0.5 # via sphinx -sphinxcontrib-httpdomain==1.8.0 +sphinxcontrib-httpdomain==1.8.1 # via -r requirements/dev.in sphinxcontrib-jsmath==1.0.1 # via sphinx -sphinxcontrib-qthelp==1.0.3 +sphinxcontrib-qthelp==1.0.7 # via sphinx -sphinxcontrib-serializinghtml==1.1.5 +sphinxcontrib-serializinghtml==1.1.10 # via sphinx -sqlparse==0.4.2 +sqlparse==0.4.4 # via # -c requirements/prod.txt # django -stack-data==0.3.0 +stack-data==0.6.3 # via ipython -stevedore==4.0.0 +stevedore==5.1.0 # via doc8 -termcolor==1.1.0 +termcolor==2.4.0 # via pytest-sugar tomli==2.0.1 # via # black # coverage # pytest -traitlets==5.3.0 +traitlets==5.14.1 # via # ipython # matplotlib-inline -twisted[tls]==22.4.0 +twisted[tls]==23.10.0 # via # -c requirements/prod.txt # daphne -txaio==22.2.1 + # twisted +txaio==23.1.1 # via # -c requirements/prod.txt # autobahn -typing-extensions==4.5.0 +typing-extensions==4.7.1 # via # -c requirements/prod.txt - # myst-parser + # asgiref + # black # pytest-factoryboy # twisted -urllib3==1.26.14 +urllib3==1.26.16 # via # -c requirements/prod.txt # requests -wcwidth==0.2.5 +wcwidth==0.2.13 # via prompt-toolkit -zope-interface==5.4.0 +zope-interface==6.1 # via # -c requirements/prod.txt # twisted diff --git a/requirements/prod.in b/requirements/prod.in index 0346f271a..5041c7573 100644 --- a/requirements/prod.in +++ b/requirements/prod.in @@ -2,12 +2,12 @@ # upgrade-deps.yml workflow. Avoid pinning specific versions here unless required # for stability. -Django +Django<5 autobahn beautifulsoup4 bleach -channels -channels-redis +channels[daphne]<4 +channels-redis<4 cumulusci dj-database-url django-allauth @@ -38,5 +38,5 @@ psycopg2-binary rq-scheduler sentry-sdk service_identity -sfdo-template-helpers @ https://github.com/SFDO-Tooling/sfdo-template-helpers/archive/v0.20.0.tar.gz +sfdo-template-helpers @ https://github.com/SFDO-Tooling/sfdo-template-helpers/archive/v0.23.0.tar.gz whitenoise diff --git a/requirements/prod.txt b/requirements/prod.txt index 03b6830e5..02ad840d6 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -10,79 +10,82 @@ appdirs==1.4.4 # via # cumulusci # fs -asgiref==3.5.2 +asgiref==3.7.2 # via # channels # channels-redis # daphne # django -async-timeout==4.0.2 +async-timeout==4.0.3 # via # aioredis # redis -attrs==21.4.0 +attrs==23.2.0 # via # automat # jsonschema + # referencing # service-identity # twisted -authlib==1.2.0 +authlib==1.2.1 # via # cumulusci # simple-salesforce -autobahn==22.6.1 +autobahn==23.6.2 # via # -r requirements/prod.in # daphne -automat==20.2.0 +automat==22.10.0 # via twisted -beautifulsoup4==4.11.1 +beautifulsoup4==4.12.3 # via -r requirements/prod.in -bleach==5.0.1 +bleach==6.1.0 # via # -r requirements/prod.in # sfdo-template-helpers -certifi==2022.12.7 +certifi==2023.7.22 # via # cumulusci # requests # sentry-sdk # snowfakery -cffi==1.15.1 +cffi==1.16.0 # via # cryptography # cumulusci -channels==3.0.5 +channels[daphne]==3.0.5 # via # -r requirements/prod.in + # channels # channels-redis channels-redis==3.4.1 # via -r requirements/prod.in -charset-normalizer==3.0.1 +charset-normalizer==3.2.0 # via # cumulusci # requests # snowfakery -click==8.1.3 +click==8.1.6 # via # cumulusci # rq # snowfakery -constantly==15.1.0 +constantly==23.10.4 # via twisted -croniter==1.3.5 +crontab==1.0.1 # via rq-scheduler -cryptography==39.0.1 +cryptography==41.0.7 # via # authlib # autobahn # cumulusci + # django-anymail # pyjwt # pyopenssl # secretstorage # service-identity # sfdo-template-helpers -cumulusci==3.76.0 +cumulusci==3.84.1 # via -r requirements/prod.in daphne==3.0.2 # via channels @@ -90,14 +93,13 @@ defusedxml==0.7.1 # via # cumulusci # python3-openid -deprecated==1.2.13 - # via redis -dj-database-url==0.5.0 +dj-database-url==2.1.0 # via -r requirements/prod.in -django==4.0.6 +django==4.2.9 # via # -r requirements/prod.in # channels + # dj-database-url # django-allauth # django-anymail # django-filter @@ -110,51 +112,62 @@ django==4.0.6 # djangorestframework # drf-spectacular # sfdo-template-helpers -django-allauth==0.51.0 +django-allauth==0.60.1 # via -r requirements/prod.in -django-anymail[mailgun]==8.6 +django-anymail[mailgun]==10.2 # via -r requirements/prod.in -django-environ==0.9.0 +django-environ==0.11.2 # via -r requirements/prod.in -django-filter==22.1 +django-filter==23.5 # via sfdo-template-helpers -django-hashid-field==3.3.5 +django-hashid-field==3.4.0 # via -r requirements/prod.in django-js-reverse @ https://github.com/ierror/django-js-reverse/archive/7cab78c4531780ab4b32033d5104ccd5be1a246a.tar.gz # via -r requirements/prod.in -django-log-request-id==2.0.0 +django-log-request-id==2.1.0 # via -r requirements/prod.in -django-model-utils==4.2.0 +django-model-utils==4.3.1 # via -r requirements/prod.in django-parler==2.3 # via -r requirements/prod.in -django-rq==2.5.1 +django-rq==2.10.1 # via -r requirements/prod.in -djangorestframework==3.13.1 +djangorestframework==3.14.0 # via # -r requirements/prod.in # drf-spectacular # sfdo-template-helpers docutils==0.16 # via cumulusci -drf-spectacular==0.22.1 +drf-spectacular==0.27.1 # via -r requirements/prod.in -faker==17.0.0 +faker==19.3.0 + # via + # cumulusci + # faker-edu + # faker-nonprofit + # snowfakery +faker-edu==1.0.0 + # via + # cumulusci + # snowfakery +faker-nonprofit==1.0.0 # via # cumulusci # snowfakery +freezegun==1.4.0 + # via rq-scheduler fs==2.4.16 # via cumulusci furl==2.1.3 # via -r requirements/prod.in -github3-py==3.2.0 +github3-py==4.0.1 # via # -r requirements/prod.in # cumulusci -greenlet==2.0.2 +greenlet==3.0.1 # via # cumulusci - # snowfakery # sqlalchemy gvgen==1.0 # via @@ -162,7 +175,7 @@ gvgen==1.0 # snowfakery hashids==1.3.1 # via django-hashid-field -hiredis==2.0.0 +hiredis==2.3.2 # via aioredis honcho==1.1.0 # via -r requirements/prod.in @@ -177,11 +190,11 @@ idna==3.4 # requests # snowfakery # twisted -importlib-metadata==6.0.0 +importlib-metadata==6.8.0 # via # cumulusci # keyring -incremental==21.3.0 +incremental==22.10.0 # via twisted inflection==0.5.1 # via drf-spectacular @@ -194,25 +207,27 @@ jinja2==3.1.2 # via # cumulusci # snowfakery -jsonschema==4.7.2 +jsonschema==4.21.1 # via drf-spectacular +jsonschema-specifications==2023.12.1 + # via jsonschema keyring==23.0.1 # via cumulusci logfmt==0.4 # via # -r requirements/prod.in # sfdo-template-helpers -lxml==4.9.2 +lxml==4.9.3 # via cumulusci -markdown==3.4.1 +markdown==3.5.2 # via # -r requirements/prod.in # sfdo-template-helpers -markdown-it-py==2.1.0 +markdown-it-py==2.2.0 # via # cumulusci # rich -markupsafe==2.1.2 +markupsafe==2.1.3 # via # cumulusci # jinja2 @@ -221,80 +236,79 @@ mdurl==0.1.2 # via # cumulusci # markdown-it-py -msgpack==1.0.4 +msgpack==1.0.7 # via channels-redis -natsort==8.2.0 +natsort==8.4.0 # via # cumulusci # robotframework-pabot -oauthlib==3.2.0 +oauthlib==3.2.2 # via requests-oauthlib orderedmultidict==1.0.1 # via furl -packaging==21.3 - # via redis -psutil==5.9.4 +psutil==5.9.6 # via cumulusci -psycopg2-binary==2.9.3 +psycopg2-binary==2.9.9 # via -r requirements/prod.in -pyasn1==0.4.8 +pyasn1==0.5.1 # via # pyasn1-modules # service-identity -pyasn1-modules==0.2.8 +pyasn1-modules==0.3.0 # via service-identity pycparser==2.21 # via # cffi # cumulusci -pydantic==1.10.5 +pydantic==1.10.12 # via # cumulusci # snowfakery -pygments==2.14.0 +pygments==2.17.2 # via # cumulusci # rich -pyjwt[crypto]==2.6.0 +pyjwt[crypto]==2.8.0 # via # cumulusci # django-allauth # github3-py -pyopenssl==23.0.0 + # pyjwt +pyopenssl==24.0.0 # via twisted -pyparsing==3.0.9 - # via packaging -pyrsistent==0.18.1 - # via jsonschema python-baseconv==1.2.2 # via # cumulusci # snowfakery python-dateutil==2.8.2 # via - # croniter # cumulusci # faker + # freezegun # github3-py # rq-scheduler # snowfakery python3-openid==3.2.0 # via django-allauth -pytz==2022.7.1 +pytz==2023.3.post1 # via # cumulusci # djangorestframework -pyyaml==6.0 +pyyaml==6.0.1 # via # -r requirements/prod.in # cumulusci # drf-spectacular # snowfakery -redis==4.3.4 +redis==5.0.1 # via # django-rq # rq -requests==2.28.2 +referencing==0.33.0 + # via + # jsonschema + # jsonschema-specifications +requests==2.29.0 # via # cumulusci # django-allauth @@ -306,29 +320,26 @@ requests==2.28.2 # salesforce-bulk # simple-salesforce # snowfakery -requests-futures==1.0.0 +requests-futures==1.0.1 # via cumulusci requests-oauthlib==1.3.1 # via django-allauth -rich==13.3.1 +rich==13.7.0 # via cumulusci -robotframework==6.0.2 +robotframework==6.1.1 # via # cumulusci - # robotframework-lint # robotframework-pabot # robotframework-requests # robotframework-seleniumlibrary # robotframework-stacktrace -robotframework-lint==1.1 +robotframework-pabot==2.16.0 # via cumulusci -robotframework-pabot==2.13.0 - # via cumulusci -robotframework-pythonlibcore==4.1.0 +robotframework-pythonlibcore==4.3.0 # via # cumulusci # robotframework-seleniumlibrary -robotframework-requests==0.9.4 +robotframework-requests==0.9.6 # via cumulusci robotframework-seleniumlibrary==5.1.3 # via cumulusci @@ -336,11 +347,15 @@ robotframework-stacktrace==0.4.1 # via # cumulusci # robotframework-pabot -rq==1.10.1 +rpds-py==0.17.1 + # via + # jsonschema + # referencing +rq==1.15.1 # via # django-rq # rq-scheduler -rq-scheduler==0.11.0 +rq-scheduler==0.13.1 # via -r requirements/prod.in rst2ansi==0.1.5 # via cumulusci @@ -356,13 +371,13 @@ selenium==3.141.0 # via # cumulusci # robotframework-seleniumlibrary -sentry-sdk==1.8.0 +sentry-sdk==1.40.0 # via -r requirements/prod.in -service-identity==21.1.0 +service-identity==24.1.0 # via # -r requirements/prod.in # twisted -sfdo-template-helpers @ https://github.com/SFDO-Tooling/sfdo-template-helpers/archive/v0.20.0.tar.gz +sfdo-template-helpers @ https://github.com/SFDO-Tooling/sfdo-template-helpers/archive/v0.23.0.tar.gz # via -r requirements/prod.in simple-salesforce==1.11.4 # via @@ -378,25 +393,28 @@ six==1.16.0 # orderedmultidict # python-dateutil # salesforce-bulk - # service-identity # snowfakery -snowfakery==3.5.0 +snowfakery==3.6.1 # via cumulusci -soupsieve==2.3.2.post1 +soupsieve==2.5 # via beautifulsoup4 -sqlalchemy==1.4.46 +sqlalchemy==1.4.49 # via # cumulusci # snowfakery -sqlparse==0.4.2 +sqlparse==0.4.4 # via django -twisted[tls]==22.4.0 - # via daphne -txaio==22.2.1 +twisted[tls]==23.10.0 + # via + # daphne + # twisted +txaio==23.1.1 # via autobahn -typing-extensions==4.5.0 +typing-extensions==4.7.1 # via + # asgiref # cumulusci + # dj-database-url # pydantic # snowfakery # twisted @@ -409,26 +427,25 @@ uritemplate==4.1.1 # cumulusci # drf-spectacular # github3-py -urllib3==1.26.14 +urllib3==1.26.16 # via # cumulusci + # django-anymail # requests # selenium # sentry-sdk # snowfakery webencodings==0.5.1 # via bleach -whitenoise==6.2.0 +whitenoise==6.6.0 # via -r requirements/prod.in -wrapt==1.14.1 - # via deprecated xmltodict==0.13.0 # via cumulusci -zipp==3.13.0 +zipp==3.17.0 # via # cumulusci # importlib-metadata -zope-interface==5.4.0 +zope-interface==6.1 # via twisted # The following packages are considered to be unsafe in a requirements file: From 7689ac46e4618b34b83f424906bd34eef9fb7ffc Mon Sep 17 00:00:00 2001 From: Bharath Chadarajupalli Date: Tue, 6 Feb 2024 01:54:30 -0800 Subject: [PATCH 2/5] @W-14870747 - Fixing sorts and black issues --- CONTRIBUTING.md | 3 ++- README.md | 3 ++- metecho/api/gh.py | 2 +- metecho/api/jobs.py | 5 +++-- metecho/api/migrations/0118_project_deleted_at.py | 6 +++--- metecho/api/models.py | 5 ++--- metecho/api/push.py | 1 + metecho/api/tests/serializers.py | 6 +++--- metecho/oauth2/github/tests/views.py | 1 - metecho/oauth2/github/views.py | 5 +---- metecho/oauth2/salesforce/tests/provider.py | 1 + metecho/oauth2/salesforce/views.py | 5 +---- metecho/urls.py | 1 + 13 files changed, 21 insertions(+), 23 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d880a7103..53c328a0a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -56,7 +56,8 @@ Use the "Webhook secret" value as your `GITHUB_HOOK_SECRET` environment variable in Metecho. Use the app's "App ID" as `GITHUB_APP_ID`, "Client ID" as `GITHUB_CLIENT_ID`, -and "Client secret" as `GITHUB_CLIENT_SECRET`. These are stored in a shared lastpass note. +and "Client secret" as `GITHUB_CLIENT_SECRET`. These are stored in a shared +lastpass note. Finally, generate a new private key for the app and set it as the `GITHUB_APP_KEY` environment variable (the entire key, not a path to one). If diff --git a/README.md b/README.md index 5c997fe0e..c6ead5fa0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ ## Development and Deployment -See [documentation](https://metecho.readthedocs.io/en/latest/heroku-setup.html) on how to set up Metecho on Heroku. +See [documentation](https://metecho.readthedocs.io/en/latest/heroku-setup.html) +on how to set up Metecho on Heroku. See [CONTRIBUTING.md](CONTRIBUTING.md). diff --git a/metecho/api/gh.py b/metecho/api/gh.py index f80d7de5d..d401c4d14 100644 --- a/metecho/api/gh.py +++ b/metecho/api/gh.py @@ -9,9 +9,9 @@ import os import pathlib import shutil -from typing import Generator import zipfile from glob import glob +from typing import Generator from cumulusci.utils import temporary_dir from django.conf import settings diff --git a/metecho/api/jobs.py b/metecho/api/jobs.py index a79103d06..40b1243a3 100644 --- a/metecho/api/jobs.py +++ b/metecho/api/jobs.py @@ -273,8 +273,9 @@ def create_repository( else: repo = org.create_repository( - project.repo_name, description=project.description, - private=settings.ENABLE_CREATE_PRIVATE_REPO + project.repo_name, + description=project.description, + private=settings.ENABLE_CREATE_PRIVATE_REPO, ) team.add_repository(repo.full_name, permission="push") project.repo_id = repo.id diff --git a/metecho/api/migrations/0118_project_deleted_at.py b/metecho/api/migrations/0118_project_deleted_at.py index 81ff4e92e..15cac9ae6 100644 --- a/metecho/api/migrations/0118_project_deleted_at.py +++ b/metecho/api/migrations/0118_project_deleted_at.py @@ -6,13 +6,13 @@ class Migration(migrations.Migration): dependencies = [ - ('api', '0117_scratchorg_installed_packages'), + ("api", "0117_scratchorg_installed_packages"), ] operations = [ migrations.AddField( - model_name='project', - name='deleted_at', + model_name="project", + name="deleted_at", field=models.DateTimeField(blank=True, null=True), ), ] diff --git a/metecho/api/models.py b/metecho/api/models.py index 90c944413..5df70fcb1 100644 --- a/metecho/api/models.py +++ b/metecho/api/models.py @@ -11,7 +11,7 @@ from django.contrib.auth.models import AbstractUser from django.contrib.auth.models import UserManager as BaseUserManager from django.contrib.sites.models import Site -from django.core.exceptions import ValidationError, MultipleObjectsReturned +from django.core.exceptions import MultipleObjectsReturned, ValidationError from django.core.mail import send_mail from django.core.serializers.json import DjangoJSONEncoder from django.db import models, transaction @@ -241,10 +241,9 @@ def avatar_url(self) -> Optional[str]: except (AttributeError, KeyError, TypeError): return None # if social app exists in both db and settings retrun sample url - except (MultipleObjectsReturned): + except MultipleObjectsReturned: return "https://example.com/avatar/" - @property def org_id(self) -> Optional[str]: try: diff --git a/metecho/api/push.py b/metecho/api/push.py index ad8c56c05..dccbfe55c 100644 --- a/metecho/api/push.py +++ b/metecho/api/push.py @@ -63,6 +63,7 @@ scratchorg.list SCRATCH_ORG_RECREATE """ + from copy import deepcopy from typing import TYPE_CHECKING, Optional diff --git a/metecho/api/tests/serializers.py b/metecho/api/tests/serializers.py index 5bc874d18..59c7ecbf3 100644 --- a/metecho/api/tests/serializers.py +++ b/metecho/api/tests/serializers.py @@ -880,9 +880,9 @@ def test_assign__scratch_org_transfer( _ = user_factory( socialaccount_set__provider="github", socialaccount_set__uid=GH_WITH_METECHO_ID, - devhub_username=FIRST_DEVHUB_USER - if target_has_same_dev_hub - else SECOND_DEVHUB_USER, + devhub_username=( + FIRST_DEVHUB_USER if target_has_same_dev_hub else SECOND_DEVHUB_USER + ), ) target_gh_with_user = git_hub_user_factory(id=GH_WITH_METECHO_ID) diff --git a/metecho/oauth2/github/tests/views.py b/metecho/oauth2/github/tests/views.py index 9b975f905..14b6636f1 100644 --- a/metecho/oauth2/github/tests/views.py +++ b/metecho/oauth2/github/tests/views.py @@ -1,7 +1,6 @@ from unittest import mock import pytest -from allauth.socialaccount.models import SocialApp from ..views import CustomGitHubOAuth2Adapter diff --git a/metecho/oauth2/github/views.py b/metecho/oauth2/github/views.py index dd4f569a6..b1456fc2b 100644 --- a/metecho/oauth2/github/views.py +++ b/metecho/oauth2/github/views.py @@ -1,9 +1,6 @@ from allauth.socialaccount.providers.github.views import GitHubOAuth2Adapter -from ..views import ( - LoggingOAuth2CallbackView, - LoggingOAuth2LoginView, -) +from ..views import LoggingOAuth2CallbackView, LoggingOAuth2LoginView class CustomGitHubOAuth2Adapter(GitHubOAuth2Adapter): diff --git a/metecho/oauth2/salesforce/tests/provider.py b/metecho/oauth2/salesforce/tests/provider.py index 2f92bd5dd..b1bd65454 100644 --- a/metecho/oauth2/salesforce/tests/provider.py +++ b/metecho/oauth2/salesforce/tests/provider.py @@ -1,4 +1,5 @@ import pytest + from ..provider import CustomSalesforceProvider diff --git a/metecho/oauth2/salesforce/views.py b/metecho/oauth2/salesforce/views.py index 9a391854b..3de1eca39 100644 --- a/metecho/oauth2/salesforce/views.py +++ b/metecho/oauth2/salesforce/views.py @@ -10,10 +10,7 @@ from metecho.api.constants import ORGANIZATION_DETAILS -from ..views import ( - LoggingOAuth2CallbackView, - LoggingOAuth2LoginView, -) +from ..views import LoggingOAuth2CallbackView, LoggingOAuth2LoginView logger = logging.getLogger(__name__) ORGID_RE = re.compile(r"^00D[a-zA-Z0-9]{15}$") diff --git a/metecho/urls.py b/metecho/urls.py index ccea1f15f..e61584c8f 100644 --- a/metecho/urls.py +++ b/metecho/urls.py @@ -13,6 +13,7 @@ 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ + from urllib.parse import urljoin from django.conf import settings From 2c69214f2897f678a5989fb38d514db04fee6f61 Mon Sep 17 00:00:00 2001 From: Bharath Chadarajupalli Date: Tue, 6 Feb 2024 02:11:34 -0800 Subject: [PATCH 3/5] @W-14870747 - Fixing test failures --- metecho/api/tests/templatetags_api_bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metecho/api/tests/templatetags_api_bootstrap.py b/metecho/api/tests/templatetags_api_bootstrap.py index 3b65f1ae2..edd21ae63 100644 --- a/metecho/api/tests/templatetags_api_bootstrap.py +++ b/metecho/api/tests/templatetags_api_bootstrap.py @@ -18,7 +18,7 @@ def test_serialize(user_factory): "id": str(user.id), "username": "template_tags@example.com", "email": "template_tags@example.com", - "avatar_url": None, + "avatar_url": "https://example.com/avatar/", "github_id": user.github_id, "is_staff": False, "valid_token_for": None, From 2a053ec52a88439d5c5a4f1bc88cb65be1e8db46 Mon Sep 17 00:00:00 2001 From: Bharath Chadarajupalli Date: Tue, 20 Feb 2024 13:59:25 -0800 Subject: [PATCH 4/5] @W-15055573 - Dep CCI upgrade to 3.84.2 --- requirements/dev.txt | 5 +---- requirements/prod.txt | 8 ++------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index c4a976b20..402be93eb 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -53,9 +53,7 @@ constantly==23.10.4 # -c requirements/prod.txt # twisted coverage[toml]==7.4.1 - # via - # coverage - # pytest-cov + # via pytest-cov cryptography==41.0.7 # via # -c requirements/prod.txt @@ -306,7 +304,6 @@ twisted[tls]==23.10.0 # via # -c requirements/prod.txt # daphne - # twisted txaio==23.1.1 # via # -c requirements/prod.txt diff --git a/requirements/prod.txt b/requirements/prod.txt index 02ad840d6..b2a42bc39 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -56,7 +56,6 @@ cffi==1.16.0 channels[daphne]==3.0.5 # via # -r requirements/prod.in - # channels # channels-redis channels-redis==3.4.1 # via -r requirements/prod.in @@ -85,7 +84,7 @@ cryptography==41.0.7 # secretstorage # service-identity # sfdo-template-helpers -cumulusci==3.84.1 +cumulusci==3.84.2 # via -r requirements/prod.in daphne==3.0.2 # via channels @@ -273,7 +272,6 @@ pyjwt[crypto]==2.8.0 # cumulusci # django-allauth # github3-py - # pyjwt pyopenssl==24.0.0 # via twisted python-baseconv==1.2.2 @@ -405,9 +403,7 @@ sqlalchemy==1.4.49 sqlparse==0.4.4 # via django twisted[tls]==23.10.0 - # via - # daphne - # twisted + # via daphne txaio==23.1.1 # via autobahn typing-extensions==4.7.1 From 1dca52fcfbe466315eed656fe04ef42d5dbf9a75 Mon Sep 17 00:00:00 2001 From: Bharath Chadarajupalli Date: Tue, 20 Feb 2024 15:39:36 -0800 Subject: [PATCH 5/5] @W-15055573 - Updated depricated authentication_error --- metecho/oauth2/adapter.py | 2 +- metecho/oauth2/tests/adapter.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metecho/oauth2/adapter.py b/metecho/oauth2/adapter.py index c492b01c3..13e346864 100644 --- a/metecho/oauth2/adapter.py +++ b/metecho/oauth2/adapter.py @@ -6,7 +6,7 @@ class CustomSocialAccountAdapter(DefaultSocialAccountAdapter): - def authentication_error(self, *args, **kwargs): + def on_authentication_error(self, *args, **kwargs): """Make sure that auth errors get logged""" logger.error(f"Social Account authentication error: {args}, {kwargs}") return super().on_authentication_error(*args, **kwargs) diff --git a/metecho/oauth2/tests/adapter.py b/metecho/oauth2/tests/adapter.py index e32c4cf94..d31d15a8a 100644 --- a/metecho/oauth2/tests/adapter.py +++ b/metecho/oauth2/tests/adapter.py @@ -7,5 +7,5 @@ def test_authentication_error_logs(mocker): ) # noqa error = mocker.patch("metecho.oauth2.adapter.logger.error") adapter = CustomSocialAccountAdapter() - adapter.authentication_error() + adapter.on_authentication_error() assert error.called