@@ -524,6 +524,86 @@ public function userSendsTheFollowingResourceShareInvitationToFederatedUserUsing
524
524
);
525
525
}
526
526
527
+ /**
528
+ * @When user :user sends the following resources share invitation concurrently to federated user using the Graph API:
529
+ *
530
+ * @param string $user
531
+ * @param TableNode $table
532
+ *
533
+ * @return void
534
+ */
535
+ public function userSendsTheFollowingResourcesShareInvitationConcurrentlyToFederatedUserUsingTheGraphApi (
536
+ string $ user ,
537
+ TableNode $ table
538
+ ): void {
539
+ $ results = $ this ->sendConcurrentShareInvitation ($ user , $ table );
540
+ foreach ($ results as $ result ) {
541
+ var_dump ($ result ->getBody ()->getContents ());
542
+ $ this ->featureContext ->pushToLastHttpStatusCodesArray ((string )$ result ->getStatusCode ());
543
+ if ($ result ->getStatusCode () === 200 ) {
544
+ $ this ->featureContext ->shareNgAddToCreatedUserGroupShares ($ result );
545
+ }
546
+ }
547
+ }
548
+
549
+ /**
550
+ * @param string $user
551
+ * @param TableNode $table
552
+ *
553
+ * @return array
554
+ * @throws GuzzleException
555
+ * @throws JsonException
556
+ */
557
+ public function sendConcurrentShareInvitation (string $ user , TableNode $ table ): array {
558
+ $ table = $ table ->getColumnsHash ();
559
+ foreach ($ table as $ shareInfo ) {
560
+ $ space = $ this ->spacesContext ->getSpaceByName ($ user , $ shareInfo ['space ' ]);
561
+ $ spaceId = $ space ['id ' ];
562
+
563
+ $ resource = $ shareInfo ['resource ' ] ?? '' ;
564
+ $ itemId = $ this ->spacesContext ->getResourceId ($ user , $ shareInfo ['space ' ], $ resource );
565
+
566
+ $ shareeId = (
567
+ $ this ->featureContext ->ocmContext ->getAcceptedUserByName (
568
+ $ user ,
569
+ $ shareInfo ["sharee " ]
570
+ )
571
+ )['user_id ' ];
572
+
573
+ $ shareType = $ shareInfo ['shareType ' ];
574
+ $ permissionsRole = $ shareInfo ['permissionsRole ' ] ?? null ;
575
+ $ roleId = GraphHelper::getPermissionsRoleIdByName ($ permissionsRole );
576
+
577
+ $ body = [];
578
+ $ body ['recipients ' ][] = [
579
+ "@libre.graph.recipient.type " => $ shareType ,
580
+ "objectId " => $ shareeId
581
+ ];
582
+ $ body ['roles ' ] = [$ roleId ];
583
+
584
+ $ fullUrl = GraphHelper::getBetaFullUrl (
585
+ $ this ->featureContext ->getBaseUrl (),
586
+ "drives/ $ spaceId/items/ $ itemId/invite "
587
+ );
588
+
589
+ $ request = HttpRequestHelper::createRequest (
590
+ $ fullUrl ,
591
+ $ this ->featureContext ->getStepLineRef (),
592
+ "POST " ,
593
+ ['Content-Type ' => 'application/json ' ],
594
+ \json_encode ($ body )
595
+ );
596
+ $ requests [] = $ request ;
597
+ }
598
+
599
+ $ client = HttpRequestHelper::createClient (
600
+ $ this ->featureContext ->getActualUsername ($ user ),
601
+ $ this ->featureContext ->getPasswordForUser ($ user )
602
+ );
603
+
604
+ return HttpRequestHelper::sendBatchRequest ($ requests , $ client );
605
+ }
606
+
527
607
/**
528
608
* @When /^user "([^"]*)" sends the following space share invitation using permissions endpoint of the Graph API:$/
529
609
*
@@ -2043,6 +2123,48 @@ public function userShouldOrShouldNotHaveFederatedShareSharedByUserFromSpace(
2043
2123
$ this ->checkIfShareExists ($ share , $ sharee , $ sharer , $ space , $ shouldOrNot === "should " , true );
2044
2124
}
2045
2125
2126
+ /**
2127
+ * @Then user :sharee should have the following federated share shared by user :sharer
2128
+ *
2129
+ * @param string $sharee
2130
+ * @param string $sharer
2131
+ * @param TableNode $table
2132
+ *
2133
+ * @return void
2134
+ */
2135
+ public function userShouldHaveTheFollowingFederatedShareSharedByUserFromSpace (
2136
+ string $ sharee ,
2137
+ string $ sharer ,
2138
+ TableNode $ table
2139
+ ): void {
2140
+ $ share = $ table ->getRowsHash ();
2141
+ $ response = GraphHelper::getSharesSharedWithMe (
2142
+ $ this ->featureContext ->getBaseUrl (),
2143
+ $ this ->featureContext ->getStepLineRef (),
2144
+ $ sharee ,
2145
+ $ this ->featureContext ->getPasswordForUser ($ sharee )
2146
+ );
2147
+ $ sharedWithMeList = HttpRequestHelper::getJsonDecodedResponseBodyContent ($ response )->value ;
2148
+ foreach ($ sharedWithMeList as $ item ) {
2149
+ if ($ item ->name === $ share ["resource " ]) {
2150
+ foreach ($ item ->remoteItem ->permissions as $ permission ) {
2151
+ $ shareCreator = $ permission ->invitation ->invitedBy ->user ->displayName ;
2152
+ $ permissionsRole = $ permission ->roles [0 ];
2153
+ Assert::assertEquals (
2154
+ $ this ->featureContext ->getDisplayNameForUser ($ sharer ),
2155
+ $ shareCreator ,
2156
+ "Expected sharer to be ' $ sharer' but got ' $ shareCreator' "
2157
+ );
2158
+ Assert::assertEquals (
2159
+ $ share ["permissionsRole " ],
2160
+ GraphHelper::getPermissionNameByPermissionRoleId ($ permissionsRole ),
2161
+ "Error "
2162
+ );
2163
+ }
2164
+ }
2165
+ }
2166
+ }
2167
+
2046
2168
/**
2047
2169
* @Given /^user "([^"]*)" has shared the following (?:files|folders) from space "([^"]*)" with user "([^"]*)" and role "([^"]*)":$/
2048
2170
*
0 commit comments