You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.6 KiB
44 lines
1.6 KiB
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());
|
|
}
|
|
}
|
|
|