Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DSP-API project IRI validation fails for BEOL project IRI #2240

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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