From fa2cfe199d3c491f7a0a69ba429e7654f8a84183 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Tue, 19 Nov 2024 19:44:49 +0100 Subject: [PATCH] Add test for #3244 (#3248) --- .../kotlin/org/loculus/backend/controller/TestHelpers.kt | 5 +++++ .../backend/controller/submission/RevokeEndpointTest.kt | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/src/test/kotlin/org/loculus/backend/controller/TestHelpers.kt b/backend/src/test/kotlin/org/loculus/backend/controller/TestHelpers.kt index 0675387ae..54ae13d49 100644 --- a/backend/src/test/kotlin/org/loculus/backend/controller/TestHelpers.kt +++ b/backend/src/test/kotlin/org/loculus/backend/controller/TestHelpers.kt @@ -77,6 +77,11 @@ fun SequenceEntryStatus.assertHasError(error: Boolean): SequenceEntryStatus { return this } +fun SequenceEntryStatus.assertSubmitterIs(submitter: String): SequenceEntryStatus { + assertThat(this.submitter, `is`(submitter)) + return this +} + fun expectUnauthorizedResponse(isModifyingRequest: Boolean = false, apiCall: (jwt: String?) -> ResultActions) { val response = apiCall(null) diff --git a/backend/src/test/kotlin/org/loculus/backend/controller/submission/RevokeEndpointTest.kt b/backend/src/test/kotlin/org/loculus/backend/controller/submission/RevokeEndpointTest.kt index f30209c17..bedfa8c75 100644 --- a/backend/src/test/kotlin/org/loculus/backend/controller/submission/RevokeEndpointTest.kt +++ b/backend/src/test/kotlin/org/loculus/backend/controller/submission/RevokeEndpointTest.kt @@ -8,7 +8,9 @@ import org.loculus.backend.controller.DEFAULT_ORGANISM import org.loculus.backend.controller.DEFAULT_USER_NAME import org.loculus.backend.controller.EndpointTest import org.loculus.backend.controller.OTHER_ORGANISM +import org.loculus.backend.controller.SUPER_USER_NAME import org.loculus.backend.controller.assertStatusIs +import org.loculus.backend.controller.assertSubmitterIs import org.loculus.backend.controller.expectUnauthorizedResponse import org.loculus.backend.controller.generateJwtFor import org.loculus.backend.controller.jwtForSuperUser @@ -36,7 +38,7 @@ class RevokeEndpointTest( } @Test - fun `GIVEN entries with 'APPROVED_FOR_RELEASE' THEN returns revocation version in status AWAITING_APPROVAL`() { + fun `GIVEN entries with 'APPROVED_FOR_RELEASE' THEN returns revocation version in status PROCESSED`() { val accessions = convenienceClient.prepareDefaultSequenceEntriesToApprovedForRelease().map { it.accession } client.revokeSequenceEntries(accessions) @@ -48,6 +50,7 @@ class RevokeEndpointTest( convenienceClient.getSequenceEntry(accession = accessions.first(), version = 2) .assertStatusIs(PROCESSED) + .assertSubmitterIs(DEFAULT_USER_NAME) } @Test @@ -94,7 +97,7 @@ class RevokeEndpointTest( } @Test - fun `WHEN superuser revokes entries of other group THEN revocation version is created`() { + fun `WHEN superuser revokes entries of other group THEN superuser is submitter of revocation entry`() { val accessions = convenienceClient .prepareDefaultSequenceEntriesToApprovedForRelease(username = DEFAULT_USER_NAME) .map { it.accession } @@ -108,6 +111,7 @@ class RevokeEndpointTest( convenienceClient.getSequenceEntry(accession = accessions.first(), version = 2) .assertStatusIs(PROCESSED) + .assertSubmitterIs(SUPER_USER_NAME) } @Test