Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(nextcloud)!: Return raw response in WebDAV proppatch #2563

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
13 changes: 2 additions & 11 deletions packages/nextcloud/lib/src/api/webdav/webdav_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,11 @@ class WebDavClient extends DynamiteClient {
///
/// The props in [set] will be added/updated.
/// The props in [remove] will be removed.
/// Returns true if the update was successful.
///
/// See:
/// * http://www.webdav.org/specs/rfc2518.html#METHOD_PROPPATCH for more information.
/// * [proppatch_Request] for the request sent by this method.
Future<bool> proppatch(
Future<WebDavMultistatus> proppatch(
PathUri path, {
WebDavProp? set,
WebDavPropWithoutValues? remove,
Expand All @@ -612,15 +611,7 @@ class WebDavClient extends DynamiteClient {
throw DynamiteStatusCodeException(response);
}

final data = const WebDavResponseConverter().convert(response);
for (final a in data.responses) {
for (final b in a.propstats) {
if (!b.status.contains('200')) {
return false;
}
}
}
return true;
return const WebDavResponseConverter().convert(response);
}

/// Returns a request to move the resource from [sourcePath] to [destinationPath].
Expand Down
30 changes: 21 additions & 9 deletions packages/nextcloud/test/api/webdav/webdav_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,16 @@ void main() {
created: createdDate,
);

final updated = await tester.client.webdav.proppatch(
final response = await tester.client.webdav.proppatch(
PathUri.parse('test/set-props.txt'),
set: const WebDavProp(
ocFavorite: true,
),
);
expect(updated, isTrue);
expect(
response.responses.where((r) => r.propstats.where((ps) => !ps.status.contains('200 OK')).isNotEmpty),
isEmpty,
);

final props = (await tester.client.webdav.propfind(
PathUri.parse('test/set-props.txt'),
Expand All @@ -440,13 +443,16 @@ void main() {
test('Remove properties', () async {
await tester.client.webdav.put(utf8.encode('test'), PathUri.parse('test/remove-props.txt'));

var updated = await tester.client.webdav.proppatch(
var response = await tester.client.webdav.proppatch(
PathUri.parse('test/remove-props.txt'),
set: const WebDavProp(
ocFavorite: true,
),
);
expect(updated, isTrue);
expect(
response.responses.where((r) => r.propstats.where((ps) => !ps.status.contains('200 OK')).isNotEmpty),
isEmpty,
);

var props = (await tester.client.webdav.propfind(
PathUri.parse('test/remove-props.txt'),
Expand All @@ -463,13 +469,16 @@ void main() {
.prop;
expect(props.ocFavorite, true);

updated = await tester.client.webdav.proppatch(
response = await tester.client.webdav.proppatch(
PathUri.parse('test/remove-props.txt'),
remove: const WebDavPropWithoutValues.fromBools(
ocFavorite: true,
),
);
expect(updated, isFalse);
expect(
response.responses.where((r) => r.propstats.where((ps) => !ps.status.contains('200 OK')).isNotEmpty),
isNotEmpty,
);

props = (await tester.client.webdav.propfind(
PathUri.parse('test/remove-props.txt'),
Expand All @@ -491,15 +500,18 @@ void main() {
PathUri.parse('test/tags.txt'),
);

final updated = await tester.client.webdav.proppatch(
var response = await tester.client.webdav.proppatch(
PathUri.parse('test/tags.txt'),
set: const WebDavProp(
ocTags: WebDavOcTags(tags: ['example']),
),
);
expect(updated, isTrue);
expect(
response.responses.where((r) => r.propstats.where((ps) => !ps.status.contains('200 OK')).isNotEmpty),
isEmpty,
);

final response = await tester.client.webdav.propfind(
response = await tester.client.webdav.propfind(
PathUri.parse('test/tags.txt'),
prop: const WebDavPropWithoutValues.fromBools(
ocTags: true,
Expand Down