implemented a comprehensive Nextcloud file sharing system with support for user, group, and public link shares with gating based on server-side permissions; added sharing management interfaces including a share sheet; updated the file list with visual badges for incoming shares and improved OCS API response handling.

This commit is contained in:
2026-06-02 21:42:08 +02:00
parent b6d06dd3b4
commit baa26a6e79
33 changed files with 2453 additions and 29 deletions
@@ -0,0 +1,57 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:marianum_mobile/api/marianumcloud/capabilities/nextcloud_sharing_capabilities.dart';
void main() {
group('NextcloudSharingCapabilities.fromFilesSharing', () {
test('parses a full files_sharing block', () {
final caps = NextcloudSharingCapabilities.fromFilesSharing({
'api_enabled': true,
'public': {
'enabled': true,
'multiple_links': true,
'upload': true,
'password': {'enforced': true},
'expire_date': {'enabled': true, 'days': 7, 'enforced': true},
},
'group': {'enabled': true},
'resharing': true,
});
expect(caps.apiEnabled, isTrue);
expect(caps.publicEnabled, isTrue);
expect(caps.publicMultipleLinks, isTrue);
expect(caps.publicUploadEnabled, isTrue);
expect(caps.publicPasswordEnforced, isTrue);
expect(caps.publicExpireEnabled, isTrue);
expect(caps.publicExpireDays, 7);
expect(caps.publicExpireEnforced, isTrue);
expect(caps.groupEnabled, isTrue);
expect(caps.resharing, isTrue);
});
test('falls back to the legacy group_sharing flag', () {
final caps = NextcloudSharingCapabilities.fromFilesSharing({
'api_enabled': true,
'group_sharing': true,
});
expect(caps.groupEnabled, isTrue);
});
test('missing fields default to the restrictive value', () {
final caps = NextcloudSharingCapabilities.fromFilesSharing({});
expect(caps.apiEnabled, isFalse);
expect(caps.publicEnabled, isFalse);
expect(caps.groupEnabled, isFalse);
expect(caps.resharing, isFalse);
expect(caps.publicExpireDays, isNull);
});
test('tolerates non-map / wrong-typed nested values', () {
final caps = NextcloudSharingCapabilities.fromFilesSharing({
'api_enabled': 'yes', // not a bool -> false
'public': 'nope', // not a map -> all false
});
expect(caps.apiEnabled, isFalse);
expect(caps.publicEnabled, isFalse);
});
});
}