diff --git a/.github/workflows/halo.yaml b/.github/workflows/halo.yaml index 839b82f75..46418dafc 100644 --- a/.github/workflows/halo.yaml +++ b/.github/workflows/halo.yaml @@ -91,5 +91,5 @@ jobs: sudo chmod u+x /usr/local/bin/docker-compose 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 diff --git a/.gitignore b/.gitignore index c7b044088..db223874f 100755 --- a/.gitignore +++ b/.gitignore @@ -64,7 +64,6 @@ nbdist/ ### VSCode .vscode -.gitpod.yml ### Local file application-local.yml diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 000000000..512cc0ae2 --- /dev/null +++ b/.gitpod.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 diff --git a/e2e/README.md b/e2e/README.md index 6a1906111..6a9722faa 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -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 * 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` + +## Run Halo only +Please run the following command if you only want to run Halo. + +```shell +docker-compose up halo +``` diff --git a/e2e/compose.yaml b/e2e/compose.yaml index 74e703d88..7e8cb99f6 100644 --- a/e2e/compose.yaml +++ b/e2e/compose.yaml @@ -10,7 +10,7 @@ services: halo: condition: service_healthy halo: - image: ghcr.io/halo-dev/halo-dev:dev + image: ghcr.io/halo-dev/halo-dev:${TAG:-main} healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8090/actuator/health/readiness"] interval: 30s @@ -25,6 +25,8 @@ services: - --spring.sql.init.platform=postgresql # 外部访问地址,请根据实际需要修改 # - --halo.external-url=http://localhost:8090/ + ports: + - 8090:8090 links: - postgresql depends_on: diff --git a/e2e/testsuite.yaml b/e2e/testsuite.yaml index fac4fd4ed..19b3c9681 100644 --- a/e2e/testsuite.yaml +++ b/e2e/testsuite.yaml @@ -4,6 +4,7 @@ api: | param: postName: "{{randAlpha 6}}" userName: "{{randAlpha 6}}" + roleName: "{{randAlpha 6}}" notificationName: "{{randAlpha 6}}" auth: "Basic YWRtaW46MTIzNDU2" items: @@ -28,7 +29,7 @@ items: api: /api.console.halo.run/v1alpha1/posts method: POST header: - Authorization: "Basic YWRtaW46MTIzNDU2" + Authorization: "{{.param.auth}}" Content-Type: application/json body: | { @@ -71,7 +72,7 @@ items: request: api: /api.console.halo.run/v1alpha1/posts?keyword={{.param.postName}} header: - Authorization: "Basic YWRtaW46MTIzNDU2" + Authorization: "{{.param.auth}}" expect: verify: - data.total == 1 @@ -80,13 +81,171 @@ items: api: /api.console.halo.run/v1alpha1/posts/{{(index .listPosts.items 0).post.metadata.name}}/recycle method: PUT header: - Authorization: "Basic YWRtaW46MTIzNDU2" + Authorization: "{{.param.auth}}" - name: recover request: api: /content.halo.run/v1alpha1/posts/{{(index .listPosts.items 0).post.metadata.name}} method: DELETE 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 - name: createNotification