|
|
@ -24,15 +24,15 @@ void main() { |
|
|
|
tearDown(() => container.destroy()); |
|
|
|
tearDown(() => container.destroy()); |
|
|
|
|
|
|
|
|
|
|
|
test('Get status', () async { |
|
|
|
test('Get status', () async { |
|
|
|
final status = await client.webdav.status(); |
|
|
|
final options = await client.webdav.options(); |
|
|
|
expect(status.capabilities, containsAll(['1', '3'])); |
|
|
|
expect(options.capabilities, containsAll(['1', '3'])); |
|
|
|
expect(status.searchCapabilities, hasLength(0)); |
|
|
|
expect(options.searchCapabilities, hasLength(0)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('List directory', () async { |
|
|
|
test('List directory', () async { |
|
|
|
final responses = (await client.webdav.ls( |
|
|
|
final responses = (await client.webdav.propfind( |
|
|
|
'/', |
|
|
|
'/', |
|
|
|
prop: WebDavPropfindProp.fromBools( |
|
|
|
prop: WebDavPropWithoutValues.fromBools( |
|
|
|
nchaspreview: true, |
|
|
|
nchaspreview: true, |
|
|
|
davgetcontenttype: true, |
|
|
|
davgetcontenttype: true, |
|
|
|
davgetlastmodified: true, |
|
|
|
davgetlastmodified: true, |
|
|
@ -50,7 +50,7 @@ void main() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('List directory recursively', () async { |
|
|
|
test('List directory recursively', () async { |
|
|
|
final responses = (await client.webdav.ls( |
|
|
|
final responses = (await client.webdav.propfind( |
|
|
|
'/', |
|
|
|
'/', |
|
|
|
depth: 'infinity', |
|
|
|
depth: 'infinity', |
|
|
|
)) |
|
|
|
)) |
|
|
@ -59,32 +59,23 @@ void main() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Create directory', () async { |
|
|
|
test('Create directory', () async { |
|
|
|
final response = await client.webdav.mkdir('test'); |
|
|
|
final response = await client.webdav.mkcol('test'); |
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Create directory recursively', () async { |
|
|
|
|
|
|
|
final response = await client.webdav.mkdirs('test/bla'); |
|
|
|
|
|
|
|
expect(response!.statusCode, equals(201)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final responses = (await client.webdav.ls('/test')).responses; |
|
|
|
|
|
|
|
expect(responses, hasLength(2)); |
|
|
|
|
|
|
|
expect(responses[1].href, endsWith('/test/bla/')); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('Upload files', () async { |
|
|
|
test('Upload files', () async { |
|
|
|
final pngBytes = File('test/files/test.png').readAsBytesSync(); |
|
|
|
final pngBytes = File('test/files/test.png').readAsBytesSync(); |
|
|
|
final txtBytes = File('test/files/test.txt').readAsBytesSync(); |
|
|
|
final txtBytes = File('test/files/test.txt').readAsBytesSync(); |
|
|
|
|
|
|
|
|
|
|
|
var response = await client.webdav.upload(pngBytes, 'test.png'); |
|
|
|
var response = await client.webdav.put(pngBytes, 'test.png'); |
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
|
|
|
|
|
|
|
|
response = await client.webdav.upload(txtBytes, 'test.txt'); |
|
|
|
response = await client.webdav.put(txtBytes, 'test.txt'); |
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
|
|
|
|
|
|
|
|
final responses = (await client.webdav.ls( |
|
|
|
final responses = (await client.webdav.propfind( |
|
|
|
'/', |
|
|
|
'/', |
|
|
|
prop: WebDavPropfindProp.fromBools( |
|
|
|
prop: WebDavPropWithoutValues.fromBools( |
|
|
|
ocsize: true, |
|
|
|
ocsize: true, |
|
|
|
), |
|
|
|
), |
|
|
|
)) |
|
|
|
)) |
|
|
@ -105,7 +96,7 @@ void main() { |
|
|
|
final created = lastModified.subtract(const Duration(hours: 1)); |
|
|
|
final created = lastModified.subtract(const Duration(hours: 1)); |
|
|
|
final txtBytes = File('test/files/test.txt').readAsBytesSync(); |
|
|
|
final txtBytes = File('test/files/test.txt').readAsBytesSync(); |
|
|
|
|
|
|
|
|
|
|
|
final response = await client.webdav.upload( |
|
|
|
final response = await client.webdav.put( |
|
|
|
txtBytes, |
|
|
|
txtBytes, |
|
|
|
'test.txt', |
|
|
|
'test.txt', |
|
|
|
lastModified: lastModified, |
|
|
|
lastModified: lastModified, |
|
|
@ -113,9 +104,9 @@ void main() { |
|
|
|
); |
|
|
|
); |
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
|
|
|
|
|
|
|
|
final props = (await client.webdav.ls( |
|
|
|
final props = (await client.webdav.propfind( |
|
|
|
'/', |
|
|
|
'/', |
|
|
|
prop: WebDavPropfindProp.fromBools( |
|
|
|
prop: WebDavPropWithoutValues.fromBools( |
|
|
|
davgetlastmodified: true, |
|
|
|
davgetlastmodified: true, |
|
|
|
nccreationtime: true, |
|
|
|
nccreationtime: true, |
|
|
|
), |
|
|
|
), |
|
|
@ -136,14 +127,14 @@ void main() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Download file', () async { |
|
|
|
test('Download file', () async { |
|
|
|
final response = await client.webdav.download('Nextcloud.png'); |
|
|
|
final response = await client.webdav.get('Nextcloud.png'); |
|
|
|
expect(response, isNotEmpty); |
|
|
|
expect(response, isNotEmpty); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Delete file', () async { |
|
|
|
test('Delete file', () async { |
|
|
|
final response = await client.webdav.delete('Nextcloud.png'); |
|
|
|
final response = await client.webdav.delete('Nextcloud.png'); |
|
|
|
expect(response.statusCode, 204); |
|
|
|
expect(response.statusCode, 204); |
|
|
|
final responses = (await client.webdav.ls('/')).responses; |
|
|
|
final responses = (await client.webdav.propfind('/')).responses; |
|
|
|
expect(responses.where((final response) => response.href!.endsWith('/Nextcloud.png')), hasLength(0)); |
|
|
|
expect(responses.where((final response) => response.href!.endsWith('/Nextcloud.png')), hasLength(0)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -153,14 +144,14 @@ void main() { |
|
|
|
'test.png', |
|
|
|
'test.png', |
|
|
|
); |
|
|
|
); |
|
|
|
expect(response.statusCode, 201); |
|
|
|
expect(response.statusCode, 201); |
|
|
|
final responses = (await client.webdav.ls('/')).responses; |
|
|
|
final responses = (await client.webdav.propfind('/')).responses; |
|
|
|
expect(responses.where((final response) => response.href!.endsWith('/Nextcloud.png')), hasLength(1)); |
|
|
|
expect(responses.where((final response) => response.href!.endsWith('/Nextcloud.png')), hasLength(1)); |
|
|
|
expect(responses.where((final response) => response.href!.endsWith('/test.png')), hasLength(1)); |
|
|
|
expect(responses.where((final response) => response.href!.endsWith('/test.png')), hasLength(1)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Copy file (overwrite fail)', () async { |
|
|
|
test('Copy file (overwrite fail)', () async { |
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
await client.webdav.put(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
await client.webdav.put(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
|
|
|
|
|
|
|
|
expect( |
|
|
|
expect( |
|
|
|
() => client.webdav.copy('1.txt', '2.txt'), |
|
|
|
() => client.webdav.copy('1.txt', '2.txt'), |
|
|
@ -169,8 +160,8 @@ void main() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Copy file (overwrite success)', () async { |
|
|
|
test('Copy file (overwrite success)', () async { |
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
await client.webdav.put(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
await client.webdav.put(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
|
|
|
|
|
|
|
|
final response = await client.webdav.copy( |
|
|
|
final response = await client.webdav.copy( |
|
|
|
'1.txt', |
|
|
|
'1.txt', |
|
|
@ -186,14 +177,14 @@ void main() { |
|
|
|
'test.png', |
|
|
|
'test.png', |
|
|
|
); |
|
|
|
); |
|
|
|
expect(response.statusCode, 201); |
|
|
|
expect(response.statusCode, 201); |
|
|
|
final responses = (await client.webdav.ls('/')).responses; |
|
|
|
final responses = (await client.webdav.propfind('/')).responses; |
|
|
|
expect(responses.where((final response) => response.href!.endsWith('/Nextcloud.png')), hasLength(0)); |
|
|
|
expect(responses.where((final response) => response.href!.endsWith('/Nextcloud.png')), hasLength(0)); |
|
|
|
expect(responses.where((final response) => response.href!.endsWith('/test.png')), hasLength(1)); |
|
|
|
expect(responses.where((final response) => response.href!.endsWith('/test.png')), hasLength(1)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Move file (overwrite fail)', () async { |
|
|
|
test('Move file (overwrite fail)', () async { |
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
await client.webdav.put(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
await client.webdav.put(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
|
|
|
|
|
|
|
|
expect( |
|
|
|
expect( |
|
|
|
() => client.webdav.move('1.txt', '2.txt'), |
|
|
|
() => client.webdav.move('1.txt', '2.txt'), |
|
|
@ -202,8 +193,8 @@ void main() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Move file (overwrite success)', () async { |
|
|
|
test('Move file (overwrite success)', () async { |
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
await client.webdav.put(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
await client.webdav.put(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
|
|
|
|
|
|
|
|
final response = await client.webdav.move( |
|
|
|
final response = await client.webdav.move( |
|
|
|
'1.txt', |
|
|
|
'1.txt', |
|
|
@ -214,9 +205,9 @@ void main() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Get file props', () async { |
|
|
|
test('Get file props', () async { |
|
|
|
final response = (await client.webdav.ls( |
|
|
|
final response = (await client.webdav.propfind( |
|
|
|
'Nextcloud.png', |
|
|
|
'Nextcloud.png', |
|
|
|
prop: WebDavPropfindProp.fromBools( |
|
|
|
prop: WebDavPropWithoutValues.fromBools( |
|
|
|
davgetlastmodified: true, |
|
|
|
davgetlastmodified: true, |
|
|
|
davgetetag: true, |
|
|
|
davgetetag: true, |
|
|
|
davgetcontenttype: true, |
|
|
|
davgetcontenttype: true, |
|
|
@ -298,12 +289,12 @@ void main() { |
|
|
|
|
|
|
|
|
|
|
|
test('Get directory props', () async { |
|
|
|
test('Get directory props', () async { |
|
|
|
final data = Uint8List.fromList(utf8.encode('test')); |
|
|
|
final data = Uint8List.fromList(utf8.encode('test')); |
|
|
|
await client.webdav.mkdir('test'); |
|
|
|
await client.webdav.mkcol('test'); |
|
|
|
await client.webdav.upload(data, 'test/test.txt'); |
|
|
|
await client.webdav.put(data, 'test/test.txt'); |
|
|
|
|
|
|
|
|
|
|
|
final response = (await client.webdav.ls( |
|
|
|
final response = (await client.webdav.propfind( |
|
|
|
'test', |
|
|
|
'test', |
|
|
|
prop: WebDavPropfindProp.fromBools( |
|
|
|
prop: WebDavPropWithoutValues.fromBools( |
|
|
|
davgetcontenttype: true, |
|
|
|
davgetcontenttype: true, |
|
|
|
davgetlastmodified: true, |
|
|
|
davgetlastmodified: true, |
|
|
|
davresourcetype: true, |
|
|
|
davresourcetype: true, |
|
|
@ -329,21 +320,21 @@ void main() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Filter files', () async { |
|
|
|
test('Filter files', () async { |
|
|
|
final response = await client.webdav.upload(Uint8List.fromList(utf8.encode('test')), 'test.txt'); |
|
|
|
final response = await client.webdav.put(Uint8List.fromList(utf8.encode('test')), 'test.txt'); |
|
|
|
final id = response.headers['oc-fileid']!.first; |
|
|
|
final id = response.headers['oc-fileid']!.first; |
|
|
|
await client.webdav.updateProps( |
|
|
|
await client.webdav.proppatch( |
|
|
|
'test.txt', |
|
|
|
'test.txt', |
|
|
|
WebDavProp( |
|
|
|
set: WebDavProp( |
|
|
|
ocfavorite: 1, |
|
|
|
ocfavorite: 1, |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
final responses = (await client.webdav.filter( |
|
|
|
final responses = (await client.webdav.report( |
|
|
|
'/', |
|
|
|
'/', |
|
|
|
WebDavOcFilterRules( |
|
|
|
WebDavOcFilterRules( |
|
|
|
ocfavorite: 1, |
|
|
|
ocfavorite: 1, |
|
|
|
), |
|
|
|
), |
|
|
|
prop: WebDavPropfindProp.fromBools( |
|
|
|
prop: WebDavPropWithoutValues.fromBools( |
|
|
|
ocid: true, |
|
|
|
ocid: true, |
|
|
|
ocfavorite: true, |
|
|
|
ocfavorite: true, |
|
|
|
), |
|
|
|
), |
|
|
@ -361,20 +352,20 @@ void main() { |
|
|
|
final createdEpoch = createdDate.millisecondsSinceEpoch ~/ 1000; |
|
|
|
final createdEpoch = createdDate.millisecondsSinceEpoch ~/ 1000; |
|
|
|
final uploadTime = DateTime.now(); |
|
|
|
final uploadTime = DateTime.now(); |
|
|
|
|
|
|
|
|
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('test')), 'test.txt'); |
|
|
|
await client.webdav.put(Uint8List.fromList(utf8.encode('test')), 'test.txt'); |
|
|
|
|
|
|
|
|
|
|
|
final updated = await client.webdav.updateProps( |
|
|
|
final updated = await client.webdav.proppatch( |
|
|
|
'test.txt', |
|
|
|
'test.txt', |
|
|
|
WebDavProp( |
|
|
|
set: WebDavProp( |
|
|
|
ocfavorite: 1, |
|
|
|
ocfavorite: 1, |
|
|
|
nccreationtime: createdEpoch, |
|
|
|
nccreationtime: createdEpoch, |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
expect(updated, isTrue); |
|
|
|
expect(updated, isTrue); |
|
|
|
|
|
|
|
|
|
|
|
final props = (await client.webdav.ls( |
|
|
|
final props = (await client.webdav.propfind( |
|
|
|
'test.txt', |
|
|
|
'test.txt', |
|
|
|
prop: WebDavPropfindProp.fromBools( |
|
|
|
prop: WebDavPropWithoutValues.fromBools( |
|
|
|
ocfavorite: true, |
|
|
|
ocfavorite: true, |
|
|
|
nccreationtime: true, |
|
|
|
nccreationtime: true, |
|
|
|
ncuploadtime: true, |
|
|
|
ncuploadtime: true, |
|
|
@ -389,5 +380,53 @@ void main() { |
|
|
|
expect(DateTime.fromMillisecondsSinceEpoch(props.nccreationtime! * 1000).isAtSameMomentAs(createdDate), isTrue); |
|
|
|
expect(DateTime.fromMillisecondsSinceEpoch(props.nccreationtime! * 1000).isAtSameMomentAs(createdDate), isTrue); |
|
|
|
expectDateInReasonableTimeRange(DateTime.fromMillisecondsSinceEpoch(props.ncuploadtime! * 1000), uploadTime); |
|
|
|
expectDateInReasonableTimeRange(DateTime.fromMillisecondsSinceEpoch(props.ncuploadtime! * 1000), uploadTime); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('Remove properties', () async { |
|
|
|
|
|
|
|
await client.webdav.put(Uint8List.fromList(utf8.encode('test')), 'test.txt'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var updated = await client.webdav.proppatch( |
|
|
|
|
|
|
|
'test.txt', |
|
|
|
|
|
|
|
set: WebDavProp( |
|
|
|
|
|
|
|
ocfavorite: 1, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
expect(updated, isTrue); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var props = (await client.webdav.propfind( |
|
|
|
|
|
|
|
'test.txt', |
|
|
|
|
|
|
|
prop: WebDavPropWithoutValues.fromBools( |
|
|
|
|
|
|
|
ocfavorite: true, |
|
|
|
|
|
|
|
nccreationtime: true, |
|
|
|
|
|
|
|
ncuploadtime: true, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
)) |
|
|
|
|
|
|
|
.responses |
|
|
|
|
|
|
|
.single |
|
|
|
|
|
|
|
.propstats |
|
|
|
|
|
|
|
.first |
|
|
|
|
|
|
|
.prop; |
|
|
|
|
|
|
|
expect(props.ocfavorite, 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updated = await client.webdav.proppatch( |
|
|
|
|
|
|
|
'test.txt', |
|
|
|
|
|
|
|
remove: WebDavPropWithoutValues.fromBools( |
|
|
|
|
|
|
|
ocfavorite: true, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
expect(updated, isFalse); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
props = (await client.webdav.propfind( |
|
|
|
|
|
|
|
'test.txt', |
|
|
|
|
|
|
|
prop: WebDavPropWithoutValues.fromBools( |
|
|
|
|
|
|
|
ocfavorite: true, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
)) |
|
|
|
|
|
|
|
.responses |
|
|
|
|
|
|
|
.single |
|
|
|
|
|
|
|
.propstats |
|
|
|
|
|
|
|
.first |
|
|
|
|
|
|
|
.prop; |
|
|
|
|
|
|
|
expect(props.ocfavorite, 0); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|