Skip to content

Commit 4b4ee3a

Browse files
authored
feat: add webhook bearer auth support (#619)
* feat: add webhook bearer auth support * add tpl func randFloat * refactor run webhook * add template func uptimeSeconds * add random enum with weight feature --------- Co-authored-by: rick <[email protected]>
1 parent 430d912 commit 4b4ee3a

File tree

7 files changed

+605
-444
lines changed

7 files changed

+605
-444
lines changed

docs/site/content/zh/latest/tasks/mock/simple.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ items:
77
response:
88
header:
99
server: mock
10+
content-type: application/json
1011
body: |
1112
{
1213
"count": 1,
1314
"items": [{
14-
"title": "fix: there is a bug on page {{ randEnum "one" }}",
15-
"number": 123,
15+
"title": "fix: there is a bug on page {{ randEnum "one" "two" "three" "four" }}",
16+
"number": {{randInt 100 199}},
17+
"float": {{randFloat 0.0 1.0}},
18+
"status": "{{randWeightEnum (weightObject 4 "open") (weightObject 1 "closed")}}",
1619
"message": "{{.Response.Header.server}}",
17-
"author": "someone",
18-
"status": "success"
19-
}]
20+
"author": "{{env "USER"}}",
21+
"created": "{{ now.Format "2006-01-02T15:04:05Z07:00" }}"
22+
}],
23+
"uptime": "{{uptime}}"
2024
}
2125
- name: base64
2226
request:

docs/site/content/zh/latest/tasks/template.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,28 @@ title = "用例模板"
1010

1111
```
1212
182{{shuffle "09876543"}}
13-
```
13+
```
14+
15+
## 带权重的随机枚举
16+
17+
下面的代码以 80% 的概率返回 `open`,以 20% 的概率返回 `closed`
18+
19+
```
20+
{{randWeightEnum (weightObject 4 "open") (weightObject 1 "closed")}}
21+
```
22+
23+
## 时间
24+
25+
下面的代码可以生成当前时间,并制定时间格式:
26+
27+
```
28+
{{ now.Format "2006-01-02T15:04:05Z07:00" }}
29+
```
30+
31+
## 环境变量
32+
33+
下面的代码可以获取环境变量 `SHELL` 的值,在需要使用一个全局变量的时候,可以使用这个模板函数:
34+
35+
```
36+
{{ env "SHELL" }}
37+
```

0 commit comments

Comments
 (0)