2023-03-31 09:42:58 +02:00
<? php declare ( strict_types = 1 );
/**
* ownCloud
*
* @author Viktor Scharf <vscharf@owncloud.com>
* @copyright Copyright (c) 2023 Viktor Scharf vscharf@owncloud.com
*/
use Behat\Behat\Context\Context ;
use Behat\Behat\Hook\Scope\BeforeScenarioScope ;
use TestHelpers\OcsApiHelper ;
use Behat\Gherkin\Node\PyStringNode ;
2023-05-10 14:03:52 +05:45
use TestHelpers\EmailHelper ;
use PHPUnit\Framework\Assert ;
use TestHelpers\GraphHelper ;
2023-06-02 17:11:17 +05:45
use Behat\Gherkin\Node\TableNode ;
2023-07-18 14:12:45 +05:45
use GuzzleHttp\Exception\GuzzleException ;
use Psr\Http\Message\ResponseInterface ;
2023-03-31 09:42:58 +02:00
require_once 'bootstrap.php' ;
/**
* Defines application features from the specific context.
*/
class NotificationContext implements Context {
2023-05-02 17:25:56 +05:45
private FeatureContext $featureContext ;
2023-05-10 14:03:52 +05:45
private SpacesContext $spacesContext ;
2023-05-17 10:00:47 +02:00
private SettingsContext $settingsContext ;
2023-03-31 09:42:58 +02:00
private string $notificationEndpointPath = '/apps/notifications/api/v1/notifications?format=json' ;
2023-08-14 09:16:04 +02:00
private string $globalNotificationEndpointPath = '/apps/notifications/api/v1/notifications/global' ;
2023-05-10 14:03:52 +05:45
2023-05-02 17:25:56 +05:45
private array $notificationIds ;
2023-03-31 09:42:58 +02:00
/**
* @return array[]
*/
public function getNotificationIds () : array {
return $this -> notificationIds ;
}
/**
* @return array[]
*/
public function getLastNotificationId () : array {
return \end ( $this -> notificationIds );
}
2023-08-14 09:16:04 +02:00
/**
* @AfterScenario
*
* @return void
*/
public function deleteDeprovisioningNotification () : void {
$this -> userDeletesDeprovisioningNotification ();
}
2023-03-31 09:42:58 +02:00
/**
* @var string
*/
private string $userRecipient ;
/**
* @param string $userRecipient
*
* @return void
*/
public function setUserRecipient ( string $userRecipient ) : void {
$this -> userRecipient = $userRecipient ;
}
/**
* @return string
*/
public function getUserRecipient () : string {
return $this -> userRecipient ;
}
/**
* @BeforeScenario
*
* @param BeforeScenarioScope $scope
*
* @return void
* @throws Exception
*/
public function setUpScenario ( BeforeScenarioScope $scope ) : void {
// Get the environment
$environment = $scope -> getEnvironment ();
// Get all the contexts you need in this context
$this -> featureContext = $environment -> getContext ( 'FeatureContext' );
2023-05-10 14:03:52 +05:45
$this -> spacesContext = $environment -> getContext ( 'SpacesContext' );
2023-05-17 10:00:47 +02:00
$this -> settingsContext = $environment -> getContext ( 'SettingsContext' );
2023-03-31 09:42:58 +02:00
}
/**
* @param string $user
*
2023-09-29 12:07:45 +05:45
* @return ResponseInterface
2023-03-31 09:42:58 +02:00
*/
2023-09-29 12:07:45 +05:45
public function listAllNotifications ( string $user ) : ResponseInterface {
2023-03-31 09:42:58 +02:00
$this -> setUserRecipient ( $user );
2023-05-17 10:00:47 +02:00
$headers = [ "accept-language" => $this -> settingsContext -> getSettingLanguageValue ( $user )];
2023-09-29 12:07:45 +05:45
return OcsApiHelper :: sendRequest (
2023-03-31 09:42:58 +02:00
$this -> featureContext -> getBaseUrl (),
$this -> featureContext -> getActualUsername ( $user ),
$this -> featureContext -> getPasswordForUser ( $user ),
'GET' ,
$this -> notificationEndpointPath ,
2023-05-17 10:00:47 +02:00
$this -> featureContext -> getStepLineRef (),
[],
2 ,
$headers
2023-03-31 09:42:58 +02:00
);
}
2023-07-18 14:12:45 +05:45
/**
2023-09-29 12:07:45 +05:45
* @When /^user "([^"]*)" lists all notifications$/
2023-07-18 14:12:45 +05:45
*
* @param string $user
*
* @return void
2023-09-29 12:07:45 +05:45
*/
public function userListAllNotifications ( string $user ) : void {
$response = $this -> listAllNotifications ( $user );
$this -> featureContext -> setResponse ( $response );
$this -> featureContext -> pushToLastHttpStatusCodesArray ();
}
/**
* @param string $user
*
* @return ResponseInterface
2023-07-18 14:12:45 +05:45
* @throws GuzzleException
* @throws JsonException
*/
2023-09-29 12:07:45 +05:45
public function deleteAllNotifications ( string $user ) : ResponseInterface {
$response = $this -> listAllNotifications ( $user );
if ( isset ( $this -> featureContext -> getJsonDecodedResponseBodyContent ( $response ) -> ocs -> data )) {
$responseBody = $this -> featureContext -> getJsonDecodedResponseBodyContent ( $response ) -> ocs -> data ;
2023-07-18 14:12:45 +05:45
foreach ( $responseBody as $value ) {
// set notificationId
$this -> notificationIds [] = $value -> notification_id ;
}
}
2023-09-29 12:07:45 +05:45
return $this -> userDeletesNotification ( $user );
}
/**
* @When user :user deletes all notifications
*
* @param string $user
*
* @return void
* @throws GuzzleException
* @throws JsonException
*/
public function userDeletesAllNotifications ( string $user ) : void {
$response = $this -> deleteAllNotifications ( $user );
$this -> featureContext -> setResponse ( $response );
2023-07-18 14:12:45 +05:45
}
2023-08-14 09:16:04 +02:00
/**
* @Given user :user has deleted all notifications
*
* @param string $user
*
* @return void
* @throws GuzzleException
* @throws JsonException
*/
public function userHasDeletedAllNotifications ( string $user ) : void {
2023-09-29 12:07:45 +05:45
$response = $this -> deleteAllNotifications ( $user );
$this -> featureContext -> theHTTPStatusCodeShouldBe ( 200 , "" , $response );
2023-08-14 09:16:04 +02:00
}
2023-07-18 14:12:45 +05:45
/**
* @When user :user deletes a notification related to resource :resource with subject :subject
*
* @param string $user
* @param string $resource
* @param string $subject
*
* @return void
* @throws GuzzleException
* @throws JsonException
*/
public function userDeletesNotificationOfResourceAndSubject ( string $user , string $resource , string $subject ) : void {
2023-09-29 12:07:45 +05:45
$response = $this -> listAllNotifications ( $user );
$this -> filterResponseByNotificationSubjectAndResource ( $subject , $resource , $response );
2023-07-18 14:12:45 +05:45
$this -> featureContext -> setResponse ( $this -> userDeletesNotification ( $user ));
}
/**
* deletes notification
*
* @param string $user
*
2023-09-29 12:07:45 +05:45
* @return ResponseInterface
2023-07-18 14:12:45 +05:45
* @throws GuzzleException
* @throws JsonException
*/
public function userDeletesNotification ( string $user ) : ResponseInterface {
$this -> setUserRecipient ( $user );
$payload [ "ids" ] = $this -> getNotificationIds ();
return OcsApiHelper :: sendRequest (
$this -> featureContext -> getBaseUrl (),
$this -> featureContext -> getActualUsername ( $user ),
$this -> featureContext -> getPasswordForUser ( $user ),
'DELETE' ,
$this -> notificationEndpointPath ,
$this -> featureContext -> getStepLineRef (),
\json_encode ( $payload ),
2
);
}
2023-05-31 16:00:10 +05:45
/**
* @Then the notifications should be empty
*
* @return void
* @throws Exception
*/
public function theNotificationsShouldBeEmpty () : void {
2023-07-18 14:12:45 +05:45
$statusCode = $this -> featureContext -> getResponse () -> getStatusCode ();
if ( $statusCode !== 200 ) {
$response = $this -> featureContext -> getResponse () -> getBody () -> getContents ();
throw new \Exception (
__METHOD__
. " Failed to get user notification list" . $response
);
}
2023-05-31 16:00:10 +05:45
$notifications = $this -> featureContext -> getJsonDecodedResponseBodyContent () -> ocs -> data ;
Assert :: assertNull ( $notifications , "response should not contain any notification" );
}
2023-07-18 14:12:45 +05:45
/**
* @Then user :user should not have any notification
*
* @param $user
*
* @return void
* @throws Exception
*/
public function userShouldNotHaveAnyNotification ( $user ) : void {
$this -> userListAllNotifications ( $user );
$this -> theNotificationsShouldBeEmpty ();
}
2023-06-08 16:59:45 +05:45
/**
* @Then /^user "([^"]*)" should have "([^"]*)" notifications$/
*
* @param string $user
* @param int $numberOfNotification
*
* @return void
* @throws Exception
*/
public function userShouldHaveNotifications ( string $user , int $numberOfNotification ) : void {
if ( ! isset ( $this -> featureContext -> getJsonDecodedResponseBodyContent () -> ocs -> data )) {
throw new Exception ( "Notification is empty" );
}
$responseBody = $this -> featureContext -> getJsonDecodedResponseBodyContent () -> ocs -> data ;
$actualNumber = \count ( $responseBody );
Assert :: assertEquals (
$numberOfNotification ,
$actualNumber ,
"Expected number of notification was ' $numberOfNotification ', but got ' $actualNumber '"
);
}
2023-03-31 09:42:58 +02:00
/**
* @Then /^the JSON response should contain a notification message with the subject "([^"]*)" and the message-details should match$/
*
* @param string $subject
* @param PyStringNode $schemaString
*
* @return void
* @throws Exception
*/
public function theJsonDataFromLastResponseShouldMatch (
string $subject ,
PyStringNode $schemaString
) : void {
2023-06-02 17:11:17 +05:45
$responseBody = $this -> filterResponseAccordingToNotificationSubject ( $subject );
// substitute the value here
$schemaString = $schemaString -> getRaw ();
$schemaString = $this -> featureContext -> substituteInLineCodes (
$schemaString ,
$this -> featureContext -> getCurrentUser (),
[],
[],
null ,
$this -> getUserRecipient (),
);
$this -> featureContext -> assertJsonDocumentMatchesSchema (
$responseBody ,
$this -> featureContext -> getJSONSchema ( $schemaString )
);
}
/**
2023-07-18 14:12:45 +05:45
* filter notification according to subject
*
2023-06-02 17:11:17 +05:45
* @param string $subject
2023-09-29 12:07:45 +05:45
* @param ResponseInterface|null $response
2023-06-02 17:11:17 +05:45
*
* @return object
*/
2023-09-29 12:07:45 +05:45
public function filterResponseAccordingToNotificationSubject ( string $subject , ? ResponseInterface $response = null ) : object {
$response = $response ?? $this -> featureContext -> getResponse ();
if ( isset ( $this -> featureContext -> getJsonDecodedResponseBodyContent ( $response ) -> ocs -> data )) {
$responseBody = $this -> featureContext -> getJsonDecodedResponseBodyContent ( $response ) -> ocs -> data ;
2023-03-31 09:42:58 +02:00
foreach ( $responseBody as $value ) {
if ( isset ( $value -> subject ) && $value -> subject === $subject ) {
$responseBody = $value ;
// set notificationId
$this -> notificationIds [] = $value -> notification_id ;
break ;
}
}
} else {
2023-09-29 12:07:45 +05:45
$responseBody = $this -> featureContext -> getJsonDecodedResponseBodyContent ( $response );
2023-03-31 09:42:58 +02:00
}
2023-06-02 17:11:17 +05:45
return $responseBody ;
}
2023-03-31 09:42:58 +02:00
2023-06-02 17:11:17 +05:45
/**
2023-07-18 14:12:45 +05:45
* filter notification according to subject and resource
*
* @param string $subject
* @param string $resource
2023-09-29 12:07:45 +05:45
* @param ResponseInterface|null $response
2023-07-18 14:12:45 +05:45
*
* @return array
*/
2023-09-29 12:07:45 +05:45
public function filterResponseByNotificationSubjectAndResource ( string $subject , string $resource , ? ResponseInterface $response = null ) : array {
2023-07-18 14:12:45 +05:45
$responseBodyArray = [];
2023-09-29 12:07:45 +05:45
$response = $response ?? $this -> featureContext -> getResponse ();
$statusCode = $response -> getStatusCode ();
2023-07-18 14:12:45 +05:45
if ( $statusCode !== 200 ) {
2023-09-29 12:07:45 +05:45
$response = $response -> getBody () -> getContents ();
2023-07-18 14:12:45 +05:45
Assert :: fail ( $response . " Response should contain status code 200" );
}
2023-09-29 12:07:45 +05:45
if ( isset ( $this -> featureContext -> getJsonDecodedResponseBodyContent ( $response ) -> ocs -> data )) {
$responseBody = $this -> featureContext -> getJsonDecodedResponseBodyContent ( $response ) -> ocs -> data ;
2023-07-18 14:12:45 +05:45
foreach ( $responseBody as $value ) {
if ( isset ( $value -> subject ) && $value -> subject === $subject && isset ( $value -> messageRichParameters -> resource -> name ) && $value -> messageRichParameters -> resource -> name === $resource ) {
$this -> notificationIds [] = $value -> notification_id ;
$responseBodyArray [] = $value ;
}
}
} else {
2023-09-29 12:07:45 +05:45
$responseBodyArray [] = $this -> featureContext -> getJsonDecodedResponseBodyContent ( $response );
2023-07-18 14:12:45 +05:45
Assert :: fail ( "Response should contain notification but found: $responseBodyArray " );
}
return $responseBodyArray ;
}
/**
* @Then /^user "([^"]*)" should (?:get|have) a notification with subject "([^"]*)" and message:$/
2023-06-02 17:11:17 +05:45
*
* @param string $user
* @param string $subject
* @param TableNode $table
*
* @return void
2023-07-24 11:31:38 +05:45
* @throws Exception
2023-06-02 17:11:17 +05:45
*/
public function userShouldGetANotificationWithMessage ( string $user , string $subject , TableNode $table ) : void {
2023-07-24 11:31:38 +05:45
$count = 0 ;
// sometimes the test might try to get notification before the notification is created by the server
// in order to prevent test from failing because of that try to list the notifications again
do {
if ( $count > 0 ) {
\sleep ( 1 );
}
$this -> featureContext -> setResponse ( null );
2023-09-29 12:07:45 +05:45
$response = $this -> listAllNotifications ( $user );
$this -> featureContext -> theHTTPStatusCodeShouldBe ( 200 , "" , $response );
2023-07-24 11:31:38 +05:45
++ $count ;
2023-09-29 12:07:45 +05:45
} while ( ! isset ( $this -> filterResponseAccordingToNotificationSubject ( $subject , $response ) -> message ) && $count <= 5 );
if ( isset ( $this -> filterResponseAccordingToNotificationSubject ( $subject , $response ) -> message )) {
$actualMessage = str_replace ([ " \r " , " \n " ], " " , $this -> filterResponseAccordingToNotificationSubject ( $subject , $response ) -> message );
2023-07-24 11:31:38 +05:45
} else {
throw new \Exception ( "Notification was not found even after retrying for 5 seconds." );
}
2023-06-02 17:11:17 +05:45
$expectedMessage = $table -> getColumnsHash ()[ 0 ][ 'message' ];
Assert :: assertSame (
$expectedMessage ,
$actualMessage ,
__METHOD__ . "expected message to be ' $expectedMessage ' but found' $actualMessage '"
2023-03-31 09:42:58 +02:00
);
}
2023-05-10 14:03:52 +05:45
2023-07-26 10:07:45 +05:45
/**
* @Then user :user should get a notification for resource :resource with subject :subject and message:
*
* @param string $user
* @param string $resource
* @param string $subject
* @param TableNode $table
*
* @return void
* @throws Exception
*/
public function userShouldGetNotificationForResourceWithMessage ( string $user , string $resource , string $subject , TableNode $table ) : void {
2023-09-29 12:07:45 +05:45
$response = $this -> listAllNotifications ( $user );
$notification = $this -> filterResponseByNotificationSubjectAndResource ( $subject , $resource , $response );
2023-07-26 10:07:45 +05:45
if ( \count ( $notification ) === 1 ) {
$actualMessage = str_replace ([ " \r " , " \r " ], " " , $notification [ 0 ] -> message );
$expectedMessage = $table -> getColumnsHash ()[ 0 ][ 'message' ];
Assert :: assertSame (
$expectedMessage ,
$actualMessage ,
__METHOD__ . "expected message to be ' $expectedMessage ' but found' $actualMessage '"
);
$this -> userDeletesNotificationOfResourceAndSubject ( $user , $resource , $subject );
$this -> featureContext -> theHTTPStatusCodeShouldBe ( 200 );
} elseif ( \count ( $notification ) === 0 ) {
throw new \Exception ( "Response doesn't contain any notification with resource ' $resource ' and subject ' $subject '. \n $notification " );
} else {
throw new \Exception ( "Response contains more than one notification with resource ' $resource ' and subject ' $subject '. \n $notification " );
}
}
2023-07-18 14:12:45 +05:45
/**
* @Then user :user should not have a notification related to resource :resource with subject :subject
*
* @param string $user
* @param string $resource
* @param string $subject
*
* @return void
*/
public function userShouldNotHaveANotificationRelatedToResourceWithSubject ( string $user , string $resource , string $subject ) : void {
2023-09-29 12:07:45 +05:45
$response = $this -> listAllNotifications ( $user );
$filteredResponse = $this -> filterResponseByNotificationSubjectAndResource ( $subject , $resource , $response );
Assert :: assertCount ( 0 , $filteredResponse , "Response should not contain notification related to resource ' $resource ' with subject ' $subject ' but found" . print_r ( $filteredResponse , true ));
2023-07-18 14:12:45 +05:45
}
2023-05-10 14:03:52 +05:45
/**
* @Then user :user should have received the following email from user :sender about the share of project space :spaceName
*
* @param string $user
* @param string $sender
* @param string $spaceName
* @param PyStringNode $content
*
* @return void
* @throws Exception
*/
public function userShouldHaveReceivedTheFollowingEmailFromUserAboutTheShareOfProjectSpace ( string $user , string $sender , string $spaceName , PyStringNode $content ) : void {
$rawExpectedEmailBodyContent = \str_replace ( " \r\n " , " \n " , $content -> getRaw ());
$this -> featureContext -> setResponse (
GraphHelper :: getMySpaces (
$this -> featureContext -> getBaseUrl (),
$user ,
2023-09-07 10:33:44 +05:45
$this -> featureContext -> getPasswordForUser ( $user ),
'' ,
$this -> featureContext -> getStepLineRef ()
2023-05-10 14:03:52 +05:45
)
);
$expectedEmailBodyContent = $this -> featureContext -> substituteInLineCodes (
$rawExpectedEmailBodyContent ,
$sender ,
[],
[
[
"code" => "%space_id%" ,
"function" =>
2023-07-10 13:07:53 +05:45
[ $this -> spacesContext , "getSpaceIdByName" ],
"parameter" => [ $sender , $spaceName ]
2023-05-10 14:03:52 +05:45
],
],
null ,
null
);
$this -> assertEmailContains ( $user , $expectedEmailBodyContent );
}
/**
* @Then user :user should have received the following email from user :sender
*
* @param string $user
* @param string $sender
* @param PyStringNode $content
*
* @return void
* @throws Exception
*/
public function userShouldHaveReceivedTheFollowingEmailFromUser ( string $user , string $sender , PyStringNode $content ) : void {
$rawExpectedEmailBodyContent = \str_replace ( " \r\n " , " \n " , $content -> getRaw ());
$expectedEmailBodyContent = $this -> featureContext -> substituteInLineCodes (
$rawExpectedEmailBodyContent ,
$sender
);
$this -> assertEmailContains ( $user , $expectedEmailBodyContent );
}
/***
* @param string $user
* @param string $expectedEmailBodyContent
*
* @return void
* @throws GuzzleException
*/
public function assertEmailContains ( string $user , string $expectedEmailBodyContent ) : void {
$address = $this -> featureContext -> getEmailAddressForUser ( $user );
$this -> featureContext -> pushEmailRecipientAsMailBox ( $address );
$actualEmailBodyContent = EmailHelper :: getBodyOfLastEmail ( $address , $this -> featureContext -> getStepLineRef ());
Assert :: assertStringContainsString (
$expectedEmailBodyContent ,
$actualEmailBodyContent ,
"The email address ' $address ' should have received an email with the body containing $expectedEmailBodyContent
but the received email is $actualEmailBodyContent "
);
}
/**
* Delete all the inbucket emails
*
* @AfterScenario @email
*
* @return void
*/
public function clearInbucketMessages () : void {
try {
if ( ! empty ( $this -> featureContext -> emailRecipients )) {
foreach ( $this -> featureContext -> emailRecipients as $emailRecipent ) {
EmailHelper :: deleteAllEmailsForAMailbox (
EmailHelper :: getLocalEmailUrl (),
$this -> featureContext -> getStepLineRef (),
$emailRecipent
);
}
}
} catch ( Exception $e ) {
echo __METHOD__ .
" could not delete inbucket messages, is inbucket set up? \n " .
$e -> getMessage ();
}
}
2023-08-14 09:16:04 +02:00
/**
*
* @param string|null $user
2023-08-18 16:41:23 +05:45
* @param string|null $deprovision_date
* @param string|null $deprovision_date_format
2023-08-14 09:16:04 +02:00
*
2023-09-29 12:07:45 +05:45
* @return ResponseInterface
2023-08-18 16:41:23 +05:45
*
* @throws GuzzleException
*
* @throws JsonException
2023-08-14 09:16:04 +02:00
*/
2023-08-18 16:41:23 +05:45
public function userCreatesDeprovisioningNotification (
? string $user = null ,
? string $deprovision_date = "2043-07-04T11:23:12Z" ,
? string $deprovision_date_format = "2006-01-02T15:04:05Z07:00"
2023-08-22 13:16:08 +05:45
) : ResponseInterface {
2023-08-14 09:16:04 +02:00
$payload [ "type" ] = "deprovision" ;
2023-08-18 16:41:23 +05:45
$payload [ "data" ] = [ "deprovision_date" => $deprovision_date , "deprovision_date_format" => $deprovision_date_format ];
2023-08-22 13:16:08 +05:45
return OcsApiHelper :: sendRequest (
2023-08-14 09:16:04 +02:00
$this -> featureContext -> getBaseUrl (),
$user ? $this -> featureContext -> getActualUsername ( $user ) : $this -> featureContext -> getAdminUsername (),
$user ? $this -> featureContext -> getPasswordForUser ( $user ) : $this -> featureContext -> getAdminPassword (),
'POST' ,
$this -> globalNotificationEndpointPath ,
2023-09-07 10:33:44 +05:45
$this -> featureContext -> getStepLineRef (),
2023-08-14 09:16:04 +02:00
json_encode ( $payload ),
2
);
2023-08-22 13:16:08 +05:45
}
/**
* @When the administrator creates a deprovisioning notification
* @When user :user tries to create a deprovisioning notification
*
* @param string|null $user
*
* @return void
*
* @throws GuzzleException
* @throws JsonException
*/
public function theAdministratorCreatesADeprovisioningNotification ( ? string $user = null ) {
$response = $this -> userCreatesDeprovisioningNotification ( $user );
2023-08-14 09:16:04 +02:00
$this -> featureContext -> setResponse ( $response );
2023-08-22 13:16:08 +05:45
$this -> featureContext -> pushToLastHttpStatusCodesArray ();
2023-08-14 09:16:04 +02:00
}
2023-08-18 16:41:23 +05:45
/**
* @When the administrator creates a deprovisioning notification for date :deprovision_date of format :deprovision_date_format
*
* @param $deprovision_date
* @param $deprovision_date_format
*
* @return void
*
* @throws GuzzleException
* @throws JsonException
*/
public function theAdministratorCreatesADeprovisioningNotificationUsingDateFormat ( $deprovision_date , $deprovision_date_format ) {
2023-08-22 13:16:08 +05:45
$response = $this -> userCreatesDeprovisioningNotification ( null , $deprovision_date , $deprovision_date_format );
$this -> featureContext -> setResponse ( $response );
$this -> featureContext -> pushToLastHttpStatusCodesArray ();
2023-08-18 16:41:23 +05:45
}
2023-08-14 09:16:04 +02:00
/**
* @Given the administrator has created a deprovisioning notification
*
* @return void
*/
public function userHasCreatedDeprovisioningNotification () : void {
2023-09-29 12:07:45 +05:45
$response = $this -> userCreatesDeprovisioningNotification ();
$this -> featureContext -> theHTTPStatusCodeShouldBe ( 200 , "" , $response );
2023-08-14 09:16:04 +02:00
}
/**
* @When the administrator deletes the deprovisioning notification
* @When user :user tries to delete the deprovisioning notification
*
* @param string|null $user
*
* @return void
*/
public function userDeletesDeprovisioningNotification ( ? string $user = null ) : void {
$payload [ "ids" ] = [ "deprovision" ];
$response = OcsApiHelper :: sendRequest (
$this -> featureContext -> getBaseUrl (),
$user ? $this -> featureContext -> getActualUsername ( $user ) : $this -> featureContext -> getAdminUsername (),
$user ? $this -> featureContext -> getPasswordForUser ( $user ) : $this -> featureContext -> getAdminPassword (),
'DELETE' ,
$this -> globalNotificationEndpointPath ,
2023-09-07 10:33:44 +05:45
$this -> featureContext -> getStepLineRef (),
2023-08-14 09:16:04 +02:00
json_encode ( $payload ),
2
);
$this -> featureContext -> setResponse ( $response );
}
2023-03-31 09:42:58 +02:00
}