diff --git a/authentik/__init__.py b/authentik/__init__.py index a9e445136..7838c3acf 100644 --- a/authentik/__init__.py +++ b/authentik/__init__.py @@ -9,9 +9,7 @@ ENV_GIT_HASH_KEY = "GIT_BUILD_HASH" def get_build_hash(fallback: Optional[str] = None) -> str: """Get build hash""" build_hash = environ.get(ENV_GIT_HASH_KEY, fallback if fallback else "") - if build_hash == "" and fallback: - return fallback - return build_hash + return fallback if build_hash == "" and fallback else build_hash def get_full_version() -> str: diff --git a/authentik/api/v3/config.py b/authentik/api/v3/config.py index 952a6b637..e7f815b43 100644 --- a/authentik/api/v3/config.py +++ b/authentik/api/v3/config.py @@ -68,7 +68,7 @@ class ConfigView(APIView): caps.append(Capabilities.CAN_GEO_IP) if CONFIG.y_bool("impersonation"): caps.append(Capabilities.CAN_IMPERSONATE) - if settings.DEBUG: + if settings.DEBUG: # pragma: no cover caps.append(Capabilities.CAN_DEBUG) return caps diff --git a/authentik/blueprints/tests/test_models.py b/authentik/blueprints/tests/test_models.py index a27aa5493..718caa502 100644 --- a/authentik/blueprints/tests/test_models.py +++ b/authentik/blueprints/tests/test_models.py @@ -16,7 +16,7 @@ def serializer_tester_factory(test_model: Type[SerializerModel]) -> Callable: """Test serializer""" def tester(self: TestModels): - if test_model._meta.abstract: + if test_model._meta.abstract: # pragma: no cover return model_class = test_model() self.assertTrue(isinstance(model_class, SerializerModel)) diff --git a/authentik/blueprints/tests/test_oci.py b/authentik/blueprints/tests/test_oci.py index 80397b644..2eec45ea2 100644 --- a/authentik/blueprints/tests/test_oci.py +++ b/authentik/blueprints/tests/test_oci.py @@ -26,8 +26,8 @@ class TestBlueprintOCI(TransactionTestCase): self.assertEqual( BlueprintInstance( - path="https://ghcr.io/goauthentik/blueprints/test:latest" - ).retrieve_oci(), + path="oci://ghcr.io/goauthentik/blueprints/test:latest" + ).retrieve(), "foo", ) @@ -40,7 +40,7 @@ class TestBlueprintOCI(TransactionTestCase): with self.assertRaises(BlueprintRetrievalFailed): BlueprintInstance( - path="https://ghcr.io/goauthentik/blueprints/test:latest" + path="oci://ghcr.io/goauthentik/blueprints/test:latest" ).retrieve_oci() def test_manifests_error_response(self): @@ -53,7 +53,7 @@ class TestBlueprintOCI(TransactionTestCase): with self.assertRaises(BlueprintRetrievalFailed): BlueprintInstance( - path="https://ghcr.io/goauthentik/blueprints/test:latest" + path="oci://ghcr.io/goauthentik/blueprints/test:latest" ).retrieve_oci() def test_no_matching_blob(self): @@ -72,7 +72,7 @@ class TestBlueprintOCI(TransactionTestCase): ) with self.assertRaises(BlueprintRetrievalFailed): BlueprintInstance( - path="https://ghcr.io/goauthentik/blueprints/test:latest" + path="oci://ghcr.io/goauthentik/blueprints/test:latest" ).retrieve_oci() def test_blob_error(self): @@ -93,5 +93,5 @@ class TestBlueprintOCI(TransactionTestCase): with self.assertRaises(BlueprintRetrievalFailed): BlueprintInstance( - path="https://ghcr.io/goauthentik/blueprints/test:latest" + path="oci://ghcr.io/goauthentik/blueprints/test:latest" ).retrieve_oci() diff --git a/authentik/core/tests/test_models.py b/authentik/core/tests/test_models.py index 89cf30765..1cf2cff36 100644 --- a/authentik/core/tests/test_models.py +++ b/authentik/core/tests/test_models.py @@ -35,7 +35,7 @@ def source_tester_factory(test_model: type[Stage]) -> Callable: def tester(self: TestModels): model_class = None - if test_model._meta.abstract: + if test_model._meta.abstract: # pragma: no cover model_class = test_model.__bases__[0]() else: model_class = test_model() diff --git a/authentik/lib/tests/test_serializer_model.py b/authentik/lib/tests/test_serializer_model.py index 28b1db718..08907211e 100644 --- a/authentik/lib/tests/test_serializer_model.py +++ b/authentik/lib/tests/test_serializer_model.py @@ -19,7 +19,7 @@ def model_tester_factory(test_model: type[Stage]) -> Callable: def tester(self: TestModels): try: model_class = None - if test_model._meta.abstract: + if test_model._meta.abstract: # pragma: no cover return model_class = test_model() self.assertTrue(issubclass(model_class.serializer, BaseSerializer)) diff --git a/authentik/stages/user_write/tests.py b/authentik/stages/user_write/tests.py index 0bd101fd0..2c967300d 100644 --- a/authentik/stages/user_write/tests.py +++ b/authentik/stages/user_write/tests.py @@ -73,6 +73,9 @@ class TestUserWriteStage(FlowTestCase): "username": "test-user-new", "password": new_password, "attributes.some.custom-attribute": "test", + "attributes": { + "foo": "bar", + }, "some_ignored_attribute": "bar", } session = self.client.session @@ -89,6 +92,7 @@ class TestUserWriteStage(FlowTestCase): self.assertTrue(user_qs.exists()) self.assertTrue(user_qs.first().check_password(new_password)) self.assertEqual(user_qs.first().attributes["some"]["custom-attribute"], "test") + self.assertEqual(user_qs.first().attributes["foo"], "bar") self.assertNotIn("some_ignored_attribute", user_qs.first().attributes) @patch(