|
|
@ -24,13 +24,13 @@ Future main() async { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Get status', () 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.capabilities, containsAll(['1', '3', 'access-control'])); |
|
|
|
expect(status.searchCapabilities, hasLength(0)); |
|
|
|
expect(status.searchCapabilities, hasLength(0)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('List directory', () async { |
|
|
|
test('List directory', () async { |
|
|
|
final files = await client.webdav!.ls( |
|
|
|
final files = await client.webdav.ls( |
|
|
|
'/', |
|
|
|
'/', |
|
|
|
props: { |
|
|
|
props: { |
|
|
|
WebDavProps.ncHasPreview.name, |
|
|
|
WebDavProps.ncHasPreview.name, |
|
|
@ -48,7 +48,7 @@ Future main() async { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Create directory', () async { |
|
|
|
test('Create directory', () async { |
|
|
|
final response = await client.webdav!.mkdir('test'); |
|
|
|
final response = await client.webdav.mkdir('test'); |
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -56,13 +56,13 @@ Future main() 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.upload(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.upload(txtBytes, 'test.txt'); |
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
expect(response.statusCode, equals(201)); |
|
|
|
|
|
|
|
|
|
|
|
final files = await client.webdav!.ls( |
|
|
|
final files = await client.webdav.ls( |
|
|
|
'/', |
|
|
|
'/', |
|
|
|
props: { |
|
|
|
props: { |
|
|
|
WebDavProps.ocSize.name, |
|
|
|
WebDavProps.ocSize.name, |
|
|
@ -76,31 +76,31 @@ Future main() async { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Copy file', () async { |
|
|
|
test('Copy file', () async { |
|
|
|
final response = await client.webdav!.copy( |
|
|
|
final response = await client.webdav.copy( |
|
|
|
'Nextcloud.png', |
|
|
|
'Nextcloud.png', |
|
|
|
'test.png', |
|
|
|
'test.png', |
|
|
|
); |
|
|
|
); |
|
|
|
expect(response.statusCode, 201); |
|
|
|
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 == 'Nextcloud.png'), hasLength(1)); |
|
|
|
expect(files.where((final f) => f.name == 'test.png'), hasLength(1)); |
|
|
|
expect(files.where((final f) => f.name == '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.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('2')), '2.txt'); |
|
|
|
|
|
|
|
|
|
|
|
expect( |
|
|
|
expect( |
|
|
|
() => client.webdav!.copy('1.txt', '2.txt'), |
|
|
|
() => client.webdav.copy('1.txt', '2.txt'), |
|
|
|
throwsA(predicate((final e) => (e! as ApiException).code == 412)), |
|
|
|
throwsA(predicate((final e) => (e! as ApiException).code == 412)), |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
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.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('2')), '2.txt'); |
|
|
|
|
|
|
|
|
|
|
|
final response = await client.webdav!.copy( |
|
|
|
final response = await client.webdav.copy( |
|
|
|
'1.txt', |
|
|
|
'1.txt', |
|
|
|
'2.txt', |
|
|
|
'2.txt', |
|
|
|
overwrite: true, |
|
|
|
overwrite: true, |
|
|
@ -109,31 +109,31 @@ Future main() async { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Move file', () async { |
|
|
|
test('Move file', () async { |
|
|
|
final response = await client.webdav!.move( |
|
|
|
final response = await client.webdav.move( |
|
|
|
'Nextcloud.png', |
|
|
|
'Nextcloud.png', |
|
|
|
'test.png', |
|
|
|
'test.png', |
|
|
|
); |
|
|
|
); |
|
|
|
expect(response.statusCode, 201); |
|
|
|
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 == 'Nextcloud.png'), hasLength(0)); |
|
|
|
expect(files.where((final f) => f.name == 'test.png'), hasLength(1)); |
|
|
|
expect(files.where((final f) => f.name == '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.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('2')), '2.txt'); |
|
|
|
|
|
|
|
|
|
|
|
expect( |
|
|
|
expect( |
|
|
|
() => client.webdav!.move('1.txt', '2.txt'), |
|
|
|
() => client.webdav.move('1.txt', '2.txt'), |
|
|
|
throwsA(predicate((final e) => (e! as ApiException).code == 412)), |
|
|
|
throwsA(predicate((final e) => (e! as ApiException).code == 412)), |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
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.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('2')), '2.txt'); |
|
|
|
|
|
|
|
|
|
|
|
final response = await client.webdav!.move( |
|
|
|
final response = await client.webdav.move( |
|
|
|
'1.txt', |
|
|
|
'1.txt', |
|
|
|
'2.txt', |
|
|
|
'2.txt', |
|
|
|
overwrite: true, |
|
|
|
overwrite: true, |
|
|
@ -142,7 +142,7 @@ Future main() async { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Get file props', () async { |
|
|
|
test('Get file props', () async { |
|
|
|
final file = await client.webdav!.getProps( |
|
|
|
final file = await client.webdav.getProps( |
|
|
|
'Nextcloud.png', |
|
|
|
'Nextcloud.png', |
|
|
|
props: { |
|
|
|
props: { |
|
|
|
WebDavProps.ncHasPreview.name, |
|
|
|
WebDavProps.ncHasPreview.name, |
|
|
@ -159,10 +159,10 @@ Future main() async { |
|
|
|
|
|
|
|
|
|
|
|
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.mkdir('test'); |
|
|
|
await client.webdav!.upload(data, 'test/test.txt'); |
|
|
|
await client.webdav.upload(data, 'test/test.txt'); |
|
|
|
|
|
|
|
|
|
|
|
final file = await client.webdav!.getProps( |
|
|
|
final file = await client.webdav.getProps( |
|
|
|
'test', |
|
|
|
'test', |
|
|
|
props: { |
|
|
|
props: { |
|
|
|
WebDavProps.davResourceType.name, |
|
|
|
WebDavProps.davResourceType.name, |
|
|
@ -179,11 +179,11 @@ Future main() async { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
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.upload(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('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', |
|
|
|
WebDavProps.ocFavorite.name: '1', |
|
|
@ -204,15 +204,15 @@ Future main() async { |
|
|
|
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.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.ocFavorite.name: '1', |
|
|
|
WebDavProps.ncCreationTime.name: '$createdEpoch', |
|
|
|
WebDavProps.ncCreationTime.name: '$createdEpoch', |
|
|
|
}); |
|
|
|
}); |
|
|
|
expect(updated, isTrue); |
|
|
|
expect(updated, isTrue); |
|
|
|
|
|
|
|
|
|
|
|
final file = await client.webdav!.getProps( |
|
|
|
final file = await client.webdav.getProps( |
|
|
|
'test.txt', |
|
|
|
'test.txt', |
|
|
|
props: { |
|
|
|
props: { |
|
|
|
WebDavProps.ocFavorite.name, |
|
|
|
WebDavProps.ocFavorite.name, |
|
|
@ -226,16 +226,16 @@ Future main() async { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Set custom properties', () 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', |
|
|
|
'test:custom': 'test-custom-prop-value', |
|
|
|
}); |
|
|
|
}); |
|
|
|
expect(updated, isTrue); |
|
|
|
expect(updated, isTrue); |
|
|
|
|
|
|
|
|
|
|
|
final file = await client.webdav!.getProps( |
|
|
|
final file = await client.webdav.getProps( |
|
|
|
'test.txt', |
|
|
|
'test.txt', |
|
|
|
props: { |
|
|
|
props: { |
|
|
|
'test:custom', |
|
|
|
'test:custom', |
|
|
|