diff --git a/airsonic-main/src/test/java/org/airsonic/player/controller/InternalHelpControllerIntTest.java b/airsonic-main/src/test/java/org/airsonic/player/controller/InternalHelpControllerIntTest.java new file mode 100644 index 00000000..66dcb83e --- /dev/null +++ b/airsonic-main/src/test/java/org/airsonic/player/controller/InternalHelpControllerIntTest.java @@ -0,0 +1,44 @@ +package org.airsonic.player.controller; + +import org.airsonic.player.util.HomeRule; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.runner.RunWith; +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.security.test.context.support.WithMockUser; +import org.springframework.test.context.junit4.SpringRunner; +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.status; + +@RunWith(SpringRunner.class) +@SpringBootTest +@AutoConfigureMockMvc +public class InternalHelpControllerIntTest { + + @Autowired + private MockMvc mvc; + + @ClassRule + public static final HomeRule classRule = new HomeRule(); // sets airsonic.home to a temporary dir + + @Test + @WithMockUser(username = "admin", roles = {"USER", "ADMIN"}) + public void testOkForAdmins() throws Exception { + mvc.perform(get("/internalhelp") + .contentType(MediaType.TEXT_HTML)) + .andExpect(status().isOk()); + } + + @Test + @WithMockUser(username = "user", roles = {"USER"}) + public void testNotOkForUsers() throws Exception { + mvc.perform(get("/internalhelp") + .contentType(MediaType.TEXT_HTML)) + .andExpect(status().isForbidden()); + } +}