Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复sql query 审核回调 #2370

Merged
merged 4 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ sonar-project.properties
.env
local_settings.py
src/docker-compose-dev
.coverage
.coverage
archery_custom
15 changes: 14 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime

import pytest
from pytest_mock import MockFixture

from common.utils.const import WorkflowStatus
from sql.models import (
Expand All @@ -12,6 +13,7 @@
ArchiveConfig,
)
from common.config import SysConfig
from sql.utils.workflow_audit import AuditV2, AuditSetting


@pytest.fixture
Expand Down Expand Up @@ -91,7 +93,7 @@ def sql_query_apply(db_instance):
valid_date=tomorrow,
priv_type=1,
status=0,
audit_auth_groups="some_audit_group",
audit_auth_groups="1",
)
yield query_apply_1
query_apply_1.delete()
Expand Down Expand Up @@ -127,3 +129,14 @@ def setup_sys_config(db):
sys_config = SysConfig()
yield sys_config
sys_config.purge()


@pytest.fixture
def fake_generate_audit_setting(mocker: MockFixture):
mock_generate_audit_setting = mocker.patch.object(AuditV2, "generate_audit_setting")
fake_audit_setting = AuditSetting(
auto_pass=False,
audit_auth_groups=[123],
)
mock_generate_audit_setting.return_value = fake_audit_setting
yield mock_generate_audit_setting
10 changes: 4 additions & 6 deletions sql/query_privileges.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ def query_priv_audit(request):
:return:
"""
# 获取用户信息
user = request.user
apply_id = int(request.POST["apply_id"])
try:
audit_status = WorkflowAction(int(request.POST["audit_status"]))
Expand All @@ -437,11 +436,10 @@ def query_priv_audit(request):
)
except AuditException as e:
return render(request, "error.html", {"errMsg": f"审核失败: {str(e)}"})
if auditor.audit.current_status == WorkflowStatus.PASSED:
# 通过了, 授权
_query_apply_audit_call_back(
auditor.audit.workflow_id, auditor.audit.current_status
)
# 统一 call back, 内部做授权和更新数据库内容
_query_apply_audit_call_back(
auditor.audit.workflow_id, auditor.audit.current_status
)

# 消息通知
async_task(
Expand Down
Loading
Loading