From 45c38d42413ac39b0216c57aead1f4d6ac756111 Mon Sep 17 00:00:00 2001 From: Chen Liang <liangc13@cardiff.ac.uk> Date: Mon, 7 Apr 2025 06:49:14 +0000 Subject: [PATCH] Delete HttpTest.java --- .../java/com/cardiff/wylTest/HttpTest.java | 56 ------------------- 1 file changed, 56 deletions(-) delete mode 100644 src/test/java/com/cardiff/wylTest/HttpTest.java diff --git a/src/test/java/com/cardiff/wylTest/HttpTest.java b/src/test/java/com/cardiff/wylTest/HttpTest.java deleted file mode 100644 index 6338d11..0000000 --- a/src/test/java/com/cardiff/wylTest/HttpTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.cardiff.wylTest; - -import com.cardiff.client_project.utils.Result; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.http.ResponseEntity; - -import java.util.HashMap; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -public class HttpTest { - @Value(value="${local.server.port}") - private int port; - - @Autowired - private TestRestTemplate restTemplate; - - @Test - public void testFaultPage() throws Exception { - assertThat(this.restTemplate.getForObject("http://localhost:" + port + "/fault.html", - String.class)).contains("You do not have sufficient access rights, the page will be redirected to the login page within"); - } - - - @Test - public void testLoginPage() throws Exception { - assertThat(this.restTemplate.getForObject("http://localhost:" + port + "/login.html", - String.class)).contains("Verification code"); - } - - @Test - public void testLogin() throws Exception { - String loginUrl = "http://localhost:" + port + "/superAdmin/sign"; - - - Map<String, String> loginData = new HashMap<>(); - loginData.put("name", "2649783657@qq.com"); - loginData.put("password", "admin"); - loginData.put("role","super"); - loginData.put("status","1"); - - - - ResponseEntity<Result> loginResponse = this.restTemplate.postForEntity(loginUrl, loginData, Result.class); - assertThat(loginResponse.getStatusCode().value()).isEqualTo(200); - - - } - -} -- GitLab