diff --git a/module/webhook/test/lib/webhook.unittest.class.php b/module/webhook/test/lib/webhook.unittest.class.php index 61788861c7..93c02e165e 100644 --- a/module/webhook/test/lib/webhook.unittest.class.php +++ b/module/webhook/test/lib/webhook.unittest.class.php @@ -5,6 +5,7 @@ class webhookTest { global $tester; $this->objectModel = $tester->loadModel('webhook'); + $this->objectTao = $tester->loadTao('webhook'); } /** @@ -464,4 +465,23 @@ class webhookTest return $result; } + + /** + * Test getDingdingSecret method. + * + * @param object $webhook + * @access public + * @return object|false + */ + public function getDingdingSecretTest($webhook) + { + $reflection = new ReflectionClass($this->objectTao); + $method = $reflection->getMethod('getDingdingSecret'); + $method->setAccessible(true); + + $result = $method->invoke($this->objectTao, $webhook); + if(dao::isError()) return dao::getError(); + + return $result; + } } diff --git a/module/webhook/test/tao/getdingdingsecret.php b/module/webhook/test/tao/getdingdingsecret.php new file mode 100755 index 0000000000..53251598c1 --- /dev/null +++ b/module/webhook/test/tao/getdingdingsecret.php @@ -0,0 +1,63 @@ +#!/usr/bin/env php +agentId = '123456789'; +$normalWebhook->appKey = 'testappkey'; +$normalWebhook->appSecret = 'testappsecret'; + +r($webhookTest->getDingdingSecretTest($normalWebhook)) && p('url') && e('https://oapi.dingtalk.com/'); + +// 缺少agentId +$missingAgentId = new stdClass(); +$missingAgentId->agentId = ''; +$missingAgentId->appKey = 'testappkey'; +$missingAgentId->appSecret = 'testappsecret'; + +r($webhookTest->getDingdingSecretTest($missingAgentId)) && p('agentId') && e('『钉钉AgentId』不能为空。'); + +// 缺少appKey +$missingAppKey = new stdClass(); +$missingAppKey->agentId = '123456789'; +$missingAppKey->appKey = ''; +$missingAppKey->appSecret = 'testappsecret'; + +r($webhookTest->getDingdingSecretTest($missingAppKey)) && p('appKey') && e('『钉钉AppKey』不能为空。'); + +// 缺少appSecret +$missingAppSecret = new stdClass(); +$missingAppSecret->agentId = '123456789'; +$missingAppSecret->appKey = 'testappkey'; +$missingAppSecret->appSecret = ''; + +r($webhookTest->getDingdingSecretTest($missingAppSecret)) && p('appSecret') && e('『钉钉AppSecret』不能为空。'); + +// 所有参数都为空 +$emptyWebhook = new stdClass(); +$emptyWebhook->agentId = ''; +$emptyWebhook->appKey = ''; +$emptyWebhook->appSecret = ''; + +r($webhookTest->getDingdingSecretTest($emptyWebhook)) && p('agentId') && e('『钉钉AgentId』不能为空。'); \ No newline at end of file diff --git a/module/webhook/test/tao/yaml/webhook_getdingdingsecret.yaml b/module/webhook/test/tao/yaml/webhook_getdingdingsecret.yaml new file mode 100644 index 0000000000..d0276cb289 --- /dev/null +++ b/module/webhook/test/tao/yaml/webhook_getdingdingsecret.yaml @@ -0,0 +1,78 @@ +--- +title: 钉钉Webhook密钥配置测试数据 +desc: getDingdingSecret方法的测试数据配置 +author: Claude Code +version: 1.0 + +fields: +- field: id + note: webhook ID + range: 1-10 + prefix: "" + postfix: "" + loop: 0 + format: "" +- field: type + note: webhook类型 + range: dingding + prefix: "" + postfix: "" +- field: name + note: webhook名称 + range: 'dingding_test{1-10}' + prefix: "" + postfix: "" +- field: url + note: webhook URL + range: 'https://test.dingding.com/api{1-10}' + prefix: "" + postfix: "" +- field: agentId + note: 钉钉应用ID + range: '123456{1-10}' + prefix: "" + postfix: "" +- field: appKey + note: 钉钉应用Key + range: 'dingapp{1-10}' + prefix: "" + postfix: "" +- field: appSecret + note: 钉钉应用密钥 + range: 'secret{1-10}key' + prefix: "" + postfix: "" +- field: secret + note: 处理后的密钥JSON + range: '{}' + prefix: "" + postfix: "" +- field: contentType + note: 内容类型 + range: 'application/json' + prefix: "" + postfix: "" +- field: sendType + note: 发送类型 + range: 'sync' + prefix: "" + postfix: "" +- field: params + note: 参数配置 + range: 'title,text,mobile' + prefix: "" + postfix: "" +- field: createdBy + note: 创建者 + range: 'admin{3},user{7}' + prefix: "" + postfix: "" +- field: createdDate + note: 创建时间 + range: '2023-01-01 00:00:00-2023-12-31 23:59:59' + format: 'YYYY-MM-DD hh:mm:ss' +- field: deleted + note: 删除标记 + range: '0' + prefix: "" + postfix: "" \ No newline at end of file