Skip to content

Commit

Permalink
Generate python package upgrade (#1223)
Browse files Browse the repository at this point in the history
* DPAT-0000 generate package upgrade

* DPAT-0000 upgrade auth0

* DPAT-0000 try fix the failed tests

* DPAT-0000 fix the error of missing param when getting auth0 token
  • Loading branch information
ymao2 authored Nov 10, 2023
1 parent 04891c9 commit f3582ee
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 26 deletions.
26 changes: 14 additions & 12 deletions controlpanel/api/auth0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# Third-party
import structlog
import yaml
from auth0.v3 import authentication, exceptions
from auth0.v3.management import Auth0
from auth0.v3.management.clients import Clients
from auth0.v3.management.connections import Connections
from auth0.v3.management.device_credentials import DeviceCredentials
from auth0.v3.management.rest import RestClient
from auth0.v3.management.users import Users
from auth0 import authentication, exceptions
from auth0.management import Auth0
from auth0.management.clients import Clients
from auth0.management.connections import Connections
from auth0.management.device_credentials import DeviceCredentials
from auth0.rest import RestClient
from auth0.management.users import Users
from django.conf import settings
from jinja2 import Environment
from rest_framework.exceptions import APIException
Expand All @@ -27,7 +27,7 @@
# This is the maximum they'll allow for group/members API
PER_PAGE_FOR_GROUP_MEMBERS = 25

# The default value for timeout in auth0.v3.management is 5 seconds which will
# The default value for timeout in auth0.management is 5 seconds which will
# get ReadTimeOut error quite easily on Auth0 dev tenant when Control panel
# initialises the connection with it. In order to avoid this, a longer timeout
# is defined below as the default value for this app. This value will be passed
Expand Down Expand Up @@ -104,11 +104,13 @@ def _init_authorization_extension_apis(self):
)

def _access_token(self, audience):
get_token = authentication.GetToken(self.domain)
get_token = authentication.GetToken(
self.domain,
client_id=self.client_id,
client_secret=self.client_secret
)
try:
token = get_token.client_credentials(
self.client_id, self.client_secret, audience
)
token = get_token.client_credentials(audience)
except exceptions.Auth0Error as error:
error_detail = (
f"Access token error: {self.client_id}, {self.domain}, {error}"
Expand Down
2 changes: 1 addition & 1 deletion controlpanel/api/models/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import uuid

# Third-party
from auth0.v3.exceptions import Auth0Error
from auth0.exceptions import Auth0Error
from django.conf import settings
from django.db import models
from django_extensions.db.fields import AutoSlugField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime

# Third-party
from auth0.v3.exceptions import Auth0Error
from auth0.exceptions import Auth0Error
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings

Expand Down
2 changes: 1 addition & 1 deletion controlpanel/cli/management/commands/export_auth0_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from time import time

from controlpanel.api import auth0
from auth0.v3.management.logs import Logs
from auth0.management.logs import Logs


class Command(BaseCommand):
Expand Down
2 changes: 1 addition & 1 deletion controlpanel/frontend/views/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from django.views.generic.edit import CreateView, DeleteView, FormMixin, UpdateView
from django.views.generic.list import ListView
from rules.contrib.views import PermissionRequiredMixin
from auth0.v3.management.rest import Auth0Error
from auth0.rest import Auth0Error

# First-party/Local
from controlpanel.api import auth0, cluster
Expand Down
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
asgiref==3.6.0
auth0-python==3.13.0
auth0-python==4.5.0
beautifulsoup4==4.12.2
boto3==1.26.143
celery[sqs]==5.3.1
channels==4.0.0
channels-redis==4.0.0
daphne==4.0.0
Django==4.2.1
Django==4.2.7
django-crequest==2018.5.11
django-extensions==3.2.1
django-extensions==3.2.3
django-filter==22.1
django-prometheus==2.1.0
django-redis==5.3.0
django-redis==5.4.0
django-simple-history==3.3.0
django-structlog==2.2.0
djangorestframework==3.14.0
Expand All @@ -33,6 +33,6 @@ python-jose==3.3.0
pyyaml==6.0
rules==3.3
sentry-sdk==1.14.0
slackclient==2.8.1
urllib3==1.26.16
slackclient==2.9.4
urllib3==1.26.18
uvicorn[standard]==0.20.0
4 changes: 2 additions & 2 deletions tests/api/test_auth0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import mock
import pytest
from django.conf import settings
from auth0.v3 import exceptions
from auth0 import exceptions

# First-party/Local
from controlpanel.api import auth0
Expand All @@ -15,7 +15,7 @@
@pytest.fixture()
def ExtendedAuth0():
with patch(
"auth0.v3.authentication.GetToken.client_credentials"
"auth0.authentication.GetToken.client_credentials"
) as client_credentials:
client_credentials.return_value = {"access_token": "access_token_testing"}
yield auth0.ExtendedAuth0()
Expand Down
2 changes: 1 addition & 1 deletion tests/api/views/test_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from unittest.mock import patch

# Third-party
from auth0.v3.management.rest import Auth0Error
from auth0.rest import Auth0Error
from bs4 import BeautifulSoup
from model_mommy import mommy
import pytest
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@pytest.fixture()
def ExtendedAuth0():
with patch(
"auth0.v3.authentication.GetToken.client_credentials"
"auth0.authentication.GetToken.client_credentials"
) as client_credentials:
client_credentials.return_value = {"access_token": "access_token_testing"}
yield auth0.ExtendedAuth0()
Expand Down

0 comments on commit f3582ee

Please sign in to comment.