@@ -524,6 +524,74 @@ 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
+ public function userSendsTheFollowingResourcesShareInvitationConcurrentlyToFederatedUserUsingTheGraphApi (string $ user , TableNode $ table ): void {
534
+ $ table = $ table ->getColumnsHash ();
535
+ foreach ($ table as $ shareInfo ) {
536
+ if ($ shareInfo ['space ' ] === 'Personal ' || $ shareInfo ['space ' ] === 'Shares ' ) {
537
+ $ space = $ this ->spacesContext ->getSpaceByName ($ user , $ shareInfo ['space ' ]);
538
+ } else {
539
+ $ space = $ this ->spacesContext ->getCreatedSpace ($ shareInfo ['space ' ]);
540
+ }
541
+ $ spaceId = $ space ['id ' ];
542
+
543
+ $ resource = $ shareInfo ['resource ' ] ?? '' ;
544
+ $ itemId = $ this ->spacesContext ->getResourceId ($ user , $ shareInfo ['space ' ], $ resource );
545
+
546
+ $ shareeId = (
547
+ $ this ->featureContext ->ocmContext ->getAcceptedUserByName (
548
+ $ user ,
549
+ $ shareInfo ["sharee " ]
550
+ )
551
+ )['user_id ' ];
552
+
553
+ $ shareType = $ shareInfo ['shareType ' ];
554
+ $ permissionsRole = $ shareInfo ['permissionsRole ' ] ?? null ;
555
+ $ roleId = GraphHelper::getPermissionsRoleIdByName ($ permissionsRole );
556
+
557
+ $ body = [];
558
+ $ body ['recipients ' ][] = [
559
+ "@libre.graph.recipient.type " => $ shareType ,
560
+ "objectId " => $ shareeId
561
+ ];
562
+ $ body ['roles ' ] = [$ roleId ];
563
+
564
+ $ fullUrl = GraphHelper::getBetaFullUrl (
565
+ $ this ->featureContext ->getBaseUrl (),
566
+ "drives/ $ spaceId/items/ $ itemId/invite "
567
+ );
568
+
569
+ $ request = HttpRequestHelper::createRequest (
570
+ $ fullUrl ,
571
+ $ this ->featureContext ->getStepLineRef (),
572
+ "POST " ,
573
+ ['Content-Type ' => 'application/json ' ],
574
+ \json_encode ($ body )
575
+ );
576
+ $ requests [] = $ request ;
577
+ }
578
+
579
+ $ client = HttpRequestHelper::createClient (
580
+ $ this ->featureContext ->getActualUsername ($ user ),
581
+ $ this ->featureContext ->getPasswordForUser ($ user )
582
+ );
583
+
584
+ $ results = HttpRequestHelper::sendBatchRequest ($ requests , $ client );
585
+ // var_dump($results);
586
+ foreach ($ results as $ result ) {
587
+ var_dump ($ result ->getBody ()->getContents ());
588
+ $ this ->featureContext ->pushToLastHttpStatusCodesArray ((string )$ result ->getStatusCode ());
589
+ if ($ result ->getStatusCode () === 200 ) {
590
+ $ this ->featureContext ->shareNgAddToCreatedUserGroupShares ($ result );
591
+ }
592
+ }
593
+ }
594
+
527
595
/**
528
596
* @When /^user "([^"]*)" sends the following space share invitation using permissions endpoint of the Graph API:$/
529
597
*
@@ -2043,6 +2111,44 @@ public function userShouldOrShouldNotHaveFederatedShareSharedByUserFromSpace(
2043
2111
$ this ->checkIfShareExists ($ share , $ sharee , $ sharer , $ space , $ shouldOrNot === "should " , true );
2044
2112
}
2045
2113
2114
+ /**
2115
+ * @Then user :sharee should have the following federated share shared by user :sharer from space :space
2116
+ *
2117
+ * @param string $sharee
2118
+ * @param string $sharer
2119
+ * @param string $space
2120
+ * @param TableNode $table
2121
+ */
2122
+ public function userShouldHaveTheFollowingFederatedShareSharedByUserFromSpace (string $ sharee , string $ sharer , string $ space , TableNode $ table ): void
2123
+ {
2124
+ $ share = $ table ->getRowsHash ();
2125
+ $ response = GraphHelper::getSharesSharedWithMe (
2126
+ $ this ->featureContext ->getBaseUrl (),
2127
+ $ this ->featureContext ->getStepLineRef (),
2128
+ $ sharee ,
2129
+ $ this ->featureContext ->getPasswordForUser ($ sharee )
2130
+ );
2131
+ $ sharedWithMeList = HttpRequestHelper::getJsonDecodedResponseBodyContent ($ response )->value ;
2132
+ foreach ($ sharedWithMeList as $ item ) {
2133
+ if ($ item ->name === $ share ["resource " ]) {
2134
+ foreach ($ item ->remoteItem ->permissions as $ permission ) {
2135
+ $ shareCreator = $ permission ->invitation ->invitedBy ->user ->displayName ;
2136
+ $ permissionsRole = $ permission ->roles [0 ];
2137
+ Assert::assertEquals (
2138
+ $ this ->featureContext ->getDisplayNameForUser ($ sharer ),
2139
+ $ shareCreator ,
2140
+ "Expected sharer to be ' $ sharer' but got ' $ shareCreator' "
2141
+ );
2142
+ Assert::assertEquals (
2143
+ $ share ["permissionsRole " ],
2144
+ GraphHelper::getPermissionNameByPermissionRoleId ($ permissionsRole ),
2145
+ "Error "
2146
+ );
2147
+ }
2148
+ }
2149
+ }
2150
+ }
2151
+
2046
2152
/**
2047
2153
* @Given /^user "([^"]*)" has shared the following (?:files|folders) from space "([^"]*)" with user "([^"]*)" and role "([^"]*)":$/
2048
2154
*
0 commit comments