Skip to content

Commit

Permalink
feat: add webhook bearer auth support (#619)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
LinuxSuRen and LinuxSuRen authored Feb 15, 2025
1 parent 430d912 commit 4b4ee3a
Show file tree
Hide file tree
Showing 7 changed files with 605 additions and 444 deletions.
14 changes: 9 additions & 5 deletions docs/site/content/zh/latest/tasks/mock/simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ items:
response:
header:
server: mock
content-type: application/json
body: |
{
"count": 1,
"items": [{
"title": "fix: there is a bug on page {{ randEnum "one" }}",
"number": 123,
"title": "fix: there is a bug on page {{ randEnum "one" "two" "three" "four" }}",
"number": {{randInt 100 199}},
"float": {{randFloat 0.0 1.0}},
"status": "{{randWeightEnum (weightObject 4 "open") (weightObject 1 "closed")}}",
"message": "{{.Response.Header.server}}",
"author": "someone",
"status": "success"
}]
"author": "{{env "USER"}}",
"created": "{{ now.Format "2006-01-02T15:04:05Z07:00" }}"
}],
"uptime": "{{uptime}}"
}
- name: base64
request:
Expand Down
26 changes: 25 additions & 1 deletion docs/site/content/zh/latest/tasks/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,28 @@ title = "用例模板"

```
182{{shuffle "09876543"}}
```
```

## 带权重的随机枚举

下面的代码以 80% 的概率返回 `open`,以 20% 的概率返回 `closed`

```
{{randWeightEnum (weightObject 4 "open") (weightObject 1 "closed")}}
```

## 时间

下面的代码可以生成当前时间,并制定时间格式:

```
{{ now.Format "2006-01-02T15:04:05Z07:00" }}
```

## 环境变量

下面的代码可以获取环境变量 `SHELL` 的值,在需要使用一个全局变量的时候,可以使用这个模板函数:

```
{{ env "SHELL" }}
```
Loading

0 comments on commit 4b4ee3a

Please sign in to comment.