Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs-test-DisplayName补充 #1

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/test/java/net/ximatai/muyun/gateway/TestFrontend.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.ximatai.muyun.gateway.config.model.GatewayConfig;
import net.ximatai.muyun.gateway.handler.FrontendHandler;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.io.IOException;
Expand Down Expand Up @@ -33,6 +34,7 @@ public TestFrontend() throws IOException {
}

@Test
@DisplayName("测试前端访问 index.html 文件")
public void testFrontend() {
FrontendHandler frontendHandler = new FrontendHandler("/test", tempDirectory.toAbsolutePath().toString(), null, false, false, null, List.of(), List.of());

Expand All @@ -49,6 +51,7 @@ public void testFrontend() {
}

@Test
@DisplayName("测试前端根路径访问")
public void testFrontendIndex() {
FrontendHandler frontendHandler = new FrontendHandler("/test", tempDirectory.toAbsolutePath().toString(), null, false, false, null, List.of(), List.of());

Expand All @@ -65,6 +68,7 @@ public void testFrontendIndex() {
}

@Test
@DisplayName("测试前端未找到资源时重定向到默认页面")
public void testFrontendNotFoundReroute() {
FrontendHandler frontendHandler = new FrontendHandler("/test", tempDirectory.toAbsolutePath().toString(), "/", false, false, null, List.of(), List.of());

Expand All @@ -81,6 +85,7 @@ public void testFrontendNotFoundReroute() {
}

@Test
@DisplayName("测试前端未找到资源时返回 404 状态码")
public void testFrontend404() {
FrontendHandler frontendHandler = new FrontendHandler("/test", tempDirectory.toAbsolutePath().toString(), null, false, false, null, List.of(), List.of());

Expand All @@ -96,6 +101,7 @@ public void testFrontend404() {
}

@Test
@DisplayName("测试前端安全模式下访问根路径重定向到登录页面")
public void testFrontendSecured() {
FrontendHandler frontendHandler = new FrontendHandler("/test", tempDirectory.toAbsolutePath().toString(), null, true, false, null, List.of(), List.of());

Expand All @@ -110,6 +116,7 @@ public void testFrontendSecured() {
}

@Test
@DisplayName("测试前端安全模式下允许特定路径访问")
public void testFrontendSecuredAllow() {
FrontendHandler frontendHandler = new FrontendHandler("/test", tempDirectory.toAbsolutePath().toString(), null, true, false, null, List.of(), List.of(
"/xxx",
Expand Down Expand Up @@ -140,6 +147,7 @@ public void testFrontendSecuredAllow() {
}

@Test
@DisplayName("测试前端安全模式下 AJAX 请求返回 401 状态码")
public void testFrontendSecuredLikeAjax() {
FrontendHandler frontendHandler = new FrontendHandler("/test", tempDirectory.toAbsolutePath().toString(), null, true, false, null, List.of(), List.of());

Expand All @@ -153,6 +161,7 @@ public void testFrontendSecuredLikeAjax() {
}

@Test
@DisplayName("测试前端响应压缩")
public void testFrontendCompression() {
FrontendHandler frontendHandler = new FrontendHandler("/test", tempDirectory.toAbsolutePath().toString(), null, false, false, null, List.of(), List.of());

Expand All @@ -170,6 +179,7 @@ public void testFrontendCompression() {
}

@Test
@DisplayName("测试前端响应不缓存根路径")
public void testFrontendNoCache() {
FrontendHandler frontendHandler = new FrontendHandler("/test", tempDirectory.toAbsolutePath().toString(), null, false, false, null, List.of("/"), List.of());

Expand All @@ -187,6 +197,7 @@ public void testFrontendNoCache() {
}

@Test
@DisplayName("测试前端响应不缓存特定路径")
public void testFrontendNoCacheRegex() {
FrontendHandler frontendHandler = new FrontendHandler("/test", tempDirectory.toAbsolutePath().toString(), null, false, false, null, List.of("/", "/test.*"), List.of());

Expand Down
3 changes: 3 additions & 0 deletions src/test/java/net/ximatai/muyun/gateway/TestSecurity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.ximatai.muyun.gateway;

import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;
Expand All @@ -9,6 +10,7 @@
public class TestSecurity {

@Test
@DisplayName("测试未授权访问 /api/config 返回 401 状态码")
public void testSecurityBad() {
given()
.get("/api/config")
Expand All @@ -18,6 +20,7 @@ public void testSecurityBad() {
}

@Test
@DisplayName("测试带有有效 token 的访问 /api/config 返回 200 状态码")
public void testSecurityOk() {
String token = GatewayServer.token;
given()
Expand Down
Loading