halo/e2e/testsuite.yaml

291 lines
7.3 KiB
YAML
Raw Normal View History

name: halo
api: |
{{default "http://halo:8090" (env "SERVER")}}/apis
param:
postName: "{{randAlpha 6}}"
userName: "{{randAlpha 6}}"
roleName: "{{randAlpha 6}}"
notificationName: "{{randAlpha 6}}"
auth: "Basic YWRtaW46MTIzNDU2"
items:
- name: init
request:
api: /api.console.halo.run/v1alpha1/system/initialize
method: POST
header:
Content-Type: application/json
body: |
{
"siteTitle": "testing",
"username": "admin",
"password": "123456",
"email": "testing@halo.com",
"password_confirm": "123456"
}
expect:
statusCode: 201
- name: createPost
request:
api: /api.console.halo.run/v1alpha1/posts
method: POST
header:
Authorization: "{{.param.auth}}"
Content-Type: application/json
body: |
{
"post": {
"spec": {
"title": "{{.param.postName}}",
"slug": "{{.param.postName}}",
"template": "",
"cover": "",
"deleted": false,
"publish": false,
"pinned": false,
"allowComment": true,
"visible": "PUBLIC",
"priority": 0,
"excerpt": {
"autoGenerate": true,
"raw": ""
},
"categories": [],
"tags": [],
"htmlMetas": []
},
"apiVersion": "content.halo.run/v1alpha1",
"kind": "Post",
"metadata": {
"name": "c31f2192-c992-47b9-86b4-f3fc0605360e",
"annotations": {
"content.halo.run/preferred-editor": "default"
}
}
},
"content": {
"raw": "<p>{{.param.postName}}</p>",
"content": "<p>{{.param.postName}}</p>",
"rawType": "HTML"
}
}
- name: listPosts
request:
api: /api.console.halo.run/v1alpha1/posts?keyword={{.param.postName}}
expect:
verify:
- data.total == 1
- name: recyclePost
request:
api: /api.console.halo.run/v1alpha1/posts/{{(index .listPosts.items 0).post.metadata.name}}/recycle
method: PUT
- name: recover
request:
api: /content.halo.run/v1alpha1/posts/{{(index .listPosts.items 0).post.metadata.name}}
method: DELETE
## Users
- name: createUser
request:
api: /api.console.halo.run/v1alpha1/users
method: POST
header:
Content-Type: application/json
body: |
{
"avatar": "",
"bio": "{{randAlpha 6}}",
"displayName": "{{randAlpha 6}}",
"email": "test@halo.com",
"name": "{{.param.userName}}",
"password": "{{randAlpha 6}}",
"phone": "",
"roles": []
}
- name: updateUserPass
request:
api: /api.console.halo.run/v1alpha1/users/{{.param.userName}}/password
method: PUT
header:
Content-Type: application/json
body: |
{
"password": "{{randAlpha 3}}"
}
- name: grantPermission
request:
api: /api.console.halo.run/v1alpha1/users/{{.param.userName}}/permissions
method: POST
header:
Content-Type: application/json
body: |
{
"roles": [
"guest"
]
}
- name: sendPasswordResetEmail
request:
api: |
/api.halo.run/v1alpha1/users/-/send-password-reset-email
method: POST
header:
Content-Type: application/json
body: |
{
"username": "{{.param.userName}}",
"email": "{{.param.email}}"
}
expect:
statusCode: 204
- name: resetPasswordByToken
request:
api: |
/api.halo.run/v1alpha1/users/{{.param.userName}}/reset-password
method: PUT
header:
Content-Type: application/json
body: |
{
"newPassword": "{{randAlpha 6}}",
"token": "{{randAlpha 6}}"
}
expect:
statusCode: 403
## Roles
- name: createRole
request:
api: |
{{default "http://halo:8090" (env "SERVER")}}/api/v1alpha1/roles
method: POST
header:
Content-Type: application/json
body: |
{
"apiVersion": "v1alpha1",
"kind": "Role",
"metadata": {
"name": "",
"generateName": "role-",
"labels": {},
"annotations": {
"rbac.authorization.halo.run/dependencies": "[\"role-template-manage-appstore\"]",
"rbac.authorization.halo.run/display-name": "{{.param.roleName}}"
}
},
"rules": []
}
expect:
statusCode: 201
- name: listRoles
request:
api: |
{{default "http://halo:8090" (env "SERVER")}}/api/v1alpha1/roles
expect:
verify:
- data.total >= 3
- name: deleteRole
request:
api: |
{{default "http://halo:8090" (env "SERVER")}}/api/v1alpha1/roles/{{(index .listRoles.items 0).metadata.name}}
method: DELETE
## Plugins
- name: installPlugin
request:
api: /api.console.halo.run/v1alpha1/plugins/-/install-from-uri
method: POST
header:
Content-Type: application/json
body: |
{
"uri": "https://github.com/Stonewuu/halo-plugin-sitepush/releases/download/1.3.1/halo-plugin-sitepush-1.3.1.jar"
}
- name: pluginList
request:
api: /api.console.halo.run/v1alpha1/plugins
expect:
verify:
- data.total >= 1
- name: inActivePlugins
request:
api: /api.console.halo.run/v1alpha1/plugins?enabled=false&keyword=&page=0&size=0
expect:
verify:
- data.total == 1
- name: disablePlugin
request:
api: /api.console.halo.run/v1alpha1/plugins/PluginSitePush/plugin-state
method: PUT
header:
Content-Type: application/json
body: |
{
"enable": false
}
- name: enablePlugin
request:
api: /api.console.halo.run/v1alpha1/plugins/PluginSitePush/plugin-state
method: PUT
header:
Content-Type: application/json
body: |
{
"enable": true
}
- name: resetPlugin
request:
api: /api.console.halo.run/v1alpha1/plugins/PluginSitePush/reset-config
method: PUT
header:
Content-Type: application/json
- name: uninstallPlugin
request:
api: /plugin.halo.run/v1alpha1/plugins/PluginSitePush
method: DELETE
# Notifications
- name: createNotification
request:
api: /notification.halo.run/v1alpha1/notifications
method: POST
body: |
{
"spec": {
"recipient": "admin",
"reason": "fake-reason",
"title": "test 评论了你的页面《关于我》",
"rawContent": "Fake raw content",
"htmlContent": "<p>Fake html content</p>",
"unread": true
},
"apiVersion": "notification.halo.run/v1alpha1",
"kind": "Notification",
"metadata": {
"name": "{{.param.notificationName}}"
}
}
header:
Content-Type: application/json
expect:
statusCode: 201
- name: getNotificationByName
request:
api: /notification.halo.run/v1alpha1/notifications/{{.param.notificationName}}
method: GET
expect:
statusCode: 200
verify:
- data.spec.reason == "fake-reason"
- data.spec.title == "test 评论了你的页面《关于我》"
- name: deleteUserNotification
request:
api: |
/api.notification.halo.run/v1alpha1/userspaces/admin/notifications/{{.param.notificationName}}
method: DELETE
fix: the e2e script exit code handling is incorrect (#6097) <!-- Thanks for sending a pull request! Here are some tips for you: 1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/main/CONTRIBUTING.md>。 1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/main/CONTRIBUTING.md>. 2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。 2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request. 3. 请确保你已经添加并运行了适当的测试。 3. Ensure you have added or ran the appropriate tests for your PR. --> #### What type of PR is this? <!-- 添加其中一个类别: Add one of the following kinds: /kind bug /kind cleanup /kind documentation /kind feature /kind improvement 适当添加其中一个或多个类别(可选): Optionally add one or more of the following kinds if applicable: /kind api-change /kind deprecation /kind failing-test /kind flake /kind regression --> /kind bug #### What this PR does / why we need it: #### Which issue(s) this PR fixes: <!-- PR 合并时自动关闭 issue。 Automatically closes linked issue when PR is merged. 用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)` Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. --> Fixes https://github.com/halo-dev/halo/issues/6096 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? <!-- 如果当前 Pull Request 的修改不会造成用户侧的任何变更,在 `release-note` 代码块儿中填写 `NONE`。 否则请填写用户侧能够理解的 Release Note。如果当前 Pull Request 包含破坏性更新(Break Change), Release Note 需要以 `action required` 开头。 If no, just write "NONE" in the release-note block below. If yes, a release note is required: Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required". --> ```release-note None ```
2024-07-02 11:07:23 +00:00
- name: deleteUser
request:
api: |
{{default "http://halo:8090" (env "SERVER")}}/api/v1alpha1/users/{{.param.userName}}
method: DELETE