@@ -91,6 +91,10 @@ public function testShareReceived(): void {
9191 ->method ('isFederationEnabled ' )
9292 ->willReturn (true );
9393
94+ $ this ->calendarFederationConfig ->expects (self ::once ())
95+ ->method ('isIncomingServer2serverShareEnabled ' )
96+ ->willReturn (true );
97+
9498 $ this ->federatedCalendarMapper ->expects (self ::once ())
9599 ->method ('findByUri ' )
96100 ->with (
@@ -150,6 +154,10 @@ public function testShareReceivedWithExistingCalendar(): void {
150154 ->method ('isFederationEnabled ' )
151155 ->willReturn (true );
152156
157+ $ this ->calendarFederationConfig ->expects (self ::once ())
158+ ->method ('isIncomingServer2serverShareEnabled ' )
159+ ->willReturn (true );
160+
153161 $ existingCalendar = new FederatedCalendarEntity ();
154162 $ existingCalendar ->setId (10 );
155163 $ existingCalendar ->setPrincipaluri ('principals/users/sharee1 ' );
@@ -204,6 +212,10 @@ public function testShareReceivedWithInvalidProtocolVersion(): void {
204212 ->method ('isFederationEnabled ' )
205213 ->willReturn (true );
206214
215+ $ this ->calendarFederationConfig ->expects (self ::once ())
216+ ->method ('isIncomingServer2serverShareEnabled ' )
217+ ->willReturn (true );
218+
207219 $ this ->federatedCalendarMapper ->expects (self ::never ())
208220 ->method ('insert ' );
209221 $ this ->jobList ->expects (self ::never ())
@@ -232,6 +244,10 @@ public function testShareReceivedWithoutProtocolVersion(): void {
232244 ->method ('isFederationEnabled ' )
233245 ->willReturn (true );
234246
247+ $ this ->calendarFederationConfig ->expects (self ::once ())
248+ ->method ('isIncomingServer2serverShareEnabled ' )
249+ ->willReturn (true );
250+
235251 $ this ->federatedCalendarMapper ->expects (self ::never ())
236252 ->method ('insert ' );
237253 $ this ->jobList ->expects (self ::never ())
@@ -261,6 +277,30 @@ public function testShareReceivedWithDisabledConfig(): void {
261277 $ this ->calendarFederationProvider ->shareReceived ($ share );
262278 }
263279
280+ public function testShareReceivedWithIncomingServer2serverShareDisabled (): void {
281+ $ share = $ this ->createMock (ICloudFederationShare::class);
282+ $ share ->method ('getShareType ' )
283+ ->willReturn ('user ' );
284+
285+ $ this ->calendarFederationConfig ->expects (self ::once ())
286+ ->method ('isFederationEnabled ' )
287+ ->willReturn (true );
288+
289+ $ this ->calendarFederationConfig ->expects (self ::once ())
290+ ->method ('isIncomingServer2serverShareEnabled ' )
291+ ->willReturn (false );
292+
293+ $ this ->federatedCalendarMapper ->expects (self ::never ())
294+ ->method ('insert ' );
295+ $ this ->jobList ->expects (self ::never ())
296+ ->method ('add ' );
297+
298+ $ this ->expectException (ProviderCouldNotAddShareException::class);
299+ $ this ->expectExceptionMessage ('Instance does not support receiving federated calendar shares ' );
300+ $ this ->expectExceptionCode (503 );
301+ $ this ->calendarFederationProvider ->shareReceived ($ share );
302+ }
303+
264304 public function testShareReceivedWithUnsupportedShareType (): void {
265305 $ share = $ this ->createMock (ICloudFederationShare::class);
266306 $ share ->method ('getShareType ' )
@@ -270,6 +310,10 @@ public function testShareReceivedWithUnsupportedShareType(): void {
270310 ->method ('isFederationEnabled ' )
271311 ->willReturn (true );
272312
313+ $ this ->calendarFederationConfig ->expects (self ::once ())
314+ ->method ('isIncomingServer2serverShareEnabled ' )
315+ ->willReturn (true );
316+
273317 $ this ->federatedCalendarMapper ->expects (self ::never ())
274318 ->method ('insert ' );
275319 $ this ->jobList ->expects (self ::never ())
@@ -322,6 +366,10 @@ public function testShareReceivedWithIncompleteProtocolData(array $protocol): vo
322366 ->method ('isFederationEnabled ' )
323367 ->willReturn (true );
324368
369+ $ this ->calendarFederationConfig ->expects (self ::once ())
370+ ->method ('isIncomingServer2serverShareEnabled ' )
371+ ->willReturn (true );
372+
325373 $ this ->federatedCalendarMapper ->expects (self ::never ())
326374 ->method ('insert ' );
327375 $ this ->jobList ->expects (self ::never ())
@@ -359,6 +407,10 @@ public function testShareReceivedWithReadWriteAccess(): void {
359407 ->method ('isFederationEnabled ' )
360408 ->willReturn (true );
361409
410+ $ this ->calendarFederationConfig ->expects (self ::once ())
411+ ->method ('isIncomingServer2serverShareEnabled ' )
412+ ->willReturn (true );
413+
362414 $ this ->federatedCalendarMapper ->expects (self ::once ())
363415 ->method ('findByUri ' )
364416 ->with (
@@ -418,6 +470,10 @@ public function testShareReceivedWithUnsupportedAccess(): void {
418470 ->method ('isFederationEnabled ' )
419471 ->willReturn (true );
420472
473+ $ this ->calendarFederationConfig ->expects (self ::once ())
474+ ->method ('isIncomingServer2serverShareEnabled ' )
475+ ->willReturn (true );
476+
421477 $ this ->federatedCalendarMapper ->expects (self ::never ())
422478 ->method ('insert ' );
423479 $ this ->jobList ->expects (self ::never ())
0 commit comments