Navigation Menu

Skip to content

Commit

Permalink
fix: DSP-API project IRI validation fails for BEOL project IRI (#2240)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpro7 committed Oct 7, 2022
1 parent c5c98ce commit 4b63a72
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dsp-shared/src/main/scala/dsp/valueobjects/V2.scala
Expand Up @@ -222,7 +222,11 @@ object V2UuidValidation {
* @return TRUE for correct versions, FALSE for incorrect.
*/
def isUuidVersion4Or5(s: String): Boolean =
getUUIDVersion(s) == 4 || getUUIDVersion(s) == 5
// println("VERSION", getUUIDVersion(s), s)
// TODO-mpro: below condition is a quickfix, should be removed in DEV-1400
if (s != "http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF") {
getUUIDVersion(s) == 4 || getUUIDVersion(s) == 5
} else true

/**
* Gets the last segment of IRI, decodes UUID and gets the version.
Expand Down
Expand Up @@ -60,6 +60,11 @@ class CreateListItemsRouteADME2ESpec
"test"
)

val beolAdminUserCreds: CredentialsADM = CredentialsADM(
SharedTestDataADM.beolUser,
"test"
)

private val customChildNodeIRI = "http://rdfh.ch/lists/0001/vQgijJZKSqawFooJPyhYkw"
def addChildListNodeRequest(parentNodeIri: IRI, name: String, label: String, comment: String): String =
s"""{
Expand Down Expand Up @@ -259,6 +264,28 @@ class CreateListItemsRouteADME2ESpec
newListIri.set(listInfo.id)
}

"create a list using bad project IRI, created in the old way with bad UUID version" in {
val createListRequest: String =
s"""{
| "projectIri": "${SharedTestDataADM.BEOL_PROJECT_IRI}",
| "labels": [{ "value": "Neue Liste", "language": "de"}],
| "comments": [{ "value": "XXXXX", "language": "en"}]
|}""".stripMargin

val request = Post(
baseApiUrl + s"/admin/lists",
HttpEntity(ContentTypes.`application/json`, createListRequest)
) ~> addCredentials(beolAdminUserCreds.basicHttpCredentials)
val response: HttpResponse = singleAwaitingRequest(request)
// TODO-mro: implementation of DEV-1400 should break this tes - list with old BEOL IRI shouldn;t be created
response.status should be(StatusCodes.OK)

val receivedList: ListADM = AkkaHttpUtils.httpResponseToJson(response).fields("list").convertTo[ListADM]

val listInfo = receivedList.listinfo
listInfo.projectIri should be(SharedTestDataADM.BEOL_PROJECT_IRI)
}

"return a ForbiddenException if the user creating the list is not project or system admin" in {
val params =
s"""
Expand Down

0 comments on commit 4b63a72

Please sign in to comment.