Skip to content
Snippets Groups Projects
Commit 45c38d42 authored by Chen Liang's avatar Chen Liang
Browse files

Delete HttpTest.java

parent 4cb162ef
No related branches found
No related tags found
No related merge requests found
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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment