diff --git a/lapis2/src/main/kotlin/org/genspectrum/lapis/auth/DataOpennessAuthorizationFilter.kt b/lapis2/src/main/kotlin/org/genspectrum/lapis/auth/DataOpennessAuthorizationFilter.kt index c0627684..fa619ff3 100644 --- a/lapis2/src/main/kotlin/org/genspectrum/lapis/auth/DataOpennessAuthorizationFilter.kt +++ b/lapis2/src/main/kotlin/org/genspectrum/lapis/auth/DataOpennessAuthorizationFilter.kt @@ -103,7 +103,7 @@ private class ProtectedDataAuthorizationFilter( AMINO_ACID_MUTATIONS_ROUTE, NUCLEOTIDE_INSERTIONS_ROUTE, AMINO_ACID_INSERTIONS_ROUTE, - ) + ).map { "/sample$it" } } override fun isAuthorizedForEndpoint(request: CachedBodyHttpServletRequest): AuthorizationResult { diff --git a/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/LapisController.kt b/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/LapisController.kt index 74aa0d6e..3c83a9a1 100644 --- a/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/LapisController.kt +++ b/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/LapisController.kt @@ -57,6 +57,7 @@ import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @@ -70,6 +71,7 @@ const val ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE = "/alignedNucleotideSequences" const val ALIGNED_AMINO_ACID_SEQUENCES_ROUTE = "/alignedAminoAcidSequences" @RestController +@RequestMapping("/sample") class LapisController( private val siloQueryModel: SiloQueryModel, private val requestContext: RequestContext, diff --git a/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/MultiSegmentedSequenceController.kt b/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/MultiSegmentedSequenceController.kt index 2deb827d..d1243a40 100644 --- a/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/MultiSegmentedSequenceController.kt +++ b/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/MultiSegmentedSequenceController.kt @@ -27,6 +27,7 @@ import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @@ -35,6 +36,7 @@ const val IS_MULTI_SEGMENT_SEQUENCE_EXPRESSION = @RestController @ConditionalOnExpression(IS_MULTI_SEGMENT_SEQUENCE_EXPRESSION) +@RequestMapping("/sample") class MultiSegmentedSequenceController( private val siloQueryModel: SiloQueryModel, private val requestContext: RequestContext, diff --git a/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/SingleSegmentedSequenceController.kt b/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/SingleSegmentedSequenceController.kt index 2d01f9b4..368a278d 100644 --- a/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/SingleSegmentedSequenceController.kt +++ b/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/SingleSegmentedSequenceController.kt @@ -27,6 +27,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @@ -35,6 +36,7 @@ const val IS_SINGLE_SEGMENT_SEQUENCE_EXPRESSION = @RestController @ConditionalOnExpression(IS_SINGLE_SEGMENT_SEQUENCE_EXPRESSION) +@RequestMapping("/sample") class SingleSegmentedSequenceController( private val siloQueryModel: SiloQueryModel, private val requestContext: RequestContext, diff --git a/lapis2/src/test/kotlin/org/genspectrum/lapis/SwaggerUiTest.kt b/lapis2/src/test/kotlin/org/genspectrum/lapis/SwaggerUiTest.kt index b34b660f..10676ec2 100644 --- a/lapis2/src/test/kotlin/org/genspectrum/lapis/SwaggerUiTest.kt +++ b/lapis2/src/test/kotlin/org/genspectrum/lapis/SwaggerUiTest.kt @@ -34,7 +34,7 @@ class SwaggerUiTest( .andExpect(status().isOk) .andExpect(content().contentType("application/json")) .andExpect(jsonPath("\$.openapi").exists()) - .andExpect(jsonPath("\$.paths./aggregated").exists()) + .andExpect(jsonPath("\$.paths./sample/aggregated").exists()) } @Test @@ -47,6 +47,6 @@ class SwaggerUiTest( val objectMapper = ObjectMapper(YAMLFactory()).registerKotlinModule() val yaml = objectMapper.readTree(result.response.contentAsString) assertTrue(yaml.has("openapi")) - assertTrue(yaml.get("paths").has("/aggregated")) + assertTrue(yaml.get("paths").has("/sample/aggregated")) } } diff --git a/lapis2/src/test/kotlin/org/genspectrum/lapis/auth/ProtectedDataAuthorizationTest.kt b/lapis2/src/test/kotlin/org/genspectrum/lapis/auth/ProtectedDataAuthorizationTest.kt index 22558b7c..685faccb 100644 --- a/lapis2/src/test/kotlin/org/genspectrum/lapis/auth/ProtectedDataAuthorizationTest.kt +++ b/lapis2/src/test/kotlin/org/genspectrum/lapis/auth/ProtectedDataAuthorizationTest.kt @@ -5,6 +5,8 @@ import io.mockk.MockKAnnotations import io.mockk.every import io.mockk.verify import org.genspectrum.lapis.controller.AGGREGATED_ROUTE +import org.genspectrum.lapis.controller.getSample +import org.genspectrum.lapis.controller.postSample import org.genspectrum.lapis.model.SiloQueryModel import org.genspectrum.lapis.request.LapisInfo import org.genspectrum.lapis.request.SequenceFiltersRequestWithFields @@ -15,7 +17,6 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.MediaType import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -24,7 +25,16 @@ private const val NOT_AUTHORIZED_TO_ACCESS_ENDPOINT_ERROR = """ { "error" : { "title": "Forbidden", - "detail": "You are not authorized to access /aggregated." + "detail": "You are not authorized to access /sample/aggregated." + } +} +""" + +private const val FORBIDDEN_TO_ACCESS_ENDPOINT_ERROR = """ +{ + "error" : { + "title": "Forbidden", + "detail": "An access key is required to access /sample/aggregated." } } """ @@ -55,21 +65,10 @@ class ProtectedDataAuthorizationTest( @Test fun `given no access key in GET request to protected instance, then access is denied`() { - mockMvc.perform(get(validRoute)) + mockMvc.perform(getSample(validRoute)) .andExpect(status().isForbidden) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andExpect( - content().json( - """ - { - "error" : { - "title": "Forbidden", - "detail": "An access key is required to access /aggregated." - } - } - """, - ), - ) + .andExpect(content().json(FORBIDDEN_TO_ACCESS_ENDPOINT_ERROR)) } @Test @@ -77,30 +76,15 @@ class ProtectedDataAuthorizationTest( mockMvc.perform(postRequestWithBody("")) .andExpect(status().isForbidden) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andExpect( - content().json( - """ - { - "error" : { - "title": "Forbidden", - "detail": "An access key is required to access /aggregated." - } - } - """, - ), - ) + .andExpect(content().json(FORBIDDEN_TO_ACCESS_ENDPOINT_ERROR)) } @Test fun `given wrong access key in GET request to protected instance, then access is denied`() { - mockMvc.perform(get("$validRoute?accessKey=invalidKey")) + mockMvc.perform(getSample("$validRoute?accessKey=invalidKey")) .andExpect(status().isForbidden) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andExpect( - content().json( - NOT_AUTHORIZED_TO_ACCESS_ENDPOINT_ERROR, - ), - ) + .andExpect(content().json(NOT_AUTHORIZED_TO_ACCESS_ENDPOINT_ERROR)) } @Test @@ -108,17 +92,13 @@ class ProtectedDataAuthorizationTest( mockMvc.perform(postRequestWithBody("""{"accessKey": "invalidKey"}""")) .andExpect(status().isForbidden) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andExpect( - content().json( - NOT_AUTHORIZED_TO_ACCESS_ENDPOINT_ERROR, - ), - ) + .andExpect(content().json(NOT_AUTHORIZED_TO_ACCESS_ENDPOINT_ERROR)) } @Test fun `given valid access key for aggregated data in GET request to protected instance, then access is granted`() { mockMvc.perform( - get("$validRoute?accessKey=testAggregatedDataAccessKey&field1=value1"), + getSample("$validRoute?accessKey=testAggregatedDataAccessKey&field1=value1"), ) .andExpect(status().isOk) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) @@ -145,7 +125,7 @@ class ProtectedDataAuthorizationTest( @Test fun `given aggregated access key in GET request but filters are too fine-grained, then access is denied`() { mockMvc.perform( - get("$validRoute?accessKey=testAggregatedDataAccessKey&gisaid_epi_isl=value"), + getSample("$validRoute?accessKey=testAggregatedDataAccessKey&gisaid_epi_isl=value"), ) .andExpect(status().isForbidden) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) @@ -170,7 +150,7 @@ class ProtectedDataAuthorizationTest( @Test fun `given valid access key for full access in GET request to protected instance, then access is granted`() { mockMvc.perform( - get("$validRoute?accessKey=testFullAccessKey&field1=value1"), + getSample("$validRoute?accessKey=testFullAccessKey&field1=value1"), ) .andExpect(status().isOk) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) @@ -217,7 +197,7 @@ class ProtectedDataAuthorizationTest( } private fun postRequestWithBody(body: String) = - MockMvcRequestBuilders.post(validRoute) + postSample(validRoute) .contentType(MediaType.APPLICATION_JSON) .content(body) } diff --git a/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/ExceptionHandlerTest.kt b/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/ExceptionHandlerTest.kt index dc8758de..9f1c9117 100644 --- a/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/ExceptionHandlerTest.kt +++ b/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/ExceptionHandlerTest.kt @@ -59,7 +59,7 @@ class ExceptionHandlerTest( fun `throw INTERNAL_SERVER_ERROR(500) with additional info for any non specific error`() { every { validControllerCall() } throws Exception("SomeMessage") - mockMvc.perform(get(validRoute)) + mockMvc.perform(getSample(validRoute)) .andExpect(status().isInternalServerError) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect( @@ -83,7 +83,7 @@ class ExceptionHandlerTest( fun `Passes through exception with status code from SILO`() { every { validControllerCall() } throws SiloException(123, "SomeTitle", "SomeMessage") - mockMvc.perform(get(validRoute)) + mockMvc.perform(getSample(validRoute)) .andExpect(status().`is`(123)) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect( @@ -107,7 +107,7 @@ class ExceptionHandlerTest( fun `throw BAD_REQUEST(400) with additional info for bad requests`() { every { validControllerCall() } throws BadRequestException("SomeMessage") - mockMvc.perform(get(validRoute)) + mockMvc.perform(getSample(validRoute)) .andExpect(status().isBadRequest) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect( @@ -131,7 +131,7 @@ class ExceptionHandlerTest( fun `throw NOT_IMPLEMENTED(501) with additional info for request of a not implemented resource in SILO`() { every { validControllerCall() } throws SiloNotImplementedError("SomeMessage", Exception("SomeCause")) - mockMvc.perform(get(validRoute)) + mockMvc.perform(getSample(validRoute)) .andExpect(status().isNotImplemented) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect( diff --git a/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/LapisControllerCommonFieldsTest.kt b/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/LapisControllerCommonFieldsTest.kt index 8b076e22..d9945566 100644 --- a/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/LapisControllerCommonFieldsTest.kt +++ b/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/LapisControllerCommonFieldsTest.kt @@ -22,8 +22,6 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.MediaType import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -61,7 +59,7 @@ class LapisControllerCommonFieldsTest( ) } returns listOf(AggregationData(0, mapOf("country" to TextNode("Switzerland")))) - mockMvc.perform(get("$AGGREGATED_ROUTE?orderBy=country")) + mockMvc.perform(getSample("$AGGREGATED_ROUTE?orderBy=country")) .andExpect(status().isOk) .andExpect(jsonPath("\$.data[0].count").value(0)) .andExpect(jsonPath("\$.data[0].country").value("Switzerland")) @@ -83,7 +81,7 @@ class LapisControllerCommonFieldsTest( ) } returns listOf(AggregationData(0, mapOf("country" to TextNode("Switzerland")))) - mockMvc.perform(get("$AGGREGATED_ROUTE?orderBy=country,date")) + mockMvc.perform(getSample("$AGGREGATED_ROUTE?orderBy=country,date")) .andExpect(status().isOk) .andExpect(jsonPath("\$.data[0].count").value(0)) .andExpect(jsonPath("\$.data[0].country").value("Switzerland")) @@ -105,7 +103,7 @@ class LapisControllerCommonFieldsTest( ) } returns listOf(AggregationData(0, mapOf("country" to TextNode("Switzerland")))) - val request = post(AGGREGATED_ROUTE) + val request = postSample(AGGREGATED_ROUTE) .content("""{"orderBy": ["country", "date"]}""") .contentType(MediaType.APPLICATION_JSON) @@ -134,7 +132,7 @@ class LapisControllerCommonFieldsTest( ) } returns listOf(AggregationData(0, mapOf("country" to TextNode("Switzerland")))) - val request = post(AGGREGATED_ROUTE) + val request = postSample(AGGREGATED_ROUTE) .content( """ { @@ -155,7 +153,7 @@ class LapisControllerCommonFieldsTest( @Test fun `POST aggregated with invalid orderBy fields`() { - val request = post("$AGGREGATED_ROUTE") + val request = postSample(AGGREGATED_ROUTE) .content("""{"orderBy": [ { "field": ["this is an array, not a string"] } ]}""") .contentType(MediaType.APPLICATION_JSON) @@ -181,7 +179,7 @@ class LapisControllerCommonFieldsTest( ) } returns listOf(AggregationData(0, mapOf("country" to TextNode("Switzerland")))) - mockMvc.perform(get("$AGGREGATED_ROUTE?limit=100")) + mockMvc.perform(getSample("$AGGREGATED_ROUTE?limit=100")) .andExpect(status().isOk) .andExpect(jsonPath("\$.data[0].count").value(0)) .andExpect(jsonPath("\$.data[0].country").value("Switzerland")) @@ -204,7 +202,7 @@ class LapisControllerCommonFieldsTest( ) } returns listOf(AggregationData(0, mapOf("country" to TextNode("Switzerland")))) - val request = post(AGGREGATED_ROUTE) + val request = postSample(AGGREGATED_ROUTE) .content("""{"limit": 100}""") .contentType(MediaType.APPLICATION_JSON) @@ -215,7 +213,7 @@ class LapisControllerCommonFieldsTest( @Test fun `POST aggregated with invalid limit`() { - val request = post(AGGREGATED_ROUTE) + val request = postSample(AGGREGATED_ROUTE) .content("""{"limit": "this is not a number"}""") .contentType(MediaType.APPLICATION_JSON) @@ -242,7 +240,7 @@ class LapisControllerCommonFieldsTest( ) } returns listOf(AggregationData(0, mapOf("country" to TextNode("Switzerland")))) - mockMvc.perform(get("$AGGREGATED_ROUTE?offset=5")) + mockMvc.perform(getSample("$AGGREGATED_ROUTE?offset=5")) .andExpect(status().isOk) .andExpect(jsonPath("\$.data[0].count").value(0)) .andExpect(jsonPath("\$.data[0].country").value("Switzerland")) @@ -266,7 +264,7 @@ class LapisControllerCommonFieldsTest( ) } returns listOf(AggregationData(0, mapOf("country" to TextNode("Switzerland")))) - val request = post(AGGREGATED_ROUTE) + val request = postSample(AGGREGATED_ROUTE) .content("""{"offset": 5}""") .contentType(MediaType.APPLICATION_JSON) @@ -277,7 +275,7 @@ class LapisControllerCommonFieldsTest( @Test fun `POST aggregated with invalid offset`() { - val request = post(AGGREGATED_ROUTE) + val request = postSample(AGGREGATED_ROUTE) .content("""{"offset": "this is not a number"}""") .contentType(MediaType.APPLICATION_JSON) @@ -301,7 +299,7 @@ class LapisControllerCommonFieldsTest( ) } returns listOf(AggregationData(5, emptyMap())) - mockMvc.perform(get("$AGGREGATED_ROUTE?nucleotideInsertions=ins_123:ABC,ins_segment:124:DEF")) + mockMvc.perform(getSample("$AGGREGATED_ROUTE?nucleotideInsertions=ins_123:ABC,ins_segment:124:DEF")) .andExpect(status().isOk) .andExpect(jsonPath("\$.data[0].count").value(5)) } @@ -321,7 +319,7 @@ class LapisControllerCommonFieldsTest( ) } returns listOf(AggregationData(5, emptyMap())) - mockMvc.perform(get("$AGGREGATED_ROUTE?aminoAcidInsertions=ins_S:123:ABC,ins_ORF1:124:DEF")) + mockMvc.perform(getSample("$AGGREGATED_ROUTE?aminoAcidInsertions=ins_S:123:ABC,ins_ORF1:124:DEF")) .andExpect(status().isOk) .andExpect(jsonPath("\$.data[0].count").value(5)) } @@ -329,7 +327,7 @@ class LapisControllerCommonFieldsTest( @ParameterizedTest(name = "GET {0} with invalid nucleotide mutation") @MethodSource("getEndpointsWithNucleotideMutationFilter") fun `GET endpoint with invalid nucleotide mutation filter`(endpoint: String) { - mockMvc.perform(get("$endpoint?nucleotideMutations=invalidMutation")) + mockMvc.perform(getSample("$endpoint?nucleotideMutations=invalidMutation")) .andExpect(status().isBadRequest) .andExpect(jsonPath("\$.detail").value(Matchers.containsString("Failed to convert 'nucleotideMutations'"))) } @@ -337,7 +335,7 @@ class LapisControllerCommonFieldsTest( @ParameterizedTest(name = "GET {0} with invalid nucleotide mutation") @MethodSource("getEndpointsWithAminoAcidMutationFilter") fun `GET endpoind with invalid amino acid mutation`(endpoint: String) { - mockMvc.perform(get("$endpoint?aminoAcidMutations=invalidMutation")) + mockMvc.perform(getSample("$endpoint?aminoAcidMutations=invalidMutation")) .andExpect(status().isBadRequest) .andExpect(jsonPath("\$.detail").value(Matchers.containsString("Failed to convert 'aminoAcidMutations'"))) } @@ -345,7 +343,7 @@ class LapisControllerCommonFieldsTest( @ParameterizedTest(name = "GET {0} with invalid nucleotideInsertion") @MethodSource("getEndpointsWithInsertionFilter") fun `GET with invalid nucleotide insertion filter`(endpoint: String) { - mockMvc.perform(get(endpoint + "?nucleotideInsertions=invalidInsertion")) + mockMvc.perform(getSample("$endpoint?nucleotideInsertions=invalidInsertion")) .andExpect(status().isBadRequest) .andExpect(jsonPath("\$.detail").value(Matchers.containsString("Failed to convert 'nucleotideInsertions'"))) } @@ -353,7 +351,7 @@ class LapisControllerCommonFieldsTest( @ParameterizedTest(name = "GET {0} with invalid aminoAcidInsertion") @MethodSource("getEndpointsWithInsertionFilter") fun `GET with invalid amino acid insertionFilter`(endpoint: String) { - mockMvc.perform(get(endpoint + "?aminoAcidInsertions=invalidInsertion")) + mockMvc.perform(getSample("$endpoint?aminoAcidInsertions=invalidInsertion")) .andExpect(status().isBadRequest) .andExpect(jsonPath("\$.detail").value(Matchers.containsString("Failed to convert 'aminoAcidInsertions'"))) } diff --git a/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/LapisControllerCsvTest.kt b/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/LapisControllerCsvTest.kt index 6c53615d..49185832 100644 --- a/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/LapisControllerCsvTest.kt +++ b/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/LapisControllerCsvTest.kt @@ -24,8 +24,6 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.MediaType import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content import org.springframework.test.web.servlet.result.MockMvcResultMatchers.header import org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath @@ -54,7 +52,7 @@ class LapisControllerCsvTest( fun `GET returns empty json`(endpoint: String) { mockEndpointReturnEmptyList(endpoint) - mockMvc.perform(get("$endpoint?country=Switzerland")) + mockMvc.perform(getSample("$endpoint?country=Switzerland")) .andExpect(status().isOk) .andExpect(header().string("Content-Type", "application/json")) .andExpect(jsonPath("\$.data").isEmpty()) @@ -65,7 +63,7 @@ class LapisControllerCsvTest( fun `POST returns empty json`(endpoint: String) { mockEndpointReturnEmptyList(endpoint) - val request = post(endpoint) + val request = postSample(endpoint) .content("""{"country": "Switzerland"}""") .contentType(MediaType.APPLICATION_JSON) .accept("application/json") @@ -81,7 +79,7 @@ class LapisControllerCsvTest( fun `GET returns empty CSV`(endpoint: String) { mockEndpointReturnEmptyList(endpoint) - mockMvc.perform(get("$endpoint?country=Switzerland").header("Accept", "text/csv")) + mockMvc.perform(getSample("$endpoint?country=Switzerland").header("Accept", "text/csv")) .andExpect(status().isOk) .andExpect(header().string("Content-Type", "text/csv;charset=UTF-8")) .andExpect(content().string("")) @@ -92,7 +90,7 @@ class LapisControllerCsvTest( fun `POST {0} returns empty CSV`(endpoint: String) { mockEndpointReturnEmptyList(endpoint) - val request = post(endpoint) + val request = postSample(endpoint) .content("""{"country": "Switzerland"}""") .contentType(MediaType.APPLICATION_JSON) .accept("text/csv") @@ -108,7 +106,7 @@ class LapisControllerCsvTest( fun `GET returns as CSV with accept header`(endpoint: String) { mockEndpointReturnData(endpoint) - mockMvc.perform(get("$endpoint?country=Switzerland").header("Accept", "text/csv")) + mockMvc.perform(getSample("$endpoint?country=Switzerland").header("Accept", "text/csv")) .andExpect(status().isOk) .andExpect(header().string("Content-Type", "text/csv;charset=UTF-8")) .andExpect(content().string(returnedCsvData(endpoint))) @@ -119,7 +117,7 @@ class LapisControllerCsvTest( fun `POST returns as CSV with accept header`(endpoint: String) { mockEndpointReturnData(endpoint) - val request = post(endpoint) + val request = postSample(endpoint) .content("""{"country": "Switzerland"}""") .contentType(MediaType.APPLICATION_JSON) .accept("text/csv") @@ -135,7 +133,7 @@ class LapisControllerCsvTest( fun `GET returns as CSV with request parameter`(endpoint: String) { mockEndpointReturnData(endpoint) - mockMvc.perform(get("$endpoint?country=Switzerland&dataFormat=csv")) + mockMvc.perform(getSample("$endpoint?country=Switzerland&dataFormat=csv")) .andExpect(status().isOk) .andExpect(header().string("Content-Type", "text/csv;charset=UTF-8")) .andExpect(content().string(returnedCsvData(endpoint))) @@ -146,7 +144,7 @@ class LapisControllerCsvTest( fun `POST returns as CSV with request parameter`(endpoint: String) { mockEndpointReturnData(endpoint) - val request = post(endpoint) + val request = postSample(endpoint) .content("""{"country": "Switzerland", "dataFormat": "csv"}""") .contentType(MediaType.APPLICATION_JSON) @@ -161,7 +159,7 @@ class LapisControllerCsvTest( fun `GET returns as TSV with accept header`(endpoint: String) { mockEndpointReturnData(endpoint) - mockMvc.perform(get("$endpoint?country=Switzerland").header("Accept", "text/tab-separated-values")) + mockMvc.perform(getSample("$endpoint?country=Switzerland").header("Accept", "text/tab-separated-values")) .andExpect(status().isOk) .andExpect(header().string("Content-Type", "text/tab-separated-values;charset=UTF-8")) .andExpect(content().string(returnedTsvData(endpoint))) @@ -172,7 +170,7 @@ class LapisControllerCsvTest( fun `POST returns as TSV with accept header`(endpoint: String) { mockEndpointReturnData(endpoint) - val request = post(endpoint) + val request = postSample(endpoint) .content("""{"country": "Switzerland"}""") .contentType(MediaType.APPLICATION_JSON) .accept("text/tab-separated-values") @@ -188,7 +186,7 @@ class LapisControllerCsvTest( fun `GET returns as TSV with request parameter`(endpoint: String) { mockEndpointReturnData(endpoint) - mockMvc.perform(get("$endpoint?country=Switzerland&dataFormat=tsv")) + mockMvc.perform(getSample("$endpoint?country=Switzerland&dataFormat=tsv")) .andExpect(status().isOk) .andExpect(header().string("Content-Type", "text/tab-separated-values;charset=UTF-8")) .andExpect(content().string(returnedTsvData(endpoint))) @@ -199,7 +197,7 @@ class LapisControllerCsvTest( fun `POST returns as TSV with request parameter`(endpoint: String) { mockEndpointReturnData(endpoint) - val request = post(endpoint) + val request = postSample(endpoint) .content("""{"country": "Switzerland", "dataFormat": "tsv"}""") .contentType(MediaType.APPLICATION_JSON) diff --git a/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/LapisControllerTest.kt b/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/LapisControllerTest.kt index 9e19751c..3e80adfa 100644 --- a/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/LapisControllerTest.kt +++ b/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/LapisControllerTest.kt @@ -30,6 +30,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.MediaType import org.springframework.test.web.servlet.MockMvc +import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import org.springframework.test.web.servlet.result.MockMvcResultMatchers.header @@ -65,7 +66,7 @@ class LapisControllerTest( ), ) - mockMvc.perform(get("$AGGREGATED_ROUTE?country=Switzerland")) + mockMvc.perform(getSample("$AGGREGATED_ROUTE?country=Switzerland")) .andExpect(status().isOk) .andExpect(jsonPath("\$.data[0].count").value(0)) .andExpect(jsonPath("\$.data[0].country").value("Switzerland")) @@ -84,7 +85,7 @@ class LapisControllerTest( emptyMap(), ), ) - val request = post("/aggregated") + val request = postSample("/aggregated") .content("""{"country": "Switzerland"}""") .contentType(MediaType.APPLICATION_JSON) @@ -111,7 +112,7 @@ class LapisControllerTest( ), ) - mockMvc.perform(get("$AGGREGATED_ROUTE?country=Switzerland&fields=country,age")) + mockMvc.perform(getSample("$AGGREGATED_ROUTE?country=Switzerland&fields=country,age")) .andExpect(status().isOk) .andExpect(jsonPath("\$.data[0].count").value(0)) .andExpect(jsonPath("\$.data[0].country").value("Switzerland")) @@ -133,7 +134,7 @@ class LapisControllerTest( ) } returns listOf(AggregationData(5, emptyMap())) - mockMvc.perform(get("$AGGREGATED_ROUTE?nucleotideMutations=123A,124B")) + mockMvc.perform(getSample("$AGGREGATED_ROUTE?nucleotideMutations=123A,124B")) .andExpect(status().isOk) .andExpect(jsonPath("\$.data[0].count").value(5)) } @@ -154,7 +155,7 @@ class LapisControllerTest( ), ) - val request = post(AGGREGATED_ROUTE) + val request = postSample(AGGREGATED_ROUTE) .content("""{"country": "Switzerland", "fields": ["country","age"]}""") .contentType(MediaType.APPLICATION_JSON) @@ -170,7 +171,7 @@ class LapisControllerTest( fun `GET mutations without explicit minProportion`(endpoint: String) { setupMutationMock(endpoint, null) - mockMvc.perform(get("$endpoint?country=Switzerland")) + mockMvc.perform(getSample("$endpoint?country=Switzerland")) .andExpect(status().isOk) .andExpect(jsonPath("\$.data[0].mutation").value("the mutation")) .andExpect(jsonPath("\$.data[0].proportion").value(0.5)) @@ -184,7 +185,7 @@ class LapisControllerTest( fun `GET mutations with minProportion`(endpoint: String) { setupMutationMock(endpoint, 0.3) - mockMvc.perform(get("$endpoint?country=Switzerland&minProportion=0.3")) + mockMvc.perform(getSample("$endpoint?country=Switzerland&minProportion=0.3")) .andExpect(status().isOk) .andExpect(jsonPath("\$.data[0].mutation").value("the mutation")) .andExpect(jsonPath("\$.data[0].proportion").value(0.5)) @@ -196,7 +197,7 @@ class LapisControllerTest( fun `POST mutations without explicit minProportion`(endpoint: String) { setupMutationMock(endpoint, null) - val request = post(endpoint) + val request = postSample(endpoint) .content("""{"country": "Switzerland"}""") .contentType(MediaType.APPLICATION_JSON) @@ -212,7 +213,7 @@ class LapisControllerTest( fun `POST mutations with minProportion`(endpoint: String) { setupMutationMock(endpoint, 0.7) - val request = post(endpoint) + val request = postSample(endpoint) .content("""{"country": "Switzerland", "minProportion": 0.7}""") .contentType(MediaType.APPLICATION_JSON) @@ -228,7 +229,7 @@ class LapisControllerTest( @ParameterizedTest(name = "POST {0} with invalid minProportion returns bad request") @MethodSource("getMutationEndpoints") fun `POST mutations with invalid minProportion returns bad request`(endpoint: String) { - val request = post(endpoint) + val request = postSample(endpoint) .content("""{"country": "Switzerland", "minProportion": "this is not a float"}""") .contentType(MediaType.APPLICATION_JSON) @@ -245,7 +246,7 @@ class LapisControllerTest( fun `GET mutations only returns mutation, proportion and count`(endpoint: String) { setupMutationMock(endpoint, null) - val mvcResult = mockMvc.perform(get("$endpoint?country=Switzerland")) + val mvcResult = mockMvc.perform(getSample("$endpoint?country=Switzerland")) .andExpect(status().isOk) .andReturn() @@ -288,7 +289,7 @@ class LapisControllerTest( fun `POST insertions`(endpoint: String) { setupInsertionMock(endpoint) - val request = post(endpoint) + val request = postSample(endpoint) .content("""{"country": "Switzerland"}""") .contentType(MediaType.APPLICATION_JSON) @@ -305,7 +306,7 @@ class LapisControllerTest( fun `GET insertions`(endpoint: String) { setupInsertionMock(endpoint) - val request = get("$endpoint?country=Switzerland") + val request = getSample("$endpoint?country=Switzerland") mockMvc.perform(request) .andExpect(status().isOk) @@ -320,7 +321,7 @@ class LapisControllerTest( fun `GET insertions only returns insertion and count`(endpoint: String) { setupInsertionMock(endpoint) - val mvcResult = mockMvc.perform(get("$endpoint?country=Switzerland")) + val mvcResult = mockMvc.perform(getSample("$endpoint?country=Switzerland")) .andExpect(status().isOk) .andReturn() @@ -374,7 +375,7 @@ class LapisControllerTest( siloQueryModelMock.getDetails(sequenceFiltersRequestWithFields(mapOf("country" to "Switzerland"))) } returns listOf(DetailsData(mapOf("country" to TextNode("Switzerland"), "age" to IntNode(42)))) - mockMvc.perform(get("$DETAILS_ROUTE?country=Switzerland")) + mockMvc.perform(getSample("$DETAILS_ROUTE?country=Switzerland")) .andExpect(status().isOk) .andExpect(jsonPath("\$.data[0].country").value("Switzerland")) .andExpect(jsonPath("\$.data[0].age").value(42)) @@ -393,7 +394,7 @@ class LapisControllerTest( ) } returns listOf(DetailsData(mapOf("country" to TextNode("Switzerland"), "age" to IntNode(42)))) - mockMvc.perform(get("$DETAILS_ROUTE?country=Switzerland&fields=country&fields=age")) + mockMvc.perform(getSample("$DETAILS_ROUTE?country=Switzerland&fields=country&fields=age")) .andExpect(status().isOk) .andExpect(jsonPath("\$.data[0].country").value("Switzerland")) .andExpect(jsonPath("\$.data[0].age").value(42)) @@ -405,7 +406,7 @@ class LapisControllerTest( siloQueryModelMock.getDetails(sequenceFiltersRequestWithFields(mapOf("country" to "Switzerland"))) } returns listOf(DetailsData(mapOf("country" to TextNode("Switzerland"), "age" to IntNode(42)))) - val request = post(DETAILS_ROUTE) + val request = postSample(DETAILS_ROUTE) .content("""{"country": "Switzerland"}""") .contentType(MediaType.APPLICATION_JSON) @@ -428,7 +429,7 @@ class LapisControllerTest( ) } returns listOf(DetailsData(mapOf("country" to TextNode("Switzerland"), "age" to IntNode(42)))) - val request = post(DETAILS_ROUTE) + val request = postSample(DETAILS_ROUTE) .content("""{"country": "Switzerland", "fields": ["country", "age"]}""") .contentType(MediaType.APPLICATION_JSON) @@ -482,3 +483,7 @@ class LapisControllerTest( private fun someAminoAcidInsertion() = AminoAcidInsertionResponse("the insertion", 42) } + +fun getSample(path: String): MockHttpServletRequestBuilder = get("/sample/$path") + +fun postSample(path: String): MockHttpServletRequestBuilder = post("/sample/$path") diff --git a/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/MultiSegmentedSequenceControllerTest.kt b/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/MultiSegmentedSequenceControllerTest.kt index 9190b1fa..ffaa1259 100644 --- a/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/MultiSegmentedSequenceControllerTest.kt +++ b/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/MultiSegmentedSequenceControllerTest.kt @@ -15,8 +15,6 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.MediaType import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content import org.springframework.test.web.servlet.result.MockMvcResultMatchers.header import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -55,7 +53,7 @@ class MultiSegmentedSequenceControllerTest( ) } returns returnedValue - mockMvc.perform(get("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE/otherSegment")) + mockMvc.perform(getSample("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE/otherSegment")) .andExpect(status().isOk) .andExpect(content().string(returnedValue)) .andExpect(header().stringValues("Lapis-Data-Version", "1234")) @@ -72,7 +70,7 @@ class MultiSegmentedSequenceControllerTest( ) } returns returnedValue - mockMvc.perform(get("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE/otherSegment?country=Switzerland")) + mockMvc.perform(getSample("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE/otherSegment?country=Switzerland")) .andExpect(status().isOk) .andExpect(content().string(returnedValue)) .andExpect(header().stringValues("Lapis-Data-Version", "1234")) @@ -89,7 +87,7 @@ class MultiSegmentedSequenceControllerTest( ) } returns returnedValue - val request = post("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE/otherSegment") + val request = postSample("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE/otherSegment") .content("""{}""") .contentType(MediaType.APPLICATION_JSON) @@ -110,7 +108,7 @@ class MultiSegmentedSequenceControllerTest( ) } returns returnedValue - val request = post("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE/otherSegment") + val request = postSample("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE/otherSegment") .content("""{"country":"Switzerland"}""") .contentType(MediaType.APPLICATION_JSON) @@ -131,7 +129,7 @@ class MultiSegmentedSequenceControllerTest( ) } returns returnedValue - mockMvc.perform(get(ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE)) + mockMvc.perform(getSample(ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE)) .andExpect(status().isNotFound) } @@ -146,7 +144,7 @@ class MultiSegmentedSequenceControllerTest( ) } returns returnedValue - val request = post(ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE) + val request = postSample(ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE) .content("""{}""") .contentType(MediaType.APPLICATION_JSON) diff --git a/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/SingleSegmentedSequenceControllerTest.kt b/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/SingleSegmentedSequenceControllerTest.kt index cde0ec50..a82cb277 100644 --- a/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/SingleSegmentedSequenceControllerTest.kt +++ b/lapis2/src/test/kotlin/org/genspectrum/lapis/controller/SingleSegmentedSequenceControllerTest.kt @@ -15,8 +15,6 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.MediaType import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content import org.springframework.test.web.servlet.result.MockMvcResultMatchers.header import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -55,7 +53,7 @@ class SingleSegmentedSequenceControllerTest( ) } returns returnedValue - mockMvc.perform(get(ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE)) + mockMvc.perform(getSample(ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE)) .andExpect(status().isOk) .andExpect(content().string(returnedValue)) .andExpect(header().stringValues("Lapis-Data-Version", "1234")) @@ -72,7 +70,7 @@ class SingleSegmentedSequenceControllerTest( ) } returns returnedValue - mockMvc.perform(get("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE?country=Switzerland")) + mockMvc.perform(getSample("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE?country=Switzerland")) .andExpect(status().isOk) .andExpect(content().string(returnedValue)) .andExpect(header().stringValues("Lapis-Data-Version", "1234")) @@ -89,7 +87,7 @@ class SingleSegmentedSequenceControllerTest( ) } returns returnedValue - val request = MockMvcRequestBuilders.post(ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE) + val request = postSample(ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE) .content("""{}""") .contentType(MediaType.APPLICATION_JSON) @@ -110,7 +108,7 @@ class SingleSegmentedSequenceControllerTest( ) } returns returnedValue - val request = MockMvcRequestBuilders.post(ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE) + val request = postSample(ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE) .content("""{"country": "Switzerland"}""") .contentType(MediaType.APPLICATION_JSON) @@ -131,7 +129,7 @@ class SingleSegmentedSequenceControllerTest( ) } returns returnedValue - mockMvc.perform(get("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE/someSegment")) + mockMvc.perform(getSample("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE/someSegment")) .andExpect(status().isNotFound) } @@ -146,7 +144,7 @@ class SingleSegmentedSequenceControllerTest( ) } returns returnedValue - val request = MockMvcRequestBuilders.post("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE/someSegment") + val request = postSample("$ALIGNED_NUCLEOTIDE_SEQUENCES_ROUTE/someSegment") .content("""{}""") .contentType(MediaType.APPLICATION_JSON) diff --git a/siloLapisTests/test/aggregated.spec.ts b/siloLapisTests/test/aggregated.spec.ts index 4742e0eb..449a84d8 100644 --- a/siloLapisTests/test/aggregated.spec.ts +++ b/siloLapisTests/test/aggregated.spec.ts @@ -8,7 +8,7 @@ const queriesPath = __dirname + '/aggregatedQueries'; const aggregatedQueryFiles = fs.readdirSync(queriesPath); function getAggregated(params?: URLSearchParams) { - const aggregatedEndpoint = '/aggregated'; + const aggregatedEndpoint = '/sample/aggregated'; if (params === undefined) { return fetch(basePath + aggregatedEndpoint); } diff --git a/siloLapisTests/test/alignedNucleotideSequence.spec.ts b/siloLapisTests/test/alignedNucleotideSequence.spec.ts index 90825ba1..cbf59c37 100644 --- a/siloLapisTests/test/alignedNucleotideSequence.spec.ts +++ b/siloLapisTests/test/alignedNucleotideSequence.spec.ts @@ -104,7 +104,7 @@ describe('The /alignedNucleotideSequence endpoint', () => { }); it('should return the lapis data version in the response', async () => { - const result = await fetch(basePath + '/alignedNucleotideSequences'); + const result = await fetch(basePath + '/sample/alignedNucleotideSequences'); expect(result.status).equals(200); expect(result.headers.get('lapis-data-version')).to.match(/\d{10}/); diff --git a/siloLapisTests/test/aminoAcidInsertions.spec.ts b/siloLapisTests/test/aminoAcidInsertions.spec.ts index 49ce763e..ae79e491 100644 --- a/siloLapisTests/test/aminoAcidInsertions.spec.ts +++ b/siloLapisTests/test/aminoAcidInsertions.spec.ts @@ -88,7 +88,7 @@ describe('The /aminoAcidInsertions endpoint', () => { dataFormat: 'csv', }); - const result = await fetch(basePath + '/aminoAcidInsertions?' + urlParams.toString()); + const result = await fetch(basePath + '/sample/aminoAcidInsertions?' + urlParams.toString()); const resultText = await result.text(); expect(resultText).to.contain( @@ -113,7 +113,7 @@ ins_S:247:SGE,1 dataFormat: 'tsv', }); - const result = await fetch(basePath + '/aminoAcidInsertions?' + urlParams.toString()); + const result = await fetch(basePath + '/sample/aminoAcidInsertions?' + urlParams.toString()); const resultText = await result.text(); expect(resultText).to.contain( @@ -133,7 +133,7 @@ ins_S:247:SGE 1 }); it('should return the lapis data version in the response', async () => { - const result = await fetch(basePath + '/aminoAcidInsertions'); + const result = await fetch(basePath + '/sample/aminoAcidInsertions'); expect(result.status).equals(200); expect(result.headers.get('lapis-data-version')).to.match(/\d{10}/); diff --git a/siloLapisTests/test/aminoAcidMutations.spec.ts b/siloLapisTests/test/aminoAcidMutations.spec.ts index f910ae56..52188fdd 100644 --- a/siloLapisTests/test/aminoAcidMutations.spec.ts +++ b/siloLapisTests/test/aminoAcidMutations.spec.ts @@ -123,7 +123,7 @@ describe('The /aminoAcidMutations endpoint', () => { dataFormat: 'csv', }); - const result = await fetch(basePath + '/aminoAcidMutations?' + urlParams.toString()); + const result = await fetch(basePath + '/sample/aminoAcidMutations?' + urlParams.toString()); const resultText = await result.text(); expect(resultText).to.contain( @@ -149,7 +149,7 @@ ORF1a:A2529V,3,0.17647058823529413 dataFormat: 'tsv', }); - const result = await fetch(basePath + '/aminoAcidMutations?' + urlParams.toString()); + const result = await fetch(basePath + '/sample/aminoAcidMutations?' + urlParams.toString()); const resultText = await result.text(); expect(resultText).to.contain( @@ -168,7 +168,7 @@ ORF1a:A2529V 3 0.17647058823529413 }); it('should return the lapis data version in the response', async () => { - const result = await fetch(basePath + '/aminoAcidMutations'); + const result = await fetch(basePath + '/sample/aminoAcidMutations'); expect(result.status).equals(200); expect(result.headers.get('lapis-data-version')).to.match(/\d{10}/); diff --git a/siloLapisTests/test/aminoAcidSequence.spec.ts b/siloLapisTests/test/aminoAcidSequence.spec.ts index ca21f775..3f9c2058 100644 --- a/siloLapisTests/test/aminoAcidSequence.spec.ts +++ b/siloLapisTests/test/aminoAcidSequence.spec.ts @@ -111,7 +111,7 @@ describe('The /alignedAminoAcidSequence endpoint', () => { }); it('should return the lapis data version in the response', async () => { - const result = await fetch(basePath + '/alignedAminoAcidSequences/S'); + const result = await fetch(basePath + '/sample/alignedAminoAcidSequences/S'); expect(result.status).equals(200); expect(result.headers.get('lapis-data-version')).to.match(/\d{10}/); diff --git a/siloLapisTests/test/badRequest.spec.ts b/siloLapisTests/test/badRequest.spec.ts index eac0bc95..6707032e 100644 --- a/siloLapisTests/test/badRequest.spec.ts +++ b/siloLapisTests/test/badRequest.spec.ts @@ -4,13 +4,13 @@ import { basePath } from './common'; describe('Error handling: BadRequest', () => { it('should return a 400 JSON response for a bad request', async () => { const badRequestForAggregated = 'nucleotideMutations=someInvalidMutation'; - const result = await fetch(basePath + '/aggregated?' + badRequestForAggregated); + const result = await fetch(basePath + '/sample/aggregated?' + badRequestForAggregated); expect(result.status).equals(400); expect(result.headers.get('Content-Type')).equals('application/problem+json'); expect(await result.json()).to.deep.equal({ detail: "Failed to convert 'nucleotideMutations' with value: 'someInvalidMutation'", - instance: '/aggregated', + instance: '/sample/aggregated', status: 400, title: 'Bad Request', type: 'about:blank', diff --git a/siloLapisTests/test/details.spec.ts b/siloLapisTests/test/details.spec.ts index 7abf7c57..e6392d68 100644 --- a/siloLapisTests/test/details.spec.ts +++ b/siloLapisTests/test/details.spec.ts @@ -104,7 +104,7 @@ describe('The /details endpoint', () => { dataFormat: 'csv', }); - const result = await fetch(basePath + '/details?' + urlParams.toString()); + const result = await fetch(basePath + '/sample/details?' + urlParams.toString()); expect(await result.text()).to.be.equal( String.raw` @@ -124,7 +124,7 @@ Solothurn,EPI_ISL_1002052,B.1 dataFormat: 'tsv', }); - const result = await fetch(basePath + '/details?' + urlParams.toString()); + const result = await fetch(basePath + '/sample/details?' + urlParams.toString()); expect(await result.text()).to.be.equal( String.raw` @@ -185,7 +185,7 @@ Solothurn EPI_ISL_1002052 B.1 }); it('should return the lapis data version in the response', async () => { - const result = await fetch(basePath + '/details'); + const result = await fetch(basePath + '/sample/details'); expect(result.status).equals(200); expect(result.headers.get('lapis-data-version')).to.match(/\d{10}/); diff --git a/siloLapisTests/test/nucleotideInsertions.spec.ts b/siloLapisTests/test/nucleotideInsertions.spec.ts index 9c18e4e9..4d785e07 100644 --- a/siloLapisTests/test/nucleotideInsertions.spec.ts +++ b/siloLapisTests/test/nucleotideInsertions.spec.ts @@ -90,7 +90,7 @@ describe('The /nucleotideInsertions endpoint', () => { dataFormat: 'csv', }); - const result = await fetch(basePath + '/nucleotideInsertions?' + urlParams.toString()); + const result = await fetch(basePath + '/sample/nucleotideInsertions?' + urlParams.toString()); const resultText = await result.text(); expect(resultText).to.contain( @@ -115,7 +115,7 @@ ins_25701:CCC,17 dataFormat: 'tsv', }); - const result = await fetch(basePath + '/nucleotideInsertions?' + urlParams.toString()); + const result = await fetch(basePath + '/sample/nucleotideInsertions?' + urlParams.toString()); const resultText = await result.text(); expect(resultText).to.contain( @@ -135,7 +135,7 @@ ins_25701:CCC 17 }); it('should return the lapis data version in the response', async () => { - const result = await fetch(basePath + '/nucleotideInsertions'); + const result = await fetch(basePath + '/sample/nucleotideInsertions'); expect(result.status).equals(200); expect(result.headers.get('lapis-data-version')).to.match(/\d{10}/); diff --git a/siloLapisTests/test/nucleotideMutations.spec.ts b/siloLapisTests/test/nucleotideMutations.spec.ts index a69717f3..3d9b3345 100644 --- a/siloLapisTests/test/nucleotideMutations.spec.ts +++ b/siloLapisTests/test/nucleotideMutations.spec.ts @@ -123,7 +123,7 @@ describe('The /nucleotideMutations endpoint', () => { dataFormat: 'csv', }); - const result = await fetch(basePath + '/nucleotideMutations?' + urlParams.toString()); + const result = await fetch(basePath + '/sample/nucleotideMutations?' + urlParams.toString()); const resultText = await result.text(); expect(resultText).to.contain( @@ -149,7 +149,7 @@ C7124T,2,0.11764705882352941 dataFormat: 'tsv', }); - const result = await fetch(basePath + '/nucleotideMutations?' + urlParams.toString()); + const result = await fetch(basePath + '/sample/nucleotideMutations?' + urlParams.toString()); const resultText = await result.text(); expect(resultText).to.contain( @@ -168,7 +168,7 @@ C7124T 2 0.11764705882352941 }); it('should return the lapis data version in the response', async () => { - const result = await fetch(basePath + '/nucleotideMutations'); + const result = await fetch(basePath + '/sample/nucleotideMutations'); expect(result.status).equals(200); expect(result.headers.get('lapis-data-version')).to.match(/\d{10}/);