feat(integration-connector): 新增集成连接器管理后台,支持关键字段拆列配置
This commit is contained in:
1 parent
bf30cddc4a
commit
1269e04116
28 files changed
+2909
-155
No files matched your search
@@ -144,3 +144,147 @@ def test_client_instance_test_connection(app, client, admin_headers, fake_gatewa
|
||||
response = client.post(f"{API_PREFIX}/client-instances/CLI-A/test", headers=admin_headers)
|
||||
assert response.status_code == 200
|
||||
assert response.get_json()["data"]["ok"] is True
|
||||
|
||||
|
||||
def test_update_client_instance(app, client, admin_headers):
|
||||
"""PUT /client-instances/<code> → 200,更新 name/config/enabled。"""
|
||||
client.post(f"{API_PREFIX}/client-instances", headers=admin_headers, json={
|
||||
"code": "CLI-U", "name": "old", "connector_type": "rest", "environment": "prod",
|
||||
"config_json": {"endpoint": "https://old.invalid"},
|
||||
})
|
||||
response = client.put(f"{API_PREFIX}/client-instances/CLI-U", headers=admin_headers, json={
|
||||
"name": "new", "config_json": {"endpoint": "https://new.invalid"}, "enabled": False,
|
||||
})
|
||||
assert response.status_code == 200
|
||||
assert response.get_json()["data"]["name"] == "new"
|
||||
assert response.get_json()["data"]["enabled"] is False
|
||||
assert response.get_json()["data"]["config_json"] == {"endpoint": "https://new.invalid"}
|
||||
|
||||
|
||||
def test_update_interface_definition(app, client, admin_headers):
|
||||
"""PUT /interface-definitions/<code> → 200,更新模板/回传映射/状态。"""
|
||||
client.post(f"{API_PREFIX}/client-instances", headers=admin_headers, json={
|
||||
"code": "CLI-I", "name": "cli", "connector_type": "rest", "environment": "prod",
|
||||
"config_json": {},
|
||||
})
|
||||
client.post(f"{API_PREFIX}/interface-definitions", headers=admin_headers, json={
|
||||
"code": "IF-U", "name": "iface", "client_instance_code": "CLI-I", "connector_type": "rest",
|
||||
"request_spec_json": {"path": "/v1/old"}, "status": "draft",
|
||||
})
|
||||
response = client.put(f"{API_PREFIX}/interface-definitions/IF-U", headers=admin_headers, json={
|
||||
"request_spec_json": {"path": "/v1/new"}, "response_mapping_json": {"qty": "data.quantity"},
|
||||
"status": "published",
|
||||
})
|
||||
assert response.status_code == 200
|
||||
data = response.get_json()["data"]
|
||||
assert data["status"] == "published"
|
||||
assert data["request_spec_json"] == {"path": "/v1/new"}
|
||||
|
||||
|
||||
def test_update_binding(app, client, admin_headers):
|
||||
"""PUT /bindings/<id> → 200,更新映射版本/优先级/状态。"""
|
||||
client.post(f"{API_PREFIX}/client-instances", headers=admin_headers, json={
|
||||
"code": "CLI-B", "name": "cli", "connector_type": "rest", "environment": "prod",
|
||||
"config_json": {},
|
||||
})
|
||||
client.post(f"{API_PREFIX}/interface-definitions", headers=admin_headers, json={
|
||||
"code": "IF-B", "name": "iface", "client_instance_code": "CLI-B", "connector_type": "rest",
|
||||
})
|
||||
created = client.post(f"{API_PREFIX}/bindings", headers=admin_headers, json={
|
||||
"capability": "in_transit_transfer.query_inventory", "client_instance_code": "CLI-B",
|
||||
"interface_definition_code": "IF-B", "status": "draft",
|
||||
})
|
||||
binding_id = created.get_json()["data"]["id"]
|
||||
response = client.put(f"{API_PREFIX}/bindings/{binding_id}", headers=admin_headers, json={
|
||||
"priority": 5, "mapping_version": 2, "status": "published",
|
||||
})
|
||||
assert response.status_code == 200
|
||||
data = response.get_json()["data"]
|
||||
assert data["priority"] == 5
|
||||
assert data["mapping_version"] == 2
|
||||
assert data["status"] == "published"
|
||||
|
||||
|
||||
def test_update_credential_reference(app, client, admin_headers):
|
||||
"""PUT /credential-references/<code> → 200,更新 secret_ref/status,且不回显明文。"""
|
||||
client.post(f"{API_PREFIX}/credential-references", headers=admin_headers, json={
|
||||
"code": "CRED-U", "secret_ref": "IN_TRANSIT_ERP_PASSWORD",
|
||||
})
|
||||
response = client.put(f"{API_PREFIX}/credential-references/CRED-U", headers=admin_headers, json={
|
||||
"secret_ref": "IN_TRANSIT_ERP_PASSWORD_ROTATED", "status": "rotating",
|
||||
})
|
||||
assert response.status_code == 200
|
||||
data = response.get_json()["data"]
|
||||
assert data["secret_ref"] == "IN_TRANSIT_ERP_PASSWORD_ROTATED"
|
||||
assert data["status"] == "rotating"
|
||||
assert "secret" not in str(data).lower() or data.get("secret") is None
|
||||
|
||||
|
||||
def test_client_instance_split_columns(app, client, admin_headers):
|
||||
"""POST /client-instances 写 endpoint/timeout_seconds 独立列,config_json 仅存扩展。"""
|
||||
created = client.post(f"{API_PREFIX}/client-instances", headers=admin_headers, json={
|
||||
"code": "CLI-COL", "name": "col client", "connector_type": "soap", "environment": "prod",
|
||||
"endpoint": "https://erp.invalid/wsdl", "timeout_seconds": 90,
|
||||
"config_json": {"headers": {"X-Tenant": "A"}},
|
||||
})
|
||||
assert created.status_code == 201
|
||||
data = created.get_json()["data"]
|
||||
assert data["endpoint"] == "https://erp.invalid/wsdl"
|
||||
assert data["timeout_seconds"] == 90
|
||||
assert data["config_json"] == {"headers": {"X-Tenant": "A"}}
|
||||
|
||||
updated = client.put(f"{API_PREFIX}/client-instances/CLI-COL", headers=admin_headers, json={
|
||||
"endpoint": "https://erp2.invalid/wsdl", "timeout_seconds": 120,
|
||||
})
|
||||
assert updated.status_code == 200
|
||||
assert updated.get_json()["data"]["endpoint"] == "https://erp2.invalid/wsdl"
|
||||
assert updated.get_json()["data"]["timeout_seconds"] == 120
|
||||
|
||||
|
||||
def test_interface_definition_split_columns(app, client, admin_headers):
|
||||
"""POST/PUT /interface-definitions 写 http_method/request_path 独立列。"""
|
||||
client.post(f"{API_PREFIX}/client-instances", headers=admin_headers, json={
|
||||
"code": "CLI-IF", "name": "cli", "connector_type": "rest", "environment": "prod",
|
||||
"endpoint": "https://erp.invalid",
|
||||
})
|
||||
created = client.post(f"{API_PREFIX}/interface-definitions", headers=admin_headers, json={
|
||||
"code": "IF-COL", "name": "iface", "client_instance_code": "CLI-IF", "connector_type": "rest",
|
||||
"http_method": "post", "request_path": "/transfer/{invoice_no}",
|
||||
"request_spec_json": {"template": {"qty": "{quantity}"}},
|
||||
})
|
||||
assert created.status_code == 201
|
||||
data = created.get_json()["data"]
|
||||
assert data["http_method"] == "POST"
|
||||
assert data["request_path"] == "/transfer/{invoice_no}"
|
||||
|
||||
updated = client.put(f"{API_PREFIX}/interface-definitions/IF-COL", headers=admin_headers, json={
|
||||
"http_method": "get", "request_path": "/inventory/{invoice_no}",
|
||||
})
|
||||
assert updated.status_code == 200
|
||||
assert updated.get_json()["data"]["http_method"] == "GET"
|
||||
assert updated.get_json()["data"]["request_path"] == "/inventory/{invoice_no}"
|
||||
|
||||
|
||||
def test_binding_split_columns(app, client, admin_headers):
|
||||
"""POST/PUT /bindings 写 context_source_code 独立列并回显。"""
|
||||
client.post(f"{API_PREFIX}/client-instances", headers=admin_headers, json={
|
||||
"code": "CLI-BC", "name": "cli", "connector_type": "rest", "environment": "prod",
|
||||
"endpoint": "https://erp.invalid",
|
||||
})
|
||||
client.post(f"{API_PREFIX}/interface-definitions", headers=admin_headers, json={
|
||||
"code": "IF-BC", "name": "iface", "client_instance_code": "CLI-BC", "connector_type": "rest",
|
||||
})
|
||||
created = client.post(f"{API_PREFIX}/bindings", headers=admin_headers, json={
|
||||
"capability": "in_transit_transfer.query_inventory",
|
||||
"client_instance_code": "CLI-BC", "interface_definition_code": "IF-BC",
|
||||
"context_source_code": "DBS-AWSBI", "status": "published",
|
||||
})
|
||||
assert created.status_code == 201
|
||||
data = created.get_json()["data"]
|
||||
assert data["context_source_code"] == "DBS-AWSBI"
|
||||
|
||||
updated = client.put(f"{API_PREFIX}/bindings/{data['id']}", headers=admin_headers, json={
|
||||
"context_source_code": "CRANE-SZ",
|
||||
})
|
||||
assert updated.status_code == 200
|
||||
assert updated.get_json()["data"]["context_source_code"] == "CRANE-SZ"
|
||||
Reference in new issue
Block a user