Skip to content

Commit

Permalink
Merge pull request #3 from eva-tech/feat/EVA-5783/update-dependencies
Browse files Browse the repository at this point in the history
[Feat][EVA-5783] - update dependencies
  • Loading branch information
sergs2003 authored Jul 26, 2024
2 parents a649f66 + cee215e commit 8e218af
Show file tree
Hide file tree
Showing 18 changed files with 112 additions and 86 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ __pycache__
/.coverage
/.pytest_cache
/.tox
/.idea

/build
/coverage.xml
Expand All @@ -28,4 +29,5 @@ __pycache__
/site

.venv/
venv/
.python-version
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ install-local:
python setup.py sdist bdist_wheel
python -m pip install dist/django-graphql-auth-${v}.tar.gz

p ?= 38
d ?= 30
python ?= 38
django ?= 3

test:
tox -e py${p}-django${d} -- --cov-report term-missing --cov-report html
tox -e py${python}-django${django} -- --cov-report term-missing --cov-report html

test-file:
tox -e py${p}-django${d} -- tests/test_${f}.py --cov-report html --cov-append
tox -e py${python}-django${django} -- tests/test_${f}.py --cov-report html --cov-append

serve:
python docs/pre_build.py
Expand Down
4 changes: 1 addition & 3 deletions graphql_auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
__version__ = "0.3.16"

default_app_config = "graphql_auth.apps.GraphQLAuthConfig"
__version__ = "0.4.0"
59 changes: 53 additions & 6 deletions graphql_auth/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def resolve_mutation(cls, root, info, **kwargs):
return cls(success=False, errors=Messages.EXPIRED_TOKEN)
except (BadSignature, TokenScopeError):
return cls(success=False, errors=Messages.INVALID_TOKEN)
except (PasswordAlreadySetError):
except PasswordAlreadySetError:
return cls(success=False, errors=Messages.PASSWORD_ALREADY_SET)


Expand Down Expand Up @@ -429,9 +429,16 @@ def resolve_mutation(cls, root, info, **kwargs):
raise UserNotVerified
raise InvalidCredentials
except (JSONWebTokenError, ObjectDoesNotExist, InvalidCredentials):
return cls(success=False, errors=Messages.INVALID_CREDENTIALS)
return cls(
success=False,
errors=Messages.INVALID_CREDENTIALS,
token="",
refresh_token="",
)
except UserNotVerified:
return cls(success=False, errors=Messages.NOT_VERIFIED)
return cls(
success=False, errors=Messages.NOT_VERIFIED, token="", refresh_token=""
)


class ArchiveOrDeleteMixin(Output):
Expand Down Expand Up @@ -547,7 +554,7 @@ def resolve_mutation(cls, root, info, **kwargs):
return cls(success=False, errors=f.errors.get_json_data())


class VerifyOrRefreshOrRevokeTokenMixin(Output):
class VerifyTokenMixin(Output):
"""
Same as `grapgql_jwt` implementation, with standard output.
"""
Expand All @@ -557,9 +564,49 @@ def resolve_mutation(cls, root, info, **kwargs):
try:
return cls.parent_resolve(root, info, **kwargs)
except JSONWebTokenExpired:
return cls(success=False, errors=Messages.EXPIRED_TOKEN)
return cls(success=False, errors=Messages.EXPIRED_TOKEN, payload="")
except JSONWebTokenError:
return cls(success=False, errors=Messages.INVALID_TOKEN)
return cls(success=False, errors=Messages.INVALID_TOKEN, payload="")


class RevokeTokenMixin(Output):
"""
Same as `grapgql_jwt` implementation, with standard output.
"""

@classmethod
def resolve_mutation(cls, root, info, **kwargs):
try:
return cls.parent_resolve(root, info, **kwargs)
except JSONWebTokenExpired:
return cls(success=False, errors=Messages.EXPIRED_TOKEN, revoked=0)
except JSONWebTokenError:
return cls(success=False, errors=Messages.INVALID_TOKEN, revoked=0)


class RefreshTokenMixin(Output):
"""
Same as `grapgql_jwt` implementation, with standard output.
"""

@classmethod
def resolve_mutation(cls, root, info, **kwargs):
try:
return cls.parent_resolve(root, info, **kwargs)
except JSONWebTokenExpired:
return cls(
success=False,
errors=Messages.EXPIRED_TOKEN,
payload="",
refresh_token="",
)
except JSONWebTokenError:
return cls(
success=False,
errors=Messages.INVALID_TOKEN,
payload="",
refresh_token="",
)


class SendSecondaryEmailActivationMixin(Output):
Expand Down
18 changes: 9 additions & 9 deletions graphql_auth/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
DeleteAccountMixin,
PasswordChangeMixin,
UpdateAccountMixin,
VerifyOrRefreshOrRevokeTokenMixin,
SendSecondaryEmailActivationMixin,
VerifySecondaryEmailMixin,
SwapEmailsMixin,
RemoveSecondaryEmailMixin,
VerifyTokenMixin,
RevokeTokenMixin,
RefreshTokenMixin,
)
from .utils import normalize_fields
from .settings import graphql_auth_settings as app_settings
Expand Down Expand Up @@ -145,15 +147,13 @@ class UpdateAccount(
_args = app_settings.UPDATE_MUTATION_FIELDS


class VerifyToken(MutationMixin, VerifyOrRefreshOrRevokeTokenMixin, graphql_jwt.Verify):
__doc__ = VerifyOrRefreshOrRevokeTokenMixin.__doc__
class VerifyToken(MutationMixin, VerifyTokenMixin, graphql_jwt.Verify):
__doc__ = VerifyTokenMixin.__doc__


class RefreshToken(
MutationMixin, VerifyOrRefreshOrRevokeTokenMixin, graphql_jwt.Refresh
):
__doc__ = VerifyOrRefreshOrRevokeTokenMixin.__doc__
class RefreshToken(MutationMixin, RefreshTokenMixin, graphql_jwt.Refresh):
__doc__ = RefreshTokenMixin.__doc__


class RevokeToken(MutationMixin, VerifyOrRefreshOrRevokeTokenMixin, graphql_jwt.Revoke):
__doc__ = VerifyOrRefreshOrRevokeTokenMixin.__doc__
class RevokeToken(MutationMixin, RevokeTokenMixin, graphql_jwt.Revoke):
__doc__ = RevokeTokenMixin.__doc__
22 changes: 9 additions & 13 deletions graphql_auth/relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
DeleteAccountMixin,
PasswordChangeMixin,
UpdateAccountMixin,
VerifyOrRefreshOrRevokeTokenMixin,
SendSecondaryEmailActivationMixin,
VerifySecondaryEmailMixin,
SwapEmailsMixin,
RemoveSecondaryEmailMixin,
VerifyTokenMixin,
RevokeTokenMixin,
RefreshTokenMixin,
)
from .utils import normalize_fields
from .settings import graphql_auth_settings as app_settings
Expand Down Expand Up @@ -174,28 +176,22 @@ class UpdateAccount(
_inputs = app_settings.UPDATE_MUTATION_FIELDS


class VerifyToken(
RelayMutationMixin, VerifyOrRefreshOrRevokeTokenMixin, graphql_jwt.relay.Verify
):
__doc__ = VerifyOrRefreshOrRevokeTokenMixin.__doc__
class VerifyToken(RelayMutationMixin, VerifyTokenMixin, graphql_jwt.relay.Verify):
__doc__ = VerifyTokenMixin.__doc__

class Input:
token = graphene.String(required=True)


class RefreshToken(
RelayMutationMixin, VerifyOrRefreshOrRevokeTokenMixin, graphql_jwt.relay.Refresh
):
__doc__ = VerifyOrRefreshOrRevokeTokenMixin.__doc__
class RefreshToken(RelayMutationMixin, RefreshTokenMixin, graphql_jwt.relay.Refresh):
__doc__ = RefreshTokenMixin.__doc__

class Input(graphql_jwt.mixins.RefreshMixin.Fields):
"""Refresh Input"""


class RevokeToken(
RelayMutationMixin, VerifyOrRefreshOrRevokeTokenMixin, graphql_jwt.relay.Revoke
):
__doc__ = VerifyOrRefreshOrRevokeTokenMixin.__doc__
class RevokeToken(RelayMutationMixin, RevokeTokenMixin, graphql_jwt.relay.Revoke):
__doc__ = RevokeTokenMixin.__doc__

class Input:
refresh_token = graphene.String(required=True)
2 changes: 0 additions & 2 deletions graphql_auth/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import warnings
from django.core import signing
from django.contrib.auth import get_user_model
from django.conf import settings as django_settings
from django.core.signing import BadSignature

from .exceptions import TokenScopeError

Expand Down
13 changes: 6 additions & 7 deletions quickstart/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
aniso8601==7.0.0
asgiref==3.2.3
Django==3.1.14
django-filter==2.2.0
django-graphql-auth==0.3.10
django-graphql-jwt==0.3.0
graphene==2.1.8
graphene-django==2.8.0
Django==3.2.25
django-filter==2.4.0
django-graphql-auth==0.3.16
django-graphql-jwt==0.4.0
graphene==2.1.9
graphene-django==2.15.0
graphql-core==2.3.1
graphql-relay==2.0.1
promise==2.3
PyJWT==1.7.1
pytz==2019.3
Rx==1.6.1
singledispatch==3.4.0.3
Expand Down
10 changes: 8 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ test=pytest
[bdist_wheel]
universal=1

[tool:pytest]
# to find the "tests" module
pythonpath=.

[coverage:run]
omit = */tests/*

Expand All @@ -18,5 +22,7 @@ line_length=88
[flake8]
exclude = setup.py,docs/*,testproject/*,tests,quickstart/
max-line-length = 88
extend-ignore = E203
ignore = apps.py F401, utils.py W503
ignore = E203
per-file-ignores =
apps.py: F401
utils.py: W503
24 changes: 10 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ def get_version(package):


tests_require = [
"pytest>=3.6.3",
"pytest-cov>=2.4.0",
"pytest-django>=3.1.2",
"pytest>=8.3.1",
"pytest-cov>=5.0.0",
"pytest-django>=4.8.0",
"coveralls",
]

dev_requires = ["black==19.3b0", "flake8==3.7.7"] + tests_require
dev_requires = ["black==24.4.2", "flake8==7.1.0"] + tests_require

setup(
name="django-graphql-auth",
Expand All @@ -42,12 +42,11 @@ def get_version(package):
),
packages=find_packages(exclude=["tests*"]),
install_requires=[
"Django>=2.2.0",
"django-graphql-jwt==0.3.0",
"django-filter>=2.2.0",
"graphene_django>=2.1.8",
"graphene>=2.1.8",
"PyJWT==2.0.0",
"Django>=3,<4",
"django-filter>=2.4.0",
"django-graphql-jwt>=0.3.1",
"graphene_django>=2.15.0,<3",
"graphene>=2.1.9,<3",
],
tests_require=tests_require,
classifiers=[
Expand All @@ -57,12 +56,9 @@ def get_version(package):
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Framework :: Django",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.0",
"Framework :: Django :: 3.2",
],
keywords="api graphql rest relay graphene auth",
zip_safe=False,
Expand Down
1 change: 1 addition & 0 deletions testproject/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import path
from django.views.decorators.csrf import csrf_exempt
Expand Down
1 change: 0 additions & 1 deletion tests/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.contrib.auth.models import AbstractUser
from django.db import models


class CustomUser(AbstractUser):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_archive_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setUp(self):

def test_not_authenticated(self):
"""
try to archive not authenticated
try to archive not authenticated
"""
query = self.make_query()
executed = self.make_request(query)
Expand All @@ -24,7 +24,7 @@ def test_not_authenticated(self):

def test_invalid_password(self):
"""
try to archive account with invalid password
try to archive account with invalid password
"""
query = self.make_query(password="123")
variables = {"user": self.user2}
Expand All @@ -34,7 +34,7 @@ def test_invalid_password(self):

def test_valid_password(self):
"""
try to archive account
try to archive account
"""
query = self.make_query()
variables = {"user": self.user2}
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_revoke_refresh_tokens_on_archive_account(self):

def test_not_verified_user(self):
"""
try to archive account
try to archive account
"""
query = self.make_query()
variables = {"user": self.user1}
Expand Down
4 changes: 1 addition & 3 deletions tests/test_delete_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from django.conf import settings

from .testCases import RelayTestCase, DefaultTestCase
from .decorators import skipif_django_21

from graphql_auth.constants import Messages
from graphql_auth.models import UserStatus
Expand All @@ -21,7 +20,7 @@ def setUp(self):

def test_not_authenticated(self):
"""
try to archive not authenticated
try to archive not authenticated
"""
query = self.make_query()
executed = self.make_request(query)
Expand Down Expand Up @@ -77,7 +76,6 @@ def test_valid_password(self):
self.assertEqual(self.user2.is_active, False)

@mark.settings_b
@skipif_django_21()
def test_valid_password_permanently_delete(self):
query = self.make_query()
variables = {"user": self.user2}
Expand Down
Loading

0 comments on commit 8e218af

Please sign in to comment.