Skip to content

Commit

Permalink
Pivotal ID # 185649200: Cater For Paths Ending With Backslash (#771)
Browse files Browse the repository at this point in the history
https://www.pivotaltracker.com/story/show/185649200

- Include the file list help url in the error message for invalid paths
- Include the task to auto deploy the stats reporter task which was
forgotten in a previous PR
  • Loading branch information
jhoanmanuelms authored Nov 15, 2023
1 parent 4b0d3ff commit e57cabe
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include:
- local: '/ci/pmc-processor.yml'
- local: '/ci/exporter.yml'
- local: '/ci/submission-releaser.yml'
- local: '/ci/stats-reporter.yml'
- local: '/ci/scheduler.yml'
- local: '/ci/bio-admin.yml'
- local: '/ci/bio-commandline.yml'
Expand All @@ -37,6 +38,7 @@ stages:
- auto-deploy-prod-scheduler
- auto-deploy-prod-exporter-task
- auto-deploy-prod-releaser-task
- auto-deploy-prod-stats-reporter-task
- auto-deploy-prod-pmc-processor-task
- deploy-dev-submitter
- deploy-beta-submitter
Expand All @@ -54,6 +56,9 @@ stages:
- deploy-dev-releaser-task
- deploy-beta-releaser-task
- deploy-prod-releaser-task
- deploy-dev-stats-reporter-task
- deploy-beta-stats-reporter-task
- deploy-prod-stats-reporter-task
- deploy-dev-scheduler
- deploy-beta-scheduler
- deploy-prod-scheduler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
package ebi.ac.uk.errors

class InvalidPathException(path: String) : RuntimeException("The given file path contains invalid characters: $path")
class InvalidPathException(val path: String) : RuntimeException() {
override val message: String
get() = """
The given file path contains invalid characters: $path
For more information check https://www.ebi.ac.uk/bioimage-archive/help-file-list
"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,31 +62,51 @@ internal class FileSourcesListTest(
val error = assertFailsWith<InvalidPathException> {
testInstance.findExtFile("./folder/file.txt", FILE_TYPE.value, attributes)
}
assertThat(error.message).isEqualTo("The given file path contains invalid characters: ./folder/file.txt")
val expectedErrorMessage =
"""
The given file path contains invalid characters: ./folder/file.txt
For more information check https://www.ebi.ac.uk/bioimage-archive/help-file-list
""".trimIndent()
assertThat(error.message).isEqualToIgnoringWhitespace(expectedErrorMessage)
}

@Test
fun `file with previous folder relative path`() = runTest {
val error = assertFailsWith<InvalidPathException> {
testInstance.findExtFile("folder/../file.txt", FILE_TYPE.value, attributes)
}
assertThat(error.message).isEqualTo("The given file path contains invalid characters: folder/../file.txt")
val expectedErrorMessage =
"""
The given file path contains invalid characters: folder/../file.txt
For more information check https://www.ebi.ac.uk/bioimage-archive/help-file-list
""".trimIndent()
assertThat(error.message).isEqualToIgnoringWhitespace(expectedErrorMessage)
}

@Test
fun `file with invalid character`() = runTest {
val error = assertFailsWith<InvalidPathException> {
testInstance.findExtFile("folder/filé.txt", FILE_TYPE.value, attributes)
}
assertThat(error.message).isEqualTo("The given file path contains invalid characters: folder/filé.txt")
val expectedErrorMessage =
"""
The given file path contains invalid characters: folder/filé.txt
For more information check https://www.ebi.ac.uk/bioimage-archive/help-file-list
""".trimIndent()
assertThat(error.message).isEqualToIgnoringWhitespace(expectedErrorMessage)
}

@Test
fun `file with trailing slash`() = runTest {
val error = assertFailsWith<InvalidPathException> {
testInstance.findExtFile("folder/inner/", DIRECTORY_TYPE.value, attributes)
}
assertThat(error.message).isEqualTo("The given file path contains invalid characters: folder/inner/")
val expectedErrorMessage =
"""
The given file path contains invalid characters: folder/inner/
For more information check https://www.ebi.ac.uk/bioimage-archive/help-file-list
""".trimIndent()
assertThat(error.message).isEqualToIgnoringWhitespace(expectedErrorMessage)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import ac.uk.ebi.biostd.client.exception.WebClientException
import ac.uk.ebi.biostd.client.integration.commons.SubmissionFormat
import ac.uk.ebi.biostd.client.integration.commons.SubmissionFormat.TSV
import ac.uk.ebi.biostd.client.integration.web.BioWebClient
import ac.uk.ebi.biostd.submission.config.FilePersistenceConfig
import ac.uk.ebi.biostd.itest.common.SecurityTestService
import ac.uk.ebi.biostd.itest.entities.FtpSuperUser
import ac.uk.ebi.biostd.itest.entities.SuperUser
Expand All @@ -16,6 +15,7 @@ import ac.uk.ebi.biostd.itest.itest.getWebClient
import ac.uk.ebi.biostd.persistence.common.service.SubmissionPersistenceQueryService
import ac.uk.ebi.biostd.persistence.model.DbSequence
import ac.uk.ebi.biostd.persistence.repositories.SequenceDataRepository
import ac.uk.ebi.biostd.submission.config.FilePersistenceConfig
import ebi.ac.uk.asserts.assertThat
import ebi.ac.uk.dsl.file
import ebi.ac.uk.dsl.section
Expand Down Expand Up @@ -298,7 +298,10 @@ class SubmissionApiTest(

assertThatExceptionOfType(WebClientException::class.java)
.isThrownBy { webClient.submitSingle(submission, TSV) }
.withMessageContaining("The given file path contains invalid characters: inner/directory/")
.withMessageContainingAll(
"The given file path contains invalid characters: inner/directory/",
"For more information check https://www.ebi.ac.uk/bioimage-archive/help-file-list",
)
}

@Nested
Expand Down

0 comments on commit e57cabe

Please sign in to comment.