Skip to content

Commit

Permalink
Pivotal ID # 182595703: Submission Suppressing Workflow (#718)
Browse files Browse the repository at this point in the history
Change wording from "un-releasing" to "suppress"
  • Loading branch information
jhoanmanuelms authored Jun 2, 2023
1 parent 594585b commit 290ca9b
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ interface IUserPrivilegesService {

fun canRelease(email: String): Boolean

fun canUnrelease(email: String): Boolean
fun canSuppress(email: String): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal class UserPrivilegesService(

override fun canRelease(email: String): Boolean = isSuperUser(email)

override fun canUnrelease(email: String): Boolean = isSuperUser(email)
override fun canSuppress(email: String): Boolean = isSuperUser(email)

private fun hasPermissions(user: String, accessTags: List<String>, accessType: AccessType): Boolean {
val tags = accessTags.filter { it != PUBLIC_ACCESS_TAG.value }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ class UserPrivilegesServiceTest(
}

@Test
fun `super user unrelease`() {
assertThat(testInstance.canUnrelease("superuser@mail.com")).isTrue
fun `super user suppress`() {
assertThat(testInstance.canSuppress("superuser@mail.com")).isTrue
}

@Test
fun `regular user unrelease`() {
fun `regular user suppress`() {
every { superuser.superuser } returns false
assertThat(testInstance.canUnrelease("superuser@mail.com")).isFalse
assertThat(testInstance.canSuppress("superuser@mail.com")).isFalse
}

private fun initUsers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class ResubmissionApiTest(
}

@Test
fun `5-4 regular user un-releases own submission`() {
fun `5-4 regular user suppresses own submission`() {
val version1 = tsv {
line("Submission", "S-RSTST4")
line("Title", "Public Submission")
Expand All @@ -208,7 +208,7 @@ class ResubmissionApiTest(

val version2 = tsv {
line("Submission", "S-RSTST4")
line("Title", "Unreleased Submission")
line("Title", "Suppressed Submission")
line("ReleaseDate", "2050-05-22")
line()
line("Study")
Expand All @@ -217,11 +217,11 @@ class ResubmissionApiTest(

assertThatExceptionOfType(WebClientException::class.java)
.isThrownBy { getWebClient(serverPort, RegularUser).submitSingle(version2, TSV) }
.withMessageContaining("The user {$regularUser} is not allowed to un-release the submission S-RSTST4")
.withMessageContaining("The user {$regularUser} is not allowed to suppress the submission S-RSTST4")
}

@Test
fun `5-5 super user un-releases submission from another user`() {
fun `5-5 super user suppresses submission from another user`() {
val version1 = tsv {
line("Submission", "S-RSTST5")
line("Title", "Public Submission")
Expand All @@ -239,7 +239,7 @@ class ResubmissionApiTest(

val version2 = tsv {
line("Submission", "S-RSTST5")
line("Title", "Unreleased Submission")
line("Title", "Suppressed Submission")
line("ReleaseDate", "2050-05-22")
line()
line("Study")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
| ResubmissionApiTest | 5-1 | resubmit existing submission | Shows the system behaves when resubmissions occurs |
| ResubmissionApiTest | 5-2 | resubmit existing submission with the same files | |
| ResubmissionApiTest | 5-3 | re submit a submission with rootPath | |
| ResubmissionApiTest | 5-4 | regular user un-releases own submission | Verifies that a regular user can't un-release (become private) a submission that's already released |
| ResubmissionApiTest | 5-5 | super user un-releases submission from another user | Verifies that a super user ca un-release (become private) a submission that's already released |
| ResubmissionApiTest | 5-4 | regular user suppresses own submission | Verifies that a regular user can't suppress (become private) a submission that's already released |
| ResubmissionApiTest | 5-5 | super user suppresses submission from another user | Verifies that a super user ca suppress (become private) a submission that's already released |
| SubmissionFileSourceTest | 6-1 | resubmission with SUBMISSION file source as priority over USER\_SPACE | Considers submission with different source files, user space, fire, bypassing files with fire |
| SubmissionFileSourceTest | 6-2 | submission with FIRE source only | |
| SubmissionFileSourceTest | 6-3 | submission with directory with files on FIRE | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class UserCanNotRelease(
user: String
) : InvalidPermissionsException("The user {$user} is not allowed to release the submission $accNo")

class UserCanNotUnrelease(
class UserCanNotSuppress(
accNo: String,
user: String
) : InvalidPermissionsException("The user {$user} is not allowed to un-release the submission $accNo")
) : InvalidPermissionsException("The user {$user} is not allowed to suppress the submission $accNo")
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ac.uk.ebi.biostd.submission.service

import ac.uk.ebi.biostd.submission.exceptions.InvalidDateFormatException
import ac.uk.ebi.biostd.submission.exceptions.PastReleaseDateException
import ac.uk.ebi.biostd.submission.exceptions.UserCanNotUnrelease
import ac.uk.ebi.biostd.submission.exceptions.UserCanNotSuppress
import ac.uk.ebi.biostd.submission.model.SubmitRequest
import ebi.ac.uk.base.orFalse
import ebi.ac.uk.model.extensions.releaseDate
Expand Down Expand Up @@ -43,12 +43,12 @@ class TimesService(

return when {
releaseTime.isBefore(today) -> throw PastReleaseDateException()
releaseTime.isAfter(today) && isReleased && cantUnrelease(user) -> throw UserCanNotUnrelease(accNo, user)
releaseTime.isAfter(today) && isReleased && cantSuppress(user) -> throw UserCanNotSuppress(accNo, user)
else -> releaseTime
}
}

private fun cantUnrelease(user: String) = privilegesService.canUnrelease(user).not()
private fun cantSuppress(user: String) = privilegesService.canSuppress(user).not()

private fun parseDate(date: String): OffsetDateTime =
runCatching { LocalDate.parse(date) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ac.uk.ebi.biostd.submission.service

import ac.uk.ebi.biostd.submission.exceptions.InvalidDateFormatException
import ac.uk.ebi.biostd.submission.exceptions.PastReleaseDateException
import ac.uk.ebi.biostd.submission.exceptions.UserCanNotUnrelease
import ac.uk.ebi.biostd.submission.exceptions.UserCanNotSuppress
import ac.uk.ebi.biostd.submission.model.SubmitRequest
import ebi.ac.uk.model.extensions.releaseDate
import ebi.ac.uk.security.integration.components.IUserPrivilegesService
Expand Down Expand Up @@ -118,22 +118,22 @@ class TimesServiceTest(
}

@Test
fun `when submitter cant unrelease`() {
fun `when submitter cant suppress`() {
every { request.previousVersion?.released } returns true
every { privilegesService.canUnrelease("user@test.org") } returns false
every { privilegesService.canSuppress("user@test.org") } returns false
every { request.submission.releaseDate } returns "2020-10-10T09:27:04.000Z"

val error = assertThrows<UserCanNotUnrelease> { testInstance.getTimes(request) }
val error = assertThrows<UserCanNotSuppress> { testInstance.getTimes(request) }
assertThat(error.message)
.isEqualTo("The user {user@test.org} is not allowed to un-release the submission S-BSST1")
.isEqualTo("The user {user@test.org} is not allowed to suppress the submission S-BSST1")
}

@Test
fun `when submitter can unrelease`() {
fun `when submitter can suppress`() {
val releaseTime = OffsetDateTime.of(2020, 10, 10, 0, 0, 0, 0, UTC)

every { request.previousVersion?.released } returns true
every { privilegesService.canUnrelease("user@test.org") } returns true
every { privilegesService.canSuppress("user@test.org") } returns true
every { request.submission.releaseDate } returns "2020-10-10T09:27:04.000Z"

val times = testInstance.getTimes(request)
Expand Down

0 comments on commit 290ca9b

Please sign in to comment.