Commit 9675514a authored by Jean-Baptiste Nizet's avatar Jean-Baptiste Nizet
Browse files

ci: adapt the ci config now that frontend is gone

parent 01d4324a
......@@ -30,8 +30,6 @@ cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- ".gradle"
- "frontend/.gradle/"
- "frontend/node_modules/"
# PRE-BUILD
......@@ -62,20 +60,6 @@ build-loader-docker-image:
# TESTS
lint:
stage: test
tags:
- openstack
script: "./gradlew lint"
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- ".gradle"
- "frontend/.gradle/"
- "frontend/node_modules/"
test-and-sonarqube:
stage: test
tags:
......@@ -104,20 +88,19 @@ test-and-sonarqube:
policy: pull-push
paths:
- ".gradle"
- "frontend/.gradle/"
- "frontend/node_modules/"
- .sonar/cache
script:
- ./gradlew :frontend:assemble --parallel
- ./gradlew :backend:test jacocoTestReport --parallel
- find /tmp/node/*/bin -name node -exec ln -s {} /tmp/node/node \;
- export PATH="/tmp/node/:$PATH"
- ./gradlew -s sonarqube -x test
- ./gradlew test jacocoTestReport --parallel
# disable sonarqube because it apparently needs node, but I don't know why, and it can't find it anymore now that
# there is no frontend project anymore, and it takes sooooo much time to complete anyway for results that nobody
# will ever look
# - find /tmp/node/*/bin -name node -exec ln -s {} /tmp/node/node \;
# - export PATH="/tmp/node/:$PATH"
# - ./gradlew -s sonarqube -x test
artifacts:
reports:
junit:
- ./backend/build/test-results/test/TEST-*.xml
# - ./frontend/karma-junit-tests-report/TEST*.xml
only:
refs:
- merge_requests
......@@ -144,8 +127,6 @@ build:
policy: pull
paths:
- ".gradle"
- "frontend/.gradle/"
- "frontend/node_modules/"
artifacts:
paths:
- "$JAR_PATH"
......
package fr.inra.urgi.faidare.filter;
import fr.inra.urgi.faidare.Application;
import fr.inra.urgi.faidare.config.SecurityConfig;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import java.io.ByteArrayInputStream;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.forwardedUrl;
/**
* Unit tests for {@link AngularRouteFilter}
*
* @author gcornut
*/
@ExtendWith(SpringExtension.class)
@Import(SecurityConfig.class)
@SpringBootTest(classes = Application.class)
class AngularRouteFilterTest {
@Autowired
private WebApplicationContext context;
@MockBean
private ResourceLoader resourceLoader;
private MockMvc mockMvc;
private AngularRouteFilter filter;
@BeforeEach
void setUp() {
filter = new AngularRouteFilter(resourceLoader);
mockMvc = MockMvcBuilders.webAppContextSetup(context)
.addFilter(filter, "/*")
.build();
}
@ParameterizedTest
@ValueSource(strings = {
// Static files
"/index.html",
"/script.js",
"/style.css",
"/image.gif",
"/icon.ico",
"/image.png",
"/image.jpg",
"/font.woff",
"/font.ttf",
// APIs
"/brapi/v1/studies",
"/faidare/v1/datadiscovery/suggest",
"/actuator/info",
})
void shouldNotForward(String url) throws Exception {
mockMvc.perform(get(url)).andExpect(forwardedUrl(null));
}
@ParameterizedTest
@ValueSource(strings = {
"/home",
"/studies/foo",
"/germplasm/bar",
})
void shouldForward(String url) throws Exception {
String indexBefore = "<html>\n" +
" <base href=\"./\">\n" +
"</html>";
String indexAfter = "<html>\n" +
" <base href=\"/gnpis-test/faidare/\">\n" +
"</html>";
ReflectionTestUtils.setField(filter, "serverContextPath", "/gnpis-test/faidare");
Resource mockResource = mock(Resource.class);
when(mockResource.getInputStream())
.thenReturn(new ByteArrayInputStream(indexBefore.getBytes()));
when(resourceLoader.getResource(anyString()))
.thenReturn(mockResource);
mockMvc.perform(get(url))
.andExpect(content().string(indexAfter));
}
}
Markdown is supported
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