mirror of
https://github.com/suitenumerique/meet.git
synced 2026-09-03 14:17:59 +00:00
♻️(backend) align Application model field with is_active convention
Most models in the project use `is_active` rather than `active`. The Application model was not aligned with this convention. Rename the field and add a migration to standardize the naming. Update related tests accordingly. This change should not introduce breaking changes for external applications.
This commit is contained in:
@@ -23,6 +23,7 @@ and this project adheres to
|
|||||||
- ♿(frontend) improve ui and aria labels for help article links #1108
|
- ♿(frontend) improve ui and aria labels for help article links #1108
|
||||||
- 🌐(frontend) improve German translation #1125
|
- 🌐(frontend) improve German translation #1125
|
||||||
- 🔨(python-env) migrate meet main app to UV #1120
|
- 🔨(python-env) migrate meet main app to UV #1120
|
||||||
|
- ♻️(backend) align Application model field with `is_active` convention
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ class ApplicationJWTAuthentication(BaseJWTAuthentication):
|
|||||||
logger.warning("Application not found: %s", client_id)
|
logger.warning("Application not found: %s", client_id)
|
||||||
raise exceptions.AuthenticationFailed("Application not found.") from e
|
raise exceptions.AuthenticationFailed("Application not found.") from e
|
||||||
|
|
||||||
if not application.active:
|
if not application.is_active:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Inactive application attempted authentication: %s", client_id
|
"Inactive application attempted authentication: %s", client_id
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class ApplicationViewSet(viewsets.ViewSet):
|
|||||||
except models.Application.DoesNotExist as e:
|
except models.Application.DoesNotExist as e:
|
||||||
raise drf_exceptions.AuthenticationFailed("Invalid credentials") from e
|
raise drf_exceptions.AuthenticationFailed("Invalid credentials") from e
|
||||||
|
|
||||||
if not application.active:
|
if not application.is_active:
|
||||||
raise drf_exceptions.AuthenticationFailed("Application is inactive")
|
raise drf_exceptions.AuthenticationFailed("Application is inactive")
|
||||||
|
|
||||||
if not check_password(client_secret, application.client_secret):
|
if not check_password(client_secret, application.client_secret):
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ class ApplicationFactory(factory.django.DjangoModelFactory):
|
|||||||
model = models.Application
|
model = models.Application
|
||||||
|
|
||||||
name = factory.Faker("company")
|
name = factory.Faker("company")
|
||||||
active = True
|
is_active = True
|
||||||
client_id = factory.LazyFunction(utils.generate_client_id)
|
client_id = factory.LazyFunction(utils.generate_client_id)
|
||||||
client_secret = factory.LazyFunction(utils.generate_client_secret)
|
client_secret = factory.LazyFunction(utils.generate_client_secret)
|
||||||
scopes = []
|
scopes = []
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.12 on 2026-03-11 14:39
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0017_file'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='application',
|
||||||
|
old_name='active',
|
||||||
|
new_name='is_active',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -759,7 +759,7 @@ class Application(BaseModel):
|
|||||||
verbose_name=_("Application name"),
|
verbose_name=_("Application name"),
|
||||||
help_text=_("Descriptive name for this application."),
|
help_text=_("Descriptive name for this application."),
|
||||||
)
|
)
|
||||||
active = models.BooleanField(default=True)
|
is_active = models.BooleanField(default=True)
|
||||||
client_id = models.CharField(
|
client_id = models.CharField(
|
||||||
max_length=100, unique=True, default=utils.generate_client_id
|
max_length=100, unique=True, default=utils.generate_client_id
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -904,7 +904,7 @@ def test_api_rooms_token_unknown_application(settings):
|
|||||||
|
|
||||||
def test_api_rooms_token_inactive_application(settings):
|
def test_api_rooms_token_inactive_application(settings):
|
||||||
"""Token for inactive application should be rejected."""
|
"""Token for inactive application should be rejected."""
|
||||||
application = ApplicationFactory(active=False)
|
application = ApplicationFactory(is_active=False)
|
||||||
|
|
||||||
now = datetime.now(timezone.utc)
|
now = datetime.now(timezone.utc)
|
||||||
payload = {
|
payload = {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ def test_api_applications_generate_token_success(settings):
|
|||||||
"""Valid credentials should return a JWT token."""
|
"""Valid credentials should return a JWT token."""
|
||||||
UserFactory(email="User.Family@example.com")
|
UserFactory(email="User.Family@example.com")
|
||||||
application = ApplicationFactory(
|
application = ApplicationFactory(
|
||||||
active=True,
|
is_active=True,
|
||||||
scopes=[ApplicationScope.ROOMS_LIST, ApplicationScope.ROOMS_CREATE],
|
scopes=[ApplicationScope.ROOMS_LIST, ApplicationScope.ROOMS_CREATE],
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ def test_api_applications_generate_token_invalid_client_id():
|
|||||||
def test_api_applications_generate_token_invalid_client_secret():
|
def test_api_applications_generate_token_invalid_client_secret():
|
||||||
"""Invalid client_secret should return 401."""
|
"""Invalid client_secret should return 401."""
|
||||||
user = UserFactory(email="user@example.com")
|
user = UserFactory(email="user@example.com")
|
||||||
application = ApplicationFactory(active=True)
|
application = ApplicationFactory(is_active=True)
|
||||||
|
|
||||||
client = APIClient()
|
client = APIClient()
|
||||||
response = client.post(
|
response = client.post(
|
||||||
@@ -100,7 +100,7 @@ def test_api_applications_generate_token_invalid_client_secret():
|
|||||||
def test_api_applications_generate_token_inactive_application():
|
def test_api_applications_generate_token_inactive_application():
|
||||||
"""Inactive application should return 401."""
|
"""Inactive application should return 401."""
|
||||||
user = UserFactory(email="user@example.com")
|
user = UserFactory(email="user@example.com")
|
||||||
application = ApplicationFactory(active=False)
|
application = ApplicationFactory(is_active=False)
|
||||||
|
|
||||||
plain_secret = "test-secret-123"
|
plain_secret = "test-secret-123"
|
||||||
application.client_secret = plain_secret
|
application.client_secret = plain_secret
|
||||||
@@ -124,7 +124,7 @@ def test_api_applications_generate_token_inactive_application():
|
|||||||
|
|
||||||
def test_api_applications_generate_token_invalid_email_format():
|
def test_api_applications_generate_token_invalid_email_format():
|
||||||
"""Invalid email format should return 400."""
|
"""Invalid email format should return 400."""
|
||||||
application = ApplicationFactory(active=True)
|
application = ApplicationFactory(is_active=True)
|
||||||
|
|
||||||
plain_secret = "test-secret-123"
|
plain_secret = "test-secret-123"
|
||||||
application.client_secret = plain_secret
|
application.client_secret = plain_secret
|
||||||
@@ -149,7 +149,7 @@ def test_api_applications_generate_token_invalid_email_format():
|
|||||||
def test_api_applications_generate_token_domain_not_authorized():
|
def test_api_applications_generate_token_domain_not_authorized():
|
||||||
"""Application without domain authorization should return 403."""
|
"""Application without domain authorization should return 403."""
|
||||||
user = UserFactory(email="user@denied.com")
|
user = UserFactory(email="user@denied.com")
|
||||||
application = ApplicationFactory(active=True)
|
application = ApplicationFactory(is_active=True)
|
||||||
ApplicationDomainFactory(application=application, domain="allowed.com")
|
ApplicationDomainFactory(application=application, domain="allowed.com")
|
||||||
|
|
||||||
plain_secret = "test-secret-123"
|
plain_secret = "test-secret-123"
|
||||||
@@ -176,7 +176,7 @@ def test_api_applications_generate_token_domain_authorized():
|
|||||||
"""Application with domain authorization should succeed."""
|
"""Application with domain authorization should succeed."""
|
||||||
user = UserFactory(email="user@allowed.com")
|
user = UserFactory(email="user@allowed.com")
|
||||||
application = ApplicationFactory(
|
application = ApplicationFactory(
|
||||||
active=True,
|
is_active=True,
|
||||||
scopes=[ApplicationScope.ROOMS_LIST],
|
scopes=[ApplicationScope.ROOMS_LIST],
|
||||||
)
|
)
|
||||||
ApplicationDomainFactory(application=application, domain="allowed.com")
|
ApplicationDomainFactory(application=application, domain="allowed.com")
|
||||||
@@ -203,7 +203,7 @@ def test_api_applications_generate_token_domain_authorized():
|
|||||||
|
|
||||||
def test_api_applications_generate_token_user_not_found():
|
def test_api_applications_generate_token_user_not_found():
|
||||||
"""Non-existent user should return 404."""
|
"""Non-existent user should return 404."""
|
||||||
application = ApplicationFactory(active=True)
|
application = ApplicationFactory(is_active=True)
|
||||||
|
|
||||||
plain_secret = "test-secret-123"
|
plain_secret = "test-secret-123"
|
||||||
application.client_secret = plain_secret
|
application.client_secret = plain_secret
|
||||||
@@ -231,7 +231,7 @@ def test_api_applications_token_payload_structure(settings):
|
|||||||
user = UserFactory(email="user@example.com")
|
user = UserFactory(email="user@example.com")
|
||||||
|
|
||||||
application = ApplicationFactory(
|
application = ApplicationFactory(
|
||||||
active=True,
|
is_active=True,
|
||||||
scopes=[ApplicationScope.ROOMS_LIST, ApplicationScope.ROOMS_CREATE],
|
scopes=[ApplicationScope.ROOMS_LIST, ApplicationScope.ROOMS_CREATE],
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ def test_api_applications_token_new_user(settings):
|
|||||||
assert len(User.objects.all()) == 0
|
assert len(User.objects.all()) == 0
|
||||||
|
|
||||||
application = ApplicationFactory(
|
application = ApplicationFactory(
|
||||||
active=True,
|
is_active=True,
|
||||||
scopes=[ApplicationScope.ROOMS_LIST, ApplicationScope.ROOMS_CREATE],
|
scopes=[ApplicationScope.ROOMS_LIST, ApplicationScope.ROOMS_CREATE],
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ def test_api_applications_token_existing_user(settings):
|
|||||||
assert len(User.objects.all()) == 1
|
assert len(User.objects.all()) == 1
|
||||||
|
|
||||||
application = ApplicationFactory(
|
application = ApplicationFactory(
|
||||||
active=True,
|
is_active=True,
|
||||||
scopes=[ApplicationScope.ROOMS_LIST, ApplicationScope.ROOMS_CREATE],
|
scopes=[ApplicationScope.ROOMS_LIST, ApplicationScope.ROOMS_CREATE],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ def test_models_application_name_maxlength():
|
|||||||
def test_models_application_active_default():
|
def test_models_application_active_default():
|
||||||
"""An application should be active by default."""
|
"""An application should be active by default."""
|
||||||
application = Application.objects.create(name="Test App")
|
application = Application.objects.create(name="Test App")
|
||||||
assert application.active is True
|
assert application.is_active is True
|
||||||
|
|
||||||
|
|
||||||
def test_models_application_scopes_default():
|
def test_models_application_scopes_default():
|
||||||
|
|||||||
Reference in New Issue
Block a user