Dry run publish 1C access profiles
This commit is contained in:
@@ -3015,6 +3015,30 @@ async def get_project_access_profile_publish_plan(project_id: str, profile_name:
|
||||
return _build_access_profile_publish_plan(normalized, profile)
|
||||
|
||||
|
||||
@app.post("/projects/{project_id}/access/profiles/{profile_name}/publish-dry-run", response_model=SferaExtensionCallResponse)
|
||||
async def dry_run_project_access_profile_publish(project_id: str, profile_name: str) -> SferaExtensionCallResponse:
|
||||
settings = _project_settings_or_404(project_id)
|
||||
normalized = _load_normalized_project(project_id)
|
||||
if normalized is None:
|
||||
raise HTTPException(status_code=404, detail="NormalizedProject not found")
|
||||
profile = _access_profile_by_name(normalized, profile_name)
|
||||
if profile is None:
|
||||
raise HTTPException(status_code=404, detail="Access profile not found")
|
||||
plan = _build_access_profile_publish_plan(normalized, profile)
|
||||
if not plan.ready_for_extension:
|
||||
raise HTTPException(status_code=409, detail="Access profile publish plan is not ready for extension")
|
||||
return _call_sfera_extension(
|
||||
project_id,
|
||||
settings,
|
||||
SferaExtensionCallRequest(
|
||||
operation="access.profile.apply",
|
||||
payload=plan.extension_payload,
|
||||
dry_run=True,
|
||||
allow_mutation=False,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@app.get("/projects/{project_id}/imports/quality", response_model=ImportQualityResponse)
|
||||
async def get_import_quality(project_id: str) -> ImportQualityResponse:
|
||||
return _import_quality_response(project_id)
|
||||
@@ -6568,6 +6592,7 @@ _SFERA_EXTENSION_MUTATION_OPERATIONS = {
|
||||
"data.write",
|
||||
"data.delete",
|
||||
"metadata.apply",
|
||||
"access.profile.apply",
|
||||
"admin.command",
|
||||
}
|
||||
|
||||
@@ -6601,6 +6626,7 @@ def _sfera_extension_operation_path(operation: str) -> str:
|
||||
"data.write": "v1/data/write",
|
||||
"query.execute": "v1/query",
|
||||
"metadata.apply": "v1/metadata/apply",
|
||||
"access.profile.apply": "v1/metadata/apply",
|
||||
"admin.command": "v1/admin/command",
|
||||
}
|
||||
return mapping.get(operation, "v1/call")
|
||||
|
||||
@@ -1466,7 +1466,7 @@ def test_runtime_required_import_does_not_index_cf_file_directly(monkeypatch, tm
|
||||
assert payload["normalized_summary"]["object_count"] >= 1
|
||||
|
||||
|
||||
def test_import_supports_structure_only_indexing(tmp_path: Path):
|
||||
def test_import_supports_structure_only_indexing(monkeypatch, tmp_path: Path):
|
||||
(tmp_path / "metadata.xml").write_text(
|
||||
"""
|
||||
<Configuration>
|
||||
@@ -1585,6 +1585,31 @@ def test_import_supports_structure_only_indexing(tmp_path: Path):
|
||||
assert any(item["action"] == "ADD_ROLE_TO_PROFILE" and item["role"] == "Роль.Менеджер" for item in plan_payload["operations"])
|
||||
assert plan_payload["extension_payload"]["operation"] == "access.profile.apply"
|
||||
|
||||
captured_extension_call = {}
|
||||
|
||||
def fake_extension_call(project_id_arg, settings_arg, request_arg):
|
||||
captured_extension_call["project_id"] = project_id_arg
|
||||
captured_extension_call["request"] = request_arg
|
||||
return main.SferaExtensionCallResponse(
|
||||
project_id=project_id_arg,
|
||||
operation=request_arg.operation,
|
||||
status="READY",
|
||||
ready=True,
|
||||
dry_run=request_arg.dry_run,
|
||||
extension_url="http://example.test/hs/sfera/v1/metadata/apply",
|
||||
result={"status": "dry_run", "operation": request_arg.operation},
|
||||
)
|
||||
|
||||
monkeypatch.setattr(main, "_call_sfera_extension", fake_extension_call)
|
||||
publish_dry_run = client.post(
|
||||
f"/projects/{project_id}/access/profiles/{quote('НовыйПрофильHTTP')}/publish-dry-run"
|
||||
)
|
||||
assert publish_dry_run.status_code == 200
|
||||
assert publish_dry_run.json()["operation"] == "access.profile.apply"
|
||||
assert captured_extension_call["project_id"] == project_id
|
||||
assert captured_extension_call["request"].dry_run is True
|
||||
assert captured_extension_call["request"].payload["profile"]["roles"] == ["Роль.Менеджер"]
|
||||
|
||||
tree = client.get(f"/projects/{project_id}/metadata/tree")
|
||||
assert tree.status_code == 200
|
||||
root = tree.json()["root"]
|
||||
|
||||
Reference in New Issue
Block a user