mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(dav): Fix PHP warnings triggered by tests in dav application
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
4fe0696e33
commit
88fc8c94ce
3 changed files with 10 additions and 3 deletions
|
|
@ -63,6 +63,13 @@ class CalendarFederationProvider implements ICloudFederationProvider {
|
|||
}
|
||||
|
||||
$rawProtocol = $share->getProtocol();
|
||||
if (!isset($rawProtocol[ICalendarFederationProtocol::PROP_VERSION])) {
|
||||
throw new ProviderCouldNotAddShareException(
|
||||
'No protocol version',
|
||||
'',
|
||||
Http::STATUS_BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
switch ($rawProtocol[ICalendarFederationProtocol::PROP_VERSION]) {
|
||||
case CalendarFederationProtocolV1::VERSION:
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@ class FederationSharingService {
|
|||
*/
|
||||
private function decodeRemoteUserPrincipal(string $principal): ?string {
|
||||
// Expected format: principals/remote-users/abcdef123
|
||||
[$prefix, $collection, $encodedId] = explode('/', $principal);
|
||||
if ($prefix !== 'principals' || $collection !== 'remote-users') {
|
||||
if (!str_starts_with($principal, 'principals/remote-users/')) {
|
||||
return null;
|
||||
}
|
||||
$encodedId = substr($principal, strlen('principals/remote-users/'));
|
||||
|
||||
$decodedId = base64_decode($encodedId);
|
||||
if (!is_string($decodedId)) {
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ class CalendarFederationProviderTest extends TestCase {
|
|||
->method('add');
|
||||
|
||||
$this->expectException(ProviderCouldNotAddShareException::class);
|
||||
$this->expectExceptionMessage('Unknown protocol version');
|
||||
$this->expectExceptionMessage('No protocol version');
|
||||
$this->expectExceptionCode(400);
|
||||
$this->assertEquals(10, $this->calendarFederationProvider->shareReceived($share));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue