mirror of https://github.com/halo-dev/halo
test: add e2e test cases of user, role, and plugin (#4920)
* chore: provide an out-of-the-box gitpod config file * test: add e2e test cases of user, role, and plugin --------- Co-authored-by: rick <LinuxSuRen@users.noreply.github.com> Co-authored-by: John Niang <johnniang@foxmail.com>pull/4937/head^2
parent
99edbddfa2
commit
ce5c1f9052
|
@ -91,5 +91,5 @@ jobs:
|
||||||
sudo chmod u+x /usr/local/bin/docker-compose
|
sudo chmod u+x /usr/local/bin/docker-compose
|
||||||
|
|
||||||
repo=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
|
repo=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
|
||||||
docker tag ghcr.io/${repo}/halo-dev:pr-${{ github.event.number }} ghcr.io/halo-dev/halo-dev:dev
|
docker tag ghcr.io/${repo}/halo-dev:pr-${{ github.event.number }} ghcr.io/halo-dev/halo-dev:main
|
||||||
cd e2e && ./start.sh
|
cd e2e && ./start.sh
|
||||||
|
|
|
@ -64,7 +64,6 @@ nbdist/
|
||||||
|
|
||||||
### VSCode
|
### VSCode
|
||||||
.vscode
|
.vscode
|
||||||
.gitpod.yml
|
|
||||||
|
|
||||||
### Local file
|
### Local file
|
||||||
application-local.yml
|
application-local.yml
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
# This configuration file was automatically generated by Gitpod.
|
||||||
|
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
|
||||||
|
# and commit this file to your remote git repository to share the goodness with others.
|
||||||
|
|
||||||
|
# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- init: ./gradlew clean build -x check && sdk install java 17.0.3-ms
|
|
@ -13,5 +13,12 @@ Please follow these steps if you want to run the e2e testing locally.
|
||||||
> Please make sure you have installed docker-compose v2
|
> Please make sure you have installed docker-compose v2
|
||||||
|
|
||||||
* Build project via `./gradlew clean build -x check` in root directory of this repository
|
* Build project via `./gradlew clean build -x check` in root directory of this repository
|
||||||
* Build image via `docker build . -t ghcr.io/halo-dev/halo-dev:dev`
|
* Build image via `docker build . -t ghcr.io/halo-dev/halo-dev:main`
|
||||||
* Change the directory to `e2e`, then execute `./start.sh`
|
* Change the directory to `e2e`, then execute `./start.sh`
|
||||||
|
|
||||||
|
## Run Halo only
|
||||||
|
Please run the following command if you only want to run Halo.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker-compose up halo
|
||||||
|
```
|
||||||
|
|
|
@ -10,7 +10,7 @@ services:
|
||||||
halo:
|
halo:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
halo:
|
halo:
|
||||||
image: ghcr.io/halo-dev/halo-dev:dev
|
image: ghcr.io/halo-dev/halo-dev:${TAG:-main}
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:8090/actuator/health/readiness"]
|
test: ["CMD", "curl", "-f", "http://localhost:8090/actuator/health/readiness"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
|
@ -25,6 +25,8 @@ services:
|
||||||
- --spring.sql.init.platform=postgresql
|
- --spring.sql.init.platform=postgresql
|
||||||
# 外部访问地址,请根据实际需要修改
|
# 外部访问地址,请根据实际需要修改
|
||||||
# - --halo.external-url=http://localhost:8090/
|
# - --halo.external-url=http://localhost:8090/
|
||||||
|
ports:
|
||||||
|
- 8090:8090
|
||||||
links:
|
links:
|
||||||
- postgresql
|
- postgresql
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
|
@ -4,6 +4,7 @@ api: |
|
||||||
param:
|
param:
|
||||||
postName: "{{randAlpha 6}}"
|
postName: "{{randAlpha 6}}"
|
||||||
userName: "{{randAlpha 6}}"
|
userName: "{{randAlpha 6}}"
|
||||||
|
roleName: "{{randAlpha 6}}"
|
||||||
notificationName: "{{randAlpha 6}}"
|
notificationName: "{{randAlpha 6}}"
|
||||||
auth: "Basic YWRtaW46MTIzNDU2"
|
auth: "Basic YWRtaW46MTIzNDU2"
|
||||||
items:
|
items:
|
||||||
|
@ -28,7 +29,7 @@ items:
|
||||||
api: /api.console.halo.run/v1alpha1/posts
|
api: /api.console.halo.run/v1alpha1/posts
|
||||||
method: POST
|
method: POST
|
||||||
header:
|
header:
|
||||||
Authorization: "Basic YWRtaW46MTIzNDU2"
|
Authorization: "{{.param.auth}}"
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
body: |
|
body: |
|
||||||
{
|
{
|
||||||
|
@ -71,7 +72,7 @@ items:
|
||||||
request:
|
request:
|
||||||
api: /api.console.halo.run/v1alpha1/posts?keyword={{.param.postName}}
|
api: /api.console.halo.run/v1alpha1/posts?keyword={{.param.postName}}
|
||||||
header:
|
header:
|
||||||
Authorization: "Basic YWRtaW46MTIzNDU2"
|
Authorization: "{{.param.auth}}"
|
||||||
expect:
|
expect:
|
||||||
verify:
|
verify:
|
||||||
- data.total == 1
|
- data.total == 1
|
||||||
|
@ -80,13 +81,171 @@ items:
|
||||||
api: /api.console.halo.run/v1alpha1/posts/{{(index .listPosts.items 0).post.metadata.name}}/recycle
|
api: /api.console.halo.run/v1alpha1/posts/{{(index .listPosts.items 0).post.metadata.name}}/recycle
|
||||||
method: PUT
|
method: PUT
|
||||||
header:
|
header:
|
||||||
Authorization: "Basic YWRtaW46MTIzNDU2"
|
Authorization: "{{.param.auth}}"
|
||||||
- name: recover
|
- name: recover
|
||||||
request:
|
request:
|
||||||
api: /content.halo.run/v1alpha1/posts/{{(index .listPosts.items 0).post.metadata.name}}
|
api: /content.halo.run/v1alpha1/posts/{{(index .listPosts.items 0).post.metadata.name}}
|
||||||
method: DELETE
|
method: DELETE
|
||||||
header:
|
header:
|
||||||
Authorization: "Basic YWRtaW46MTIzNDU2"
|
Authorization: "{{.param.auth}}"
|
||||||
|
|
||||||
|
## Users
|
||||||
|
- name: createUser
|
||||||
|
request:
|
||||||
|
api: /api.console.halo.run/v1alpha1/users
|
||||||
|
method: POST
|
||||||
|
header:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
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:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
Content-Type: application/json
|
||||||
|
body: |
|
||||||
|
{
|
||||||
|
"password": "{{randAlpha 3}}"
|
||||||
|
}
|
||||||
|
- name: grantPermission
|
||||||
|
request:
|
||||||
|
api: /api.console.halo.run/v1alpha1/users/{{.param.userName}}/permissions
|
||||||
|
method: POST
|
||||||
|
header:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
Content-Type: application/json
|
||||||
|
body: |
|
||||||
|
{
|
||||||
|
"roles": [
|
||||||
|
"guest"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
- name: deleteUser
|
||||||
|
request:
|
||||||
|
api: |
|
||||||
|
{{default "http://halo:8090" (env "SERVER")}}/api/v1alpha1/users/{{.param.userName}}
|
||||||
|
method: DELETE
|
||||||
|
header:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
|
||||||
|
## Roles
|
||||||
|
- name: createRole
|
||||||
|
request:
|
||||||
|
api: |
|
||||||
|
{{default "http://halo:8090" (env "SERVER")}}/api/v1alpha1/roles
|
||||||
|
method: POST
|
||||||
|
header:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
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
|
||||||
|
header:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
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
|
||||||
|
header:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
|
||||||
|
## Plugins
|
||||||
|
- name: installPlugin
|
||||||
|
request:
|
||||||
|
api: /api.console.halo.run/v1alpha1/plugins/-/install-from-uri
|
||||||
|
method: POST
|
||||||
|
header:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
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
|
||||||
|
header:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
expect:
|
||||||
|
verify:
|
||||||
|
- data.total >= 1
|
||||||
|
- name: inActivePlugins
|
||||||
|
request:
|
||||||
|
api: /api.console.halo.run/v1alpha1/plugins?enabled=false&keyword=&page=0&size=0
|
||||||
|
header:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
expect:
|
||||||
|
verify:
|
||||||
|
- data.total == 1
|
||||||
|
- name: disablePlugin
|
||||||
|
request:
|
||||||
|
api: /api.console.halo.run/v1alpha1/plugins/PluginSitePush/plugin-state
|
||||||
|
method: PUT
|
||||||
|
header:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
Content-Type: application/json
|
||||||
|
body: |
|
||||||
|
{
|
||||||
|
"enable": false
|
||||||
|
}
|
||||||
|
- name: enablePlugin
|
||||||
|
request:
|
||||||
|
api: /api.console.halo.run/v1alpha1/plugins/PluginSitePush/plugin-state
|
||||||
|
method: PUT
|
||||||
|
header:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
Content-Type: application/json
|
||||||
|
body: |
|
||||||
|
{
|
||||||
|
"enable": true
|
||||||
|
}
|
||||||
|
- name: resetPlugin
|
||||||
|
request:
|
||||||
|
api: /api.console.halo.run/v1alpha1/plugins/PluginSitePush/reset-config
|
||||||
|
method: PUT
|
||||||
|
header:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
Content-Type: application/json
|
||||||
|
- name: uninstallPlugin
|
||||||
|
request:
|
||||||
|
api: /plugin.halo.run/v1alpha1/plugins/PluginSitePush
|
||||||
|
method: DELETE
|
||||||
|
header:
|
||||||
|
Authorization: "{{.param.auth}}"
|
||||||
|
|
||||||
# Notifications
|
# Notifications
|
||||||
- name: createNotification
|
- name: createNotification
|
||||||
|
|
Loading…
Reference in New Issue