add blocked server test
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Failing after 15s

This commit is contained in:
Lee
2024-04-10 14:39:12 +01:00
parent 9d846dec1d
commit de338fed82
3 changed files with 12 additions and 4 deletions

View File

@ -0,0 +1,63 @@
package cc.fascinated.tests;
import cc.fascinated.model.player.Skin;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@AutoConfigureMockMvc
@SpringBootTest(classes = TestRedisConfig.class)
class PlayerControllerTests {
@Autowired
private MockMvc mockMvc;
@Test
public void ensurePlayerLookupUuidSuccess() throws Exception {
mockMvc.perform(get("/player/eeab5f8a-18dd-4d58-af78-2b3c4543da48")
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.username").value("ImFascinated"));
}
@Test
public void ensurePlayerLookupUsernameSuccess() throws Exception {
mockMvc.perform(get("/player/ImFascinated")
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.username").value("ImFascinated"));
}
@Test
public void ensurePlayerLookupFailure() throws Exception {
mockMvc.perform(get("/player/invalidnamehahahahahayesslmaooo")
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isNotFound());
}
@Test
public void ensurePlayerSkinPartsLookupSuccess() throws Exception {
for (Skin.Parts part : Skin.Parts.values()) {
mockMvc.perform(get("/player/" + part.getName() + "/eeab5f8a-18dd-4d58-af78-2b3c4543da48")
.accept(MediaType.IMAGE_PNG)
.contentType(MediaType.IMAGE_PNG))
.andExpect(status().isOk());
}
}
@Test
public void ensurePlayerSkinPartsLookupFailure() throws Exception {
mockMvc.perform(get("/player/invalidpart/eeab5f8a-18dd-4d58-af78-2b3c4543da48"))
.andExpect(status().isBadRequest());
}
}