|
|
|
@ -24,13 +24,13 @@ Future main() async {
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('Get status', () async { |
|
|
|
|
final status = await client.webdav!.status(); |
|
|
|
|
final status = await client.webdav.status(); |
|
|
|
|
expect(status.capabilities, containsAll(['1', '3', 'access-control'])); |
|
|
|
|
expect(status.searchCapabilities, hasLength(0)); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('List directory', () async { |
|
|
|
|
final files = await client.webdav!.ls( |
|
|
|
|
final files = await client.webdav.ls( |
|
|
|
|
'/', |
|
|
|
|
props: { |
|
|
|
|
WebDavProps.ncHasPreview.name, |
|
|
|
@ -48,7 +48,7 @@ Future main() async {
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('Create directory', () async { |
|
|
|
|
final response = await client.webdav!.mkdir('test'); |
|
|
|
|
final response = await client.webdav.mkdir('test'); |
|
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -56,13 +56,13 @@ Future main() async {
|
|
|
|
|
final pngBytes = File('test/files/test.png').readAsBytesSync(); |
|
|
|
|
final txtBytes = File('test/files/test.txt').readAsBytesSync(); |
|
|
|
|
|
|
|
|
|
var response = await client.webdav!.upload(pngBytes, 'test.png'); |
|
|
|
|
var response = await client.webdav.upload(pngBytes, 'test.png'); |
|
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
|
|
|
|
|
|
response = await client.webdav!.upload(txtBytes, 'test.txt'); |
|
|
|
|
response = await client.webdav.upload(txtBytes, 'test.txt'); |
|
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
|
|
|
|
|
|
final files = await client.webdav!.ls( |
|
|
|
|
final files = await client.webdav.ls( |
|
|
|
|
'/', |
|
|
|
|
props: { |
|
|
|
|
WebDavProps.ocSize.name, |
|
|
|
@ -76,31 +76,31 @@ Future main() async {
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('Copy file', () async { |
|
|
|
|
final response = await client.webdav!.copy( |
|
|
|
|
final response = await client.webdav.copy( |
|
|
|
|
'Nextcloud.png', |
|
|
|
|
'test.png', |
|
|
|
|
); |
|
|
|
|
expect(response.statusCode, 201); |
|
|
|
|
final files = await client.webdav!.ls('/'); |
|
|
|
|
final files = await client.webdav.ls('/'); |
|
|
|
|
expect(files.where((final f) => f.name == 'Nextcloud.png'), hasLength(1)); |
|
|
|
|
expect(files.where((final f) => f.name == 'test.png'), hasLength(1)); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('Copy file (overwrite fail)', () async { |
|
|
|
|
await client.webdav!.upload(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
|
await client.webdav!.upload(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
|
|
|
|
|
|
expect( |
|
|
|
|
() => client.webdav!.copy('1.txt', '2.txt'), |
|
|
|
|
() => client.webdav.copy('1.txt', '2.txt'), |
|
|
|
|
throwsA(predicate((final e) => (e! as ApiException).code == 412)), |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('Copy file (overwrite success)', () async { |
|
|
|
|
await client.webdav!.upload(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
|
await client.webdav!.upload(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
|
|
|
|
|
|
final response = await client.webdav!.copy( |
|
|
|
|
final response = await client.webdav.copy( |
|
|
|
|
'1.txt', |
|
|
|
|
'2.txt', |
|
|
|
|
overwrite: true, |
|
|
|
@ -109,31 +109,31 @@ Future main() async {
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('Move file', () async { |
|
|
|
|
final response = await client.webdav!.move( |
|
|
|
|
final response = await client.webdav.move( |
|
|
|
|
'Nextcloud.png', |
|
|
|
|
'test.png', |
|
|
|
|
); |
|
|
|
|
expect(response.statusCode, 201); |
|
|
|
|
final files = await client.webdav!.ls('/'); |
|
|
|
|
final files = await client.webdav.ls('/'); |
|
|
|
|
expect(files.where((final f) => f.name == 'Nextcloud.png'), hasLength(0)); |
|
|
|
|
expect(files.where((final f) => f.name == 'test.png'), hasLength(1)); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('Move file (overwrite fail)', () async { |
|
|
|
|
await client.webdav!.upload(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
|
await client.webdav!.upload(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
|
|
|
|
|
|
expect( |
|
|
|
|
() => client.webdav!.move('1.txt', '2.txt'), |
|
|
|
|
() => client.webdav.move('1.txt', '2.txt'), |
|
|
|
|
throwsA(predicate((final e) => (e! as ApiException).code == 412)), |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('Move file (overwrite success)', () async { |
|
|
|
|
await client.webdav!.upload(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
|
await client.webdav!.upload(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('1')), '1.txt'); |
|
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('2')), '2.txt'); |
|
|
|
|
|
|
|
|
|
final response = await client.webdav!.move( |
|
|
|
|
final response = await client.webdav.move( |
|
|
|
|
'1.txt', |
|
|
|
|
'2.txt', |
|
|
|
|
overwrite: true, |
|
|
|
@ -142,7 +142,7 @@ Future main() async {
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('Get file props', () async { |
|
|
|
|
final file = await client.webdav!.getProps( |
|
|
|
|
final file = await client.webdav.getProps( |
|
|
|
|
'Nextcloud.png', |
|
|
|
|
props: { |
|
|
|
|
WebDavProps.ncHasPreview.name, |
|
|
|
@ -159,10 +159,10 @@ Future main() async {
|
|
|
|
|
|
|
|
|
|
test('Get directory props', () async { |
|
|
|
|
final data = Uint8List.fromList(utf8.encode('test')); |
|
|
|
|
await client.webdav!.mkdir('test'); |
|
|
|
|
await client.webdav!.upload(data, 'test/test.txt'); |
|
|
|
|
await client.webdav.mkdir('test'); |
|
|
|
|
await client.webdav.upload(data, 'test/test.txt'); |
|
|
|
|
|
|
|
|
|
final file = await client.webdav!.getProps( |
|
|
|
|
final file = await client.webdav.getProps( |
|
|
|
|
'test', |
|
|
|
|
props: { |
|
|
|
|
WebDavProps.davResourceType.name, |
|
|
|
@ -179,11 +179,11 @@ Future main() async {
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('Filter files', () async { |
|
|
|
|
final response = await client.webdav!.upload(Uint8List.fromList(utf8.encode('test')), 'test.txt'); |
|
|
|
|
final response = await client.webdav.upload(Uint8List.fromList(utf8.encode('test')), 'test.txt'); |
|
|
|
|
final id = response.headers['oc-fileid']!.first; |
|
|
|
|
await client.webdav!.updateProps('test.txt', {WebDavProps.ocFavorite.name: '1'}); |
|
|
|
|
await client.webdav.updateProps('test.txt', {WebDavProps.ocFavorite.name: '1'}); |
|
|
|
|
|
|
|
|
|
final files = await client.webdav!.filter( |
|
|
|
|
final files = await client.webdav.filter( |
|
|
|
|
'/', |
|
|
|
|
{ |
|
|
|
|
WebDavProps.ocFavorite.name: '1', |
|
|
|
@ -204,15 +204,15 @@ Future main() async {
|
|
|
|
|
final createdEpoch = createdDate.millisecondsSinceEpoch / 1000; |
|
|
|
|
final uploadTime = DateTime.now(); |
|
|
|
|
|
|
|
|
|
await client.webdav!.upload(Uint8List.fromList(utf8.encode('test')), 'test.txt'); |
|
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('test')), 'test.txt'); |
|
|
|
|
|
|
|
|
|
final updated = await client.webdav!.updateProps('test.txt', { |
|
|
|
|
final updated = await client.webdav.updateProps('test.txt', { |
|
|
|
|
WebDavProps.ocFavorite.name: '1', |
|
|
|
|
WebDavProps.ncCreationTime.name: '$createdEpoch', |
|
|
|
|
}); |
|
|
|
|
expect(updated, isTrue); |
|
|
|
|
|
|
|
|
|
final file = await client.webdav!.getProps( |
|
|
|
|
final file = await client.webdav.getProps( |
|
|
|
|
'test.txt', |
|
|
|
|
props: { |
|
|
|
|
WebDavProps.ocFavorite.name, |
|
|
|
@ -226,16 +226,16 @@ Future main() async {
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('Set custom properties', () async { |
|
|
|
|
client.webdav!.registerNamespace('http://example.com/ns', 'test'); |
|
|
|
|
client.webdav.registerNamespace('http://example.com/ns', 'test'); |
|
|
|
|
|
|
|
|
|
await client.webdav!.upload(Uint8List.fromList(utf8.encode('test')), 'test.txt'); |
|
|
|
|
await client.webdav.upload(Uint8List.fromList(utf8.encode('test')), 'test.txt'); |
|
|
|
|
|
|
|
|
|
final updated = await client.webdav!.updateProps('test.txt', { |
|
|
|
|
final updated = await client.webdav.updateProps('test.txt', { |
|
|
|
|
'test:custom': 'test-custom-prop-value', |
|
|
|
|
}); |
|
|
|
|
expect(updated, isTrue); |
|
|
|
|
|
|
|
|
|
final file = await client.webdav!.getProps( |
|
|
|
|
final file = await client.webdav.getProps( |
|
|
|
|
'test.txt', |
|
|
|
|
props: { |
|
|
|
|
'test:custom', |
|
|
|
|