blueprints: remove _state from exporter blueprints

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-08-18 19:23:50 +02:00
parent f4441c9fcf
commit 9d58407e25
3 changed files with 11 additions and 5 deletions

View File

@ -10,7 +10,7 @@ from authentik.blueprints.v1.importer import Importer
from authentik.tenants.models import Tenant
class TestBundled(TransactionTestCase):
class TestPackaged(TransactionTestCase):
"""Empty class, test methods are added dynamically"""
@apply_blueprint("default/90-default-tenant.yaml")
@ -22,7 +22,7 @@ class TestBundled(TransactionTestCase):
def blueprint_tester(file_name: Path) -> Callable:
"""This is used instead of subTest for better visibility"""
def tester(self: TestBundled):
def tester(self: TestPackaged):
base = Path("blueprints/")
rel_path = Path(file_name).relative_to(base)
importer = Importer(BlueprintInstance(path=str(rel_path)).retrieve())
@ -33,4 +33,4 @@ def blueprint_tester(file_name: Path) -> Callable:
for blueprint_file in Path("blueprints/").glob("**/*.yaml"):
setattr(TestBundled, f"test_blueprint_{blueprint_file}", blueprint_tester(blueprint_file))
setattr(TestPackaged, f"test_blueprint_{blueprint_file}", blueprint_tester(blueprint_file))

View File

@ -232,7 +232,13 @@ class BlueprintDumper(SafeDumper):
def represent(self, data) -> None:
if is_dataclass(data):
data = asdict(data)
def factory(items):
final_dict = dict(items)
final_dict.pop("_state", None)
return final_dict
data = asdict(data, dict_factory=factory)
return super().represent(data)

View File

@ -231,7 +231,7 @@ class Importer:
self.logger.debug("Starting blueprint import validation")
orig_import = deepcopy(self.__import)
if self.__import.version != 1:
self.logger.warning("Invalid bundle version")
self.logger.warning("Invalid blueprint version")
return False, []
with (
transaction_rollback(),