Skip to content
Snippets Groups Projects
Commit 745646fc authored by Christoph Thelen's avatar Christoph Thelen
Browse files

Fix #41: Use test specific properties file

parent 55d6e302
Branches
1 merge request!132Resolve "Tests should not use env specific arsnova.properties"
Pipeline #26830 passed with warnings with stages
in 1 minute and 4 seconds
This commit is part of merge request !132. Comments created here will be created in the context of that merge request.
......@@ -21,12 +21,17 @@ import de.thm.arsnova.connector.client.ConnectorClient;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@RunWith(SpringJUnit4ClassRunner.class)
......@@ -43,9 +48,18 @@ public class AppConfigTest extends AbstractJUnit4SpringContextTests {
@Autowired(required = false)
private ConnectorClient connectorClient;
@Value("${security.admin-accounts}") private String[] adminAccounts;
@Test
public void testShouldNotLoadConnectorClientByDefault() {
assertNull(connectorClient);
}
@Test
public void testShouldUseAdminAccountFromTestPropertiesFile() {
List<String> expected = Arrays.asList("TestAdmin");
List<String> actual = Arrays.asList(adminAccounts);
assertEquals("Configuration did not load correct property file", expected, actual);
}
}
......@@ -59,9 +59,8 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@EnableSpringConfigured
@EnableWebMvc
@PropertySource(
value = {"classpath:arsnova.properties.example", "file:/etc/arsnova/arsnova.properties"},
ignoreResourceNotFound = true,
encoding = "UTF-8"
value = "classpath:arsnova.test.properties.example",
encoding = "UTF-8"
)
@Profile("test")
public class TestAppConfig {
......
......@@ -98,7 +98,7 @@ public class JsonViewControllerAdviceTest {
}
@Test
@WithMockUser("Admin")
@WithMockUser("TestAdmin")
public void testShouldSerializeAdminViewForAdmin() throws Exception {
logger.info("Auth: {}", SecurityContextHolder.getContext().getAuthentication());
mockMvc.perform(get("/dummy/1?view=admin").accept(MediaType.APPLICATION_JSON))
......@@ -107,7 +107,7 @@ public class JsonViewControllerAdviceTest {
}
@Test
@WithMockUser("Admin")
@WithMockUser("TestAdmin")
public void testShouldSerializeOwnerViewForAdmin() throws Exception {
logger.info("Auth: {}", SecurityContextHolder.getContext().getAuthentication());
mockMvc.perform(get("/dummy/1?view=owner").accept(MediaType.APPLICATION_JSON))
......@@ -116,7 +116,7 @@ public class JsonViewControllerAdviceTest {
}
@Test
@WithMockUser("Admin")
@WithMockUser("TestAdmin")
public void testAdminViewShouldContainAdminProperties() throws Exception {
logger.info("Auth: {}", SecurityContextHolder.getContext().getAuthentication());
mockMvc.perform(get("/dummy/1?view=admin").accept(MediaType.APPLICATION_JSON))
......@@ -127,7 +127,7 @@ public class JsonViewControllerAdviceTest {
}
@Test
@WithMockUser("Admin")
@WithMockUser("TestAdmin")
public void testOwnerViewShouldContainOwnerProperties() throws Exception {
logger.info("Auth: {}", SecurityContextHolder.getContext().getAuthentication());
mockMvc.perform(get("/dummy/1?view=owner").accept(MediaType.APPLICATION_JSON))
......@@ -138,7 +138,7 @@ public class JsonViewControllerAdviceTest {
}
@Test
@WithMockUser("Admin")
@WithMockUser("TestAdmin")
public void testDefaultViewShouldContainPublicProperties() throws Exception {
logger.info("Auth: {}", SecurityContextHolder.getContext().getAuthentication());
mockMvc.perform(get("/dummy/1").accept(MediaType.APPLICATION_JSON))
......
......@@ -30,7 +30,7 @@ socketio.port=8090
# Admin accounts
# Usernames of the accounts which are allowed to manage global messages of the
# day. Multiple accounts are separated by commas.
security.admin-accounts=Admin
security.admin-accounts=TestAdmin
################################################################################
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment