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 @@ -3883,7 +3883,7 @@ sealed class $ShareInterface {
int get itemSource;
@BuiltValueField(wireName: 'item_type')
Share_ItemType get itemType;
String get label;
String? get label;
@BuiltValueField(wireName: 'mail_send')
Share_MailSend get mailSend;
String get mimetype;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@
]
},
"label": {
"type": "string"
"type": "string",
"nullable": true
},
"mail_send": {
"type": "integer",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"op": "add",
"path": "/components/schemas/Share/properties/label/nullable",
"value": true
}
]
118 changes: 118 additions & 0 deletions packages/nextcloud/test/api/files_sharing/files_sharing_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import 'dart:io';

import 'package:nextcloud/core.dart' as core;
import 'package:nextcloud/files_sharing.dart' as files_sharing;
import 'package:nextcloud/webdav.dart' as webdav;
import 'package:nextcloud_test/nextcloud_test.dart';
import 'package:test/test.dart';

void main() {
presets('server', 'files_sharing', (tester) {
group('shareapi', () {
test('createShare', () async {
final file = File('test/files/test.png');
await tester.client.webdav.putFile(file, file.statSync(), webdav.PathUri.parse('create-share.png'));
addTearDown(() async {
closeFixture();
await tester.client.webdav.delete(webdav.PathUri.parse('create-share.png'));
});

final response = await tester.client.filesSharing.shareapi.createShare(
$body: files_sharing.ShareapiCreateShareRequestApplicationJson(
(b) => b
..path = '/create-share.png'
..shareType = core.ShareType.user.index
..shareWith = 'user2',
),
);
expect(response.statusCode, 200);
expect(() => response.headers, isA<void>());
expect(response.body.ocs.data.canDelete, true);
expect(response.body.ocs.data.canEdit, true);
expect(response.body.ocs.data.displaynameFileOwner, 'User One');
expect(response.body.ocs.data.displaynameOwner, 'User One');
expect(response.body.ocs.data.fileParent, isPositive);
expect(response.body.ocs.data.fileSource, isPositive);
expect(response.body.ocs.data.fileTarget, '/create-share.png');
expect(response.body.ocs.data.hasPreview, true);
expect(response.body.ocs.data.hideDownload, files_sharing.Share_HideDownload.$0);
expect(response.body.ocs.data.id, isNotEmpty);
expect(response.body.ocs.data.itemMtime, isPositive);
expect(response.body.ocs.data.itemPermissions, 27);
expect(response.body.ocs.data.itemSize, 8650);
expect(response.body.ocs.data.itemSource, isPositive);
expect(response.body.ocs.data.itemType, files_sharing.Share_ItemType.file);
expect(response.body.ocs.data.label, '');
expect(response.body.ocs.data.mailSend, files_sharing.Share_MailSend.$1);
expect(response.body.ocs.data.mimetype, 'image/png');
expect(response.body.ocs.data.note, '');
expect(response.body.ocs.data.path, '/create-share.png');
expect(response.body.ocs.data.permissions, 19);
expect(response.body.ocs.data.shareType, core.ShareType.user.index);
expect(response.body.ocs.data.shareWith, 'user2');
expect(response.body.ocs.data.shareWithDisplayname, 'User Two');
expect(response.body.ocs.data.shareWithDisplaynameUnique, 'user2');
expect(response.body.ocs.data.stime, isPositive);
expect(response.body.ocs.data.storage, isPositive);
expect(response.body.ocs.data.storageId, 'home::user1');
expect(response.body.ocs.data.uidFileOwner, 'user1');
expect(response.body.ocs.data.uidOwner, 'user1');
});

test('getShares', () async {
final file = File('test/files/test.png');
await tester.client.webdav.putFile(file, file.statSync(), webdav.PathUri.parse('list-shares.png'));
addTearDown(() async {
closeFixture();
await tester.client.webdav.delete(webdav.PathUri.parse('list-shares.png'));
});

await tester.client.filesSharing.shareapi.createShare(
$body: files_sharing.ShareapiCreateShareRequestApplicationJson(
(b) => b
..path = '/list-shares.png'
..shareType = core.ShareType.user.index
..shareWith = 'user2',
),
);

final response = await tester.client.filesSharing.shareapi.getShares(
path: '/list-shares.png',
reshares: 'true',
);
expect(response.statusCode, 200);
expect(() => response.headers, isA<void>());
expect(response.body.ocs.data.single.canDelete, true);
expect(response.body.ocs.data.single.canEdit, true);
expect(response.body.ocs.data.single.displaynameFileOwner, 'User One');
expect(response.body.ocs.data.single.displaynameOwner, 'User One');
expect(response.body.ocs.data.single.fileParent, isPositive);
expect(response.body.ocs.data.single.fileSource, isPositive);
expect(response.body.ocs.data.single.fileTarget, '/list-shares.png');
expect(response.body.ocs.data.single.hasPreview, true);
expect(response.body.ocs.data.single.hideDownload, files_sharing.Share_HideDownload.$0);
expect(response.body.ocs.data.single.id, isNotEmpty);
expect(response.body.ocs.data.single.itemMtime, isPositive);
expect(response.body.ocs.data.single.itemPermissions, 27);
expect(response.body.ocs.data.single.itemSize, 8650);
expect(response.body.ocs.data.single.itemSource, isPositive);
expect(response.body.ocs.data.single.itemType, files_sharing.Share_ItemType.file);
expect(response.body.ocs.data.single.label, null);
expect(response.body.ocs.data.single.mailSend, files_sharing.Share_MailSend.$0);
expect(response.body.ocs.data.single.mimetype, 'image/png');
expect(response.body.ocs.data.single.note, '');
expect(response.body.ocs.data.single.path, '/list-shares.png');
expect(response.body.ocs.data.single.permissions, 19);
expect(response.body.ocs.data.single.shareType, core.ShareType.user.index);
expect(response.body.ocs.data.single.shareWith, 'user2');
expect(response.body.ocs.data.single.shareWithDisplayname, 'User Two');
expect(response.body.ocs.data.single.shareWithDisplaynameUnique, 'user2');
expect(response.body.ocs.data.single.stime, isPositive);
expect(response.body.ocs.data.single.storage, isPositive);
expect(response.body.ocs.data.single.storageId, 'home::user1');
expect(response.body.ocs.data.single.uidFileOwner, 'user1');
expect(response.body.ocs.data.single.uidOwner, 'user1');
});
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
PUT http://localhost/remote\.php/webdav/create-share\.png
authorization: Bearer mock
content-length: 8650
content-type: application/xml
ocs-apirequest: true
requesttoken: token
.+
POST http://localhost/ocs/v2\.php/apps/files_sharing/api/v1/shares
accept: application/json
authorization: Bearer mock
content-type: application/json; charset=utf-8
ocs-apirequest: true
\{"shareType":0,"publicUpload":"false","password":"","expireDate":"","note":"","label":"","path":"/create-share\.png","shareWith":"user2"\}
Loading