Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,18 @@ public Capabilities deserialize(JsonElement json, Type typeOfT, JsonDeserializat
response.setFederationShare(outgoing.getAsBoolean());

final var publicObject = filesSharing.getAsJsonObject("public");
final var password = publicObject.getAsJsonObject("password");
final var enforced = password.getAsJsonPrimitive("enforced");
final var askForOptionalPassword = password.getAsJsonPrimitive("askForOptionalPassword");
if (publicObject.has("password")) {
final var password = publicObject.getAsJsonObject("password");
final var enforced = password.getAsJsonPrimitive("enforced");
final var askForOptionalPassword = password.getAsJsonPrimitive("askForOptionalPassword");

response.setPublicPasswordEnforced(enforced.getAsBoolean());
response.setAskForOptionalPassword(askForOptionalPassword.getAsBoolean());
}

final var isReSharingAllowed = filesSharing.getAsJsonPrimitive("resharing");
final var defaultPermission = filesSharing.getAsJsonPrimitive("default_permissions");

response.setDefaultPermission(defaultPermission.getAsInt());
response.setPublicPasswordEnforced(enforced.getAsBoolean());
response.setAskForOptionalPassword(askForOptionalPassword.getAsBoolean());
response.setReSharingAllowed(isReSharingAllowed.getAsBoolean());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,4 +366,79 @@ public void testDirectEditing() {
assertFalse("Wrongly reporting that direct editing is supported", capabilities1.isDirectEditingAvailable());

}


@Test
public void testSharingDisabled() {
//language=json
final String response = "" +
"{" +
" \"version\": {" +
" \"major\": 20," +
" \"minor\": 0," +
" \"micro\": 7," +
" \"string\": \"20.0.7\"," +
" \"edition\": \"\"," +
" \"extendedSupport\": false" +
" }," +
" \"capabilities\": {" +
" \"core\": {" +
" \"pollinterval\": 60," +
" \"webdav-root\": \"remote.php/webdav\"" +
" }," +
" \"notes\": {" +
" \"api_version\": [" +
" \"0.2\"," +
" \"1.1\"" +
" ]," +
" \"version\": \"4.0.4\"" +
" }," +
" \"files_sharing\": {" +
" \"api_enabled\": true," +
" \"public\": {" +
" \"enabled\": false," +
" \"expire_date\": {" +
" \"enabled\": false" +
" }," +
" \"multiple_links\": true," +
" \"expire_date_internal\": {" +
" \"enabled\": false" +
" }," +
" \"send_mail\": false," +
" \"upload\": true," +
" \"upload_files_drop\": true" +
" }," +
" \"resharing\": false," +
" \"user\": {" +
" \"send_mail\": false," +
" \"expire_date\": {" +
" \"enabled\": true" +
" }" +
" }," +
" \"group_sharing\": false," +
" \"group\": {" +
" \"enabled\": true," +
" \"expire_date\": {" +
" \"enabled\": true" +
" }" +
" }," +
" \"default_permissions\": 31," +
" \"federation\": {" +
" \"outgoing\": true," +
" \"incoming\": true," +
" \"expire_date\": {" +
" \"enabled\": true" +
" }" +
" }," +
" \"sharee\": {" +
" \"query_lookup_default\": false" +
" }" +
" }" +
" }" +
"}";
final var capabilities = deserializer.deserialize(JsonParser.parseString(response), null, null);
assertNull(capabilities.getETag());
assertEquals("[\"0.2\",\"1.1\"]", capabilities.getApiVersion());
assertFalse("Wrongly reporting that direct editing is supported", capabilities.isDirectEditingAvailable());
}
}
Loading