Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
fhennig committed Feb 4, 2025
1 parent f1a9474 commit 1eafc21
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import org.junit.platform.launcher.TestExecutionListener
import org.junit.platform.launcher.TestPlan
import org.loculus.backend.api.Address
import org.loculus.backend.api.NewGroup
import org.loculus.backend.config.BackendSpringProperty
import org.loculus.backend.controller.datauseterms.DataUseTermsControllerClient
import org.loculus.backend.controller.groupmanagement.GroupManagementControllerClient
import org.loculus.backend.controller.seqsetcitations.SeqSetCitationsControllerClient
Expand All @@ -24,6 +23,7 @@ import org.loculus.backend.service.submission.METADATA_UPLOAD_AUX_TABLE_NAME
import org.loculus.backend.service.submission.SEQUENCE_ENTRIES_PREPROCESSED_DATA_TABLE_NAME
import org.loculus.backend.service.submission.SEQUENCE_ENTRIES_TABLE_NAME
import org.loculus.backend.service.submission.SEQUENCE_UPLOAD_AUX_TABLE_NAME

import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.annotation.Import
Expand Down Expand Up @@ -51,18 +51,8 @@ annotation class EndpointTest(@get:AliasFor(annotation = SpringBootTest::class)

const val SINGLE_SEGMENTED_REFERENCE_GENOME = "src/test/resources/backend_config_single_segment.json"

@EndpointTest(
properties = ["${BackendSpringProperty.BACKEND_CONFIG_PATH}=$SINGLE_SEGMENTED_REFERENCE_GENOME"],
)
annotation class SingleSegmentedReferenceGenomeEndpointTest

const val DATA_USE_TERMS_DISABLED_CONFIG = "src/test/resources/backend_config_data_use_terms_disabled.json"

@EndpointTest(
properties = ["${BackendSpringProperty.BACKEND_CONFIG_PATH}=$DATA_USE_TERMS_DISABLED_CONFIG"],
)
annotation class DataUseTermsDisabledEndpointTest

private const val SPRING_DATASOURCE_URL = "spring.datasource.url"
private const val SPRING_DATASOURCE_USERNAME = "spring.datasource.username"
private const val SPRING_DATASOURCE_PASSWORD = "spring.datasource.password"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import org.junit.jupiter.api.Test
import org.keycloak.representations.idm.UserRepresentation
import org.loculus.backend.api.GeneticSequence
import org.loculus.backend.api.ProcessedData
import org.loculus.backend.config.BackendConfig
import org.loculus.backend.config.BackendSpringProperty
import org.loculus.backend.controller.DATA_USE_TERMS_DISABLED_CONFIG
import org.loculus.backend.controller.DEFAULT_GROUP
import org.loculus.backend.controller.DEFAULT_GROUP_CHANGED
import org.loculus.backend.controller.DEFAULT_GROUP_NAME_CHANGED
import org.loculus.backend.controller.DEFAULT_PIPELINE_VERSION
import org.loculus.backend.controller.DEFAULT_USER_NAME
import org.loculus.backend.controller.DataUseTermsDisabledEndpointTest
import org.loculus.backend.controller.datauseterms.DataUseTermsControllerClient
import org.loculus.backend.controller.EndpointTest
import org.loculus.backend.controller.expectNdjsonAndGetContent
import org.loculus.backend.controller.groupmanagement.GroupManagementControllerClient
import org.loculus.backend.controller.groupmanagement.andGetGroupId
Expand All @@ -34,11 +36,14 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.header
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status

@DataUseTermsDisabledEndpointTest
@EndpointTest(
properties = ["${BackendSpringProperty.BACKEND_CONFIG_PATH}=$DATA_USE_TERMS_DISABLED_CONFIG"],
)
class GetReleasedDataDataUseTermsDisabledEndpointTest(
@Autowired private val convenienceClient: SubmissionConvenienceClient,
@Autowired private val submissionControllerClient: SubmissionControllerClient,
@Autowired private val groupClient: GroupManagementControllerClient,
@Autowired private val backendConfig: BackendConfig,
) {
private val currentDate = Clock.System.now().toLocalDateTime(DateProvider.timeZone).date.toString()

Expand All @@ -51,6 +56,11 @@ class GetReleasedDataDataUseTermsDisabledEndpointTest(
every { keycloakAdapter.getUsersWithName(any()) } returns listOf(UserRepresentation())
}

@Test
fun `config has been read and data use terms are configred to be off`() {
assertThat(backendConfig.dataUseTermsEnabled, `is`(false));
}

@Test
fun `GIVEN released data exists THEN returns it with additional metadata fields`() {
val groupId = groupClient.createNewGroup(group = DEFAULT_GROUP, jwt = jwtForDefaultUser)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package org.loculus.backend.controller.submission

import org.loculus.backend.controller.DataUseTermsDisabledEndpointTest
import org.loculus.backend.config.BackendSpringProperty
import org.loculus.backend.controller.DATA_USE_TERMS_DISABLED_CONFIG
import org.loculus.backend.controller.EndpointTest

@DataUseTermsDisabledEndpointTest
@EndpointTest(
properties = ["${BackendSpringProperty.BACKEND_CONFIG_PATH}=$DATA_USE_TERMS_DISABLED_CONFIG"],
)
class SubmitEndpointDataUseTermsDisabledTest {
// TODO
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import org.hamcrest.Matchers.containsString
import org.hamcrest.Matchers.hasEntry
import org.junit.jupiter.api.Test
import org.loculus.backend.config.BackendConfig
import org.loculus.backend.controller.SingleSegmentedReferenceGenomeEndpointTest
import org.loculus.backend.config.BackendSpringProperty
import org.loculus.backend.controller.EndpointTest
import org.loculus.backend.controller.SINGLE_SEGMENTED_REFERENCE_GENOME
import org.loculus.backend.controller.groupmanagement.GroupManagementControllerClient
import org.loculus.backend.controller.groupmanagement.andGetGroupId
import org.springframework.beans.factory.annotation.Autowired
Expand All @@ -16,7 +18,9 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status

private const val DEFAULT_SEQUENCE_NAME = "main"

@SingleSegmentedReferenceGenomeEndpointTest
@EndpointTest(
properties = ["${BackendSpringProperty.BACKEND_CONFIG_PATH}=$SINGLE_SEGMENTED_REFERENCE_GENOME"],
)
class SubmitEndpointSingleSegmentedTest(
@Autowired val submissionControllerClient: SubmissionControllerClient,
@Autowired val convenienceClient: SubmissionConvenienceClient,
Expand Down

0 comments on commit 1eafc21

Please sign in to comment.