Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test-only] ApiTest. create tag #5391

Merged
merged 3 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions tests/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -884,4 +884,96 @@ public static function changeOwnPassword(
\json_encode($payload)
);
}

/**
* @param string $baseUrl
* @param string $user
* @param string $password
* @param string $xRequestId
* @param array $body
* @param array $headers
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function getTag(
ScharfViktor marked this conversation as resolved.
Show resolved Hide resolved
string $baseUrl,
string $user,
string $password,
string $xRequestId = '',
array $body = [],
array $headers = []
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'extensions/org.libregraph/tags');

return HttpRequestHelper::get($url, $xRequestId, $user, $password, $headers, $body);
}

/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $password
* @param string $resourceId
* @param array $tagName
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function createTag(
string $baseUrl,
string $xRequestId,
string $user,
string $password,
string $resourceId,
array $tagName
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'extensions/org.libregraph/tags');
$payload['resourceId'] = $resourceId;
$payload['tags'] = $tagName;

return HttpRequestHelper::sendRequest(
$url,
$xRequestId,
"PUT",
$user,
$password,
self::getRequestHeaders(),
\json_encode($payload)
);
}

/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $password
* @param string $resourceId
* @param array $tagName
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function deleteTag(
string $baseUrl,
string $xRequestId,
string $user,
string $password,
string $resourceId,
array $tagName
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'extensions/org.libregraph/tags');
$payload['resourceId'] = $resourceId;
$payload['tags'] = $tagName;

return HttpRequestHelper::sendRequest(
$url,
$xRequestId,
"DELETE",
$user,
$password,
self::getRequestHeaders(),
\json_encode($payload)
);
}
}
Loading