Skip to content

Commit

Permalink
fix(sipi): Return permissions for a previous version of a file value. (
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Geer committed Jun 4, 2019
1 parent 002eca4 commit 9a3cee3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
16 changes: 15 additions & 1 deletion webapi/_test_data/all_data/anything-data.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,21 @@
knora-base:attachedToUser <http://rdfh.ch/users/91e19f1e01>;
knora-base:dimX 512;
knora-base:dimY 256;
knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|RV knora-admin:UnknownUser" .
knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|RV knora-admin:UnknownUser" ;
knora-base:previousValue <http://rdfh.ch/0001/a-thing-picture/values/file1a> .

<http://rdfh.ch/0001/a-thing-picture/values/file1a> a knora-base:StillImageFileValue;
knora-base:valueHasString "test.tiff";
knora-base:originalFilename "test.tiff";
knora-base:originalMimeType "image/tiff";
knora-base:internalFilename "QxFMm5wlRlatStw9ft3iZA.jp2";
knora-base:internalMimeType "image/jp2";
knora-base:valueCreationDate "2012-10-21T16:50:38Z"^^xsd:dateTime;
knora-base:isDeleted false;
knora-base:attachedToUser <http://rdfh.ch/users/91e19f1e01>;
knora-base:dimX 512;
knora-base:dimY 256;
knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|V knora-admin:UnknownUser" .

<http://rdfh.ch/0001/a-thing-with-picture> a anything:Thing;
knora-base:isDeleted false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ prefix knora-base: <http://www.knora.org/ontology/knora-base#>
SELECT ?fileValue ?objPred ?objObj
WHERE {

?fileValue knora-base:internalFilename "@filename" ;
?fileValue knora-base:internalFilename "@filename" .

?currentFileValue knora-base:previousValue* ?fileValue ;
knora-base:isDeleted false .

?resource knora-base:hasFileValue ?fileValue ;
?resource knora-base:hasFileValue ?currentFileValue ;
knora-base:isDeleted false .

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ prefix knora-base: <http://www.knora.org/ontology/knora-base#>
SELECT ?fileValue ?objPred ?objObj
WHERE {

?fileValue knora-base:internalFilename "@filename" ;
?fileValue knora-base:internalFilename "@filename" .

?currentFileValue knora-base:previousValue* ?fileValue ;
knora-base:isDeleted false .

?prop rdfs:subPropertyOf* knora-base:hasFileValue .

?resource ?prop ?fileValue ;
?resource ?prop ?currentFileValue ;
knora-base:isDeleted false .

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ class SipiADME2ESpec extends E2ESpec(SipiADME2ESpec.config) with SessionJsonProt

assert(response.status == StatusCodes.NotFound)
}

"return permissions for a previous version of a file value" in {
val request = Get(baseApiUrl + s"/admin/files/0001/QxFMm5wlRlatStw9ft3iZA.jp2?email=$normalUserEmailEnc&password=$testPass")
val response: HttpResponse = singleAwaitingRequest(request)

// println(response.toString)

assert(response.status == StatusCodes.OK)

val fr: SipiFileInfoGetResponseADM = Await.result(Unmarshal(response.entity).to[SipiFileInfoGetResponseADM], 1.seconds)

(fr.permissionCode === 2) should be (true)

}
}

"The Files Route ('admin/files') using session credentials" should {
Expand Down

0 comments on commit 9a3cee3

Please sign in to comment.