Skip to content

Commit

Permalink
Update allauth (#11327)
Browse files Browse the repository at this point in the history
* Update allauth

* Delete more stuff

* More template changes

* Disable rate limits in tests

* Revert

* Use newer version

* Install sphinx testing dependencies

* Fix tests
  • Loading branch information
stsewd committed May 22, 2024
1 parent 5ff3d10 commit 411e177
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 60 deletions.
20 changes: 10 additions & 10 deletions readthedocs/oauth/services/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class GitLabService(Service):
# Just use the network location to determine if it's a GitLab project
# because private repos have another base url, eg. git@gitlab.example.com
url_pattern = re.compile(
re.escape(urlparse(adapter.provider_base_url).netloc),
re.escape(urlparse(adapter.provider_default_url).netloc),
)

PERMISSION_NO_ACCESS = 0
Expand Down Expand Up @@ -73,7 +73,7 @@ def sync_repositories(self):
remote_repositories = []
try:
repos = self.paginate(
"{url}/api/v4/projects".format(url=self.adapter.provider_base_url),
"{url}/api/v4/projects".format(url=self.adapter.provider_default_url),
per_page=100,
archived=False,
order_by="path",
Expand All @@ -100,7 +100,7 @@ def sync_organizations(self):

try:
orgs = self.paginate(
"{url}/api/v4/groups".format(url=self.adapter.provider_base_url),
"{url}/api/v4/groups".format(url=self.adapter.provider_default_url),
per_page=100,
all_available=False,
order_by="path",
Expand All @@ -110,7 +110,7 @@ def sync_organizations(self):
remote_organization = self.create_organization(org)
org_repos = self.paginate(
"{url}/api/v4/groups/{id}/projects".format(
url=self.adapter.provider_base_url,
url=self.adapter.provider_default_url,
id=org["id"],
),
per_page=100,
Expand All @@ -131,7 +131,7 @@ def sync_organizations(self):
# which contains the admin permission fields.
resp = self.get_session().get(
"{url}/api/v4/projects/{id}".format(
url=self.adapter.provider_base_url, id=repo["id"]
url=self.adapter.provider_default_url, id=repo["id"]
)
)

Expand Down Expand Up @@ -270,7 +270,7 @@ def create_organization(self, fields):
organization.name = fields.get("name")
organization.slug = fields.get("path")
organization.url = "{url}/{path}".format(
url=self.adapter.provider_base_url,
url=self.adapter.provider_default_url,
path=fields.get("path"),
)
organization.avatar_url = fields.get("avatar_url")
Expand Down Expand Up @@ -336,7 +336,7 @@ def get_provider_data(self, project, integration):
try:
resp = session.get(
"{url}/api/v4/projects/{repo_id}/hooks".format(
url=self.adapter.provider_base_url,
url=self.adapter.provider_default_url,
repo_id=repo_id,
),
)
Expand Down Expand Up @@ -383,7 +383,7 @@ def setup_webhook(self, project, integration=None):
)

repo_id = self._get_repo_id(project)
url = f"{self.adapter.provider_base_url}/api/v4/projects/{repo_id}/hooks"
url = f"{self.adapter.provider_default_url}/api/v4/projects/{repo_id}/hooks"

if repo_id is None:
return (False, resp)
Expand Down Expand Up @@ -462,7 +462,7 @@ def update_webhook(self, project, integration):
hook_id = provider_data.get("id")
resp = session.put(
"{url}/api/v4/projects/{repo_id}/hooks/{hook_id}".format(
url=self.adapter.provider_base_url,
url=self.adapter.provider_default_url,
repo_id=repo_id,
hook_id=hook_id,
),
Expand Down Expand Up @@ -537,7 +537,7 @@ def send_build_status(self, build, commit, status):
"description": description,
"context": context,
}
url = f"{self.adapter.provider_base_url}/api/v4/projects/{repo_id}/statuses/{commit}"
url = f"{self.adapter.provider_default_url}/api/v4/projects/{repo_id}/statuses/{commit}"

log.bind(
project_slug=project.slug,
Expand Down
4 changes: 2 additions & 2 deletions readthedocs/rtd_tests/tests/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_send_build_status_no_remote_repo_or_social_account_github(
notification.format_values,
{
"provider_name": "GitHub",
"url_connect_account": "/accounts/social/connections/",
"url_connect_account": "/accounts/3rdparty/",
},
)

Expand Down Expand Up @@ -222,6 +222,6 @@ def test_send_build_status_no_remote_repo_or_social_account_gitlab(
notification.format_values,
{
"provider_name": "GitLab",
"url_connect_account": "/accounts/social/connections/",
"url_connect_account": "/accounts/3rdparty/",
},
)
7 changes: 0 additions & 7 deletions readthedocs/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ def INSTALLED_APPS(self): # noqa
"allauth.socialaccount",
"allauth.socialaccount.providers.github",
"allauth.socialaccount.providers.gitlab",
"allauth.socialaccount.providers.bitbucket",
"allauth.socialaccount.providers.bitbucket_oauth2",
"cacheops",
]
Expand Down Expand Up @@ -698,12 +697,6 @@ def DOCKER_LIMITS(self):
],
# Bitbucket scope/permissions are determined by the Oauth consumer setup on bitbucket.org.
},
# Deprecated, we use `bitbucket_oauth2` for all new connections.
"bitbucket": {
"APPS": [
{"client_id": "123", "secret": "456", "key": ""},
],
},
}

@property
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/templates/account/login.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "account/base.html" %}
{% extends "account/base_entrance.html" %}

{% load i18n %}
{% load account %}
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/templates/account/signup.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "account/base.html" %}
{% extends "account/base_entrance.html" %}

{% load i18n %}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "socialaccount/base.html" %}
{% extends "socialaccount/base_entrance.html" %}

{% load i18n %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
{% for provider in socialaccount_providers %}
{% comment %}
- OpenID is not implemented.
- Bitbucket is deprecated (in favor of their new oauth implementation).
- SAML is handled in another view, we don't want to list all SAML integrations here.
{% endcomment %}
{% if provider.id != 'bitbucket' and provider.id != 'saml' %}
{% if provider.id != 'saml' %}
{% if allowed_providers and provider.id in allowed_providers or not allowed_providers %}
<li>
<form action="{% provider_login_url provider.id process=process scope=scope auth_params=auth_params next=next %}" method="post">
Expand Down
10 changes: 1 addition & 9 deletions requirements/deploy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ cssselect==1.2.0
# pyquery
decorator==5.1.1
# via ipython
defusedxml==0.7.1
# via
# -r requirements/pip.txt
# python3-openid
distlib==0.3.8
# via
# -r requirements/pip.txt
Expand Down Expand Up @@ -124,7 +120,7 @@ django==4.2.13
# django-timezone-field
# djangorestframework
# jsonfield
django-allauth[saml]==0.57.2
django-allauth[saml,socialaccount]==0.63.1
# via -r requirements/pip.txt
django-annoying==0.10.6
# via -r requirements/pip.txt
Expand Down Expand Up @@ -320,10 +316,6 @@ python-dateutil==2.9.0.post0
# botocore
# elasticsearch-dsl
# python-crontab
python3-openid==3.2.0
# via
# -r requirements/pip.txt
# django-allauth
python3-saml==1.16.0
# via
# -r requirements/pip.txt
Expand Down
10 changes: 1 addition & 9 deletions requirements/docker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ decorator==5.1.1
# via
# ipdb
# ipython
defusedxml==0.7.1
# via
# -r requirements/pip.txt
# python3-openid
distlib==0.3.8
# via
# -r requirements/pip.txt
Expand Down Expand Up @@ -134,7 +130,7 @@ django==4.2.13
# django-timezone-field
# djangorestframework
# jsonfield
django-allauth[saml]==0.57.2
django-allauth[saml,socialaccount]==0.63.1
# via -r requirements/pip.txt
django-annoying==0.10.6
# via -r requirements/pip.txt
Expand Down Expand Up @@ -352,10 +348,6 @@ python-dateutil==2.9.0.post0
# botocore
# elasticsearch-dsl
# python-crontab
python3-openid==3.2.0
# via
# -r requirements/pip.txt
# django-allauth
python3-saml==1.16.0
# via
# -r requirements/pip.txt
Expand Down
4 changes: 1 addition & 3 deletions requirements/pip.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ django-celery-beat
# TODO: remove this dependency once we upgrade Celery. It should auto-install it.
tzdata

# 0.58.0 refactored the built-in templates,
# we need to check if we need to update our custom templates.
django-allauth[saml]==0.57.2
django-allauth[socialaccount,saml]==0.63.1

requests-oauthlib

Expand Down
6 changes: 1 addition & 5 deletions requirements/pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ cryptography==42.0.7
# via pyjwt
cssselect==1.2.0
# via pyquery
defusedxml==0.7.1
# via python3-openid
distlib==0.3.8
# via virtualenv
dj-pagination==2.5.0
Expand Down Expand Up @@ -85,7 +83,7 @@ django==4.2.13
# django-timezone-field
# djangorestframework
# jsonfield
django-allauth[saml]==0.57.2
django-allauth[saml,socialaccount]==0.63.1
# via -r requirements/pip.in
django-annoying==0.10.6
# via -r requirements/pip.in
Expand Down Expand Up @@ -226,8 +224,6 @@ python-dateutil==2.9.0.post0
# botocore
# elasticsearch-dsl
# python-crontab
python3-openid==3.2.0
# via django-allauth
python3-saml==1.16.0
# via django-allauth
pytz==2024.1
Expand Down
2 changes: 1 addition & 1 deletion requirements/testing.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

-r pip.txt

sphinx
sphinx[test]
django-dynamic-fixture
pytest
pytest-custom-exit-code
Expand Down
18 changes: 9 additions & 9 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ cssselect==1.2.0
# via
# -r requirements/pip.txt
# pyquery
cython==3.0.10
# via sphinx
defusedxml==0.7.1
# via
# -r requirements/pip.txt
# python3-openid
# via sphinx
distlib==0.3.8
# via
# -r requirements/pip.txt
Expand Down Expand Up @@ -125,7 +125,7 @@ django==4.2.13
# django-timezone-field
# djangorestframework
# jsonfield
django-allauth[saml]==0.57.2
django-allauth[saml,socialaccount]==0.63.1
# via -r requirements/pip.txt
django-annoying==0.10.6
# via -r requirements/pip.txt
Expand Down Expand Up @@ -317,6 +317,7 @@ pytest==8.2.0
# pytest-custom-exit-code
# pytest-django
# pytest-mock
# sphinx
pytest-cov==5.0.0
# via -r requirements/testing.in
pytest-custom-exit-code==0.3.0
Expand All @@ -335,10 +336,6 @@ python-dateutil==2.9.0.post0
# botocore
# elasticsearch-dsl
# python-crontab
python3-openid==3.2.0
# via
# -r requirements/pip.txt
# django-allauth
python3-saml==1.16.0
# via
# -r requirements/pip.txt
Expand Down Expand Up @@ -396,7 +393,7 @@ slumber==0.7.1
# via -r requirements/pip.txt
snowballstemmer==2.2.0
# via sphinx
sphinx==7.3.7
sphinx[test]==7.3.7
# via -r requirements/testing.in
sphinxcontrib-applehelp==1.0.8
# via sphinx
Expand Down Expand Up @@ -483,3 +480,6 @@ xmlsec==1.3.14
# python3-saml
yamale==2.2.0
# via -r requirements/testing.in

# The following packages are considered to be unsafe in a requirements file:
# setuptools

0 comments on commit 411e177

Please sign in to comment.