Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
willdesk_apiauto
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
29
Issues
29
List
Boards
Labels
Service Desk
Milestones
Merge Requests
29
Merge Requests
29
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
桦生 詹
willdesk_apiauto
Commits
b368b3a3
Commit
b368b3a3
authored
Apr 22, 2024
by
zhanhuasheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix
parent
c5dd74ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
18 deletions
+5
-18
Utils/webhook_handler.py
Utils/webhook_handler.py
+5
-18
No files found.
Utils/webhook_handler.py
View file @
b368b3a3
...
...
@@ -9,7 +9,7 @@ import urllib.parse
timestamp
=
str
(
round
(
time
.
time
()
*
1000
))
secret
=
'SEC
9d91939234e83369cba32c0ca4bcd9af60b5b1f69424d6fabd36f48d572a151c
'
secret
=
'SEC
80ae01de9c486a9f8531d4ec1ed09b8fbd5d9cc1b0ba171b0493f9bebfeb4807
'
secret_enc
=
secret
.
encode
(
'utf-8'
)
string_to_sign
=
'{}
\n
{}'
.
format
(
timestamp
,
secret
)
string_to_sign_enc
=
string_to_sign
.
encode
(
'utf-8'
)
...
...
@@ -20,7 +20,7 @@ sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
class
webhookHandler
:
def
__init__
(
self
,
webhookUrl
=
f
"https://oapi.dingtalk.com/robot/send?access_token=
22fda27990b00841c3201c20649c0a8abb6da82d8472b6f6154ef4cd9dadb33f
×tamp=
{
timestamp
}
&sign=
{
sign
}
"
):
def
__init__
(
self
,
webhookUrl
=
f
"https://oapi.dingtalk.com/robot/send?access_token=
775093d6cbe22673b65e506f20aea7036cc58c4b9e89850f660eb798e4c149f6
×tamp=
{
timestamp
}
&sign=
{
sign
}
"
):
self
.
webhookUrl
=
webhookUrl
...
...
@@ -31,7 +31,7 @@ class webhookHandler:
"msgtype"
:
"markdown"
,
"markdown"
:
{
"title"
:
"#willdesk接口自动化测试报告"
,
"text"
:
"#### 本次接口自动化测试结果如下
\n
> ###### 用例总数:%s
\n
> ###### 成功用例数量:%s
\n
> ###### 失败用例数量:%s
\n
> ###### 报错用例数量:%s
\n
> ###### 跳过用例数量:%s
\n
> ###### 耗时:%s秒
\n
> ###### 报告生成时间:%s [测试报告](
%s)"
%
(
result
.
_numcollected
,
len
(
result
.
stats
.
get
(
'passed'
,
[])),
len
(
result
.
stats
.
get
(
'failed'
,
[])),
len
(
result
.
stats
.
get
(
'error'
,
[])),
len
(
result
.
stats
.
get
(
'skipped'
,
[])),
second
,
current_date_time_str
,
self
.
get_local_ip_address
()
)
"text"
:
"#### 本次接口自动化测试结果如下
\n
> ###### 用例总数:%s
\n
> ###### 成功用例数量:%s
\n
> ###### 失败用例数量:%s
\n
> ###### 报错用例数量:%s
\n
> ###### 跳过用例数量:%s
\n
> ###### 耗时:%s秒
\n
> ###### 报告生成时间:%s [测试报告](
https://www.baidu.com)"
%
(
result
.
_numcollected
,
len
(
result
.
stats
.
get
(
'passed'
,
[])),
len
(
result
.
stats
.
get
(
'failed'
,
[])),
len
(
result
.
stats
.
get
(
'error'
,
[])),
len
(
result
.
stats
.
get
(
'skipped'
,
[])),
second
,
current_date_time_str
)
},
}
res
=
requests
.
post
(
url
=
self
.
webhookUrl
,
json
=
data
)
...
...
@@ -48,18 +48,5 @@ class webhookHandler:
}
res
=
requests
.
post
(
url
=
self
.
webhookUrl
,
data
=
data
)
def
get_local_ip_address
(
self
):
cmd
=
'ifconfig'
result
=
subprocess
.
run
(
cmd
,
capture_output
=
True
,
text
=
True
,
shell
=
True
)
output
=
result
.
stdout
ip
=
None
for
line
in
output
.
split
(
'
\n
'
):
if
'inet '
in
line
and
'127.0.0.1'
not
in
line
:
ip
=
line
.
split
(
' '
)[
1
]
break
if
ip
:
ip
=
ip
+
':8000/report.html'
else
:
ip
=
'https://www.baidu.com'
return
ip
webhook
=
webhookHandler
()
\ No newline at end of file
webhook
=
webhookHandler
()
webhook
.
getToken
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment