protected function CredsUtilsTrait::operationOnCredential in Apigee Edge 8
Perform an operation on the given credential (by index) of the app.
Parameters
\Drupal\apigee_edge\Entity\DeveloperAppInterface $app: The app.
string $op: The operation to perform (revoke, delete, generate).
int $cred_index: The index of the credential (only applies to revoke/delete operations).
int $expires_in: The milliseconds from now that the cred should expire (only applies for generate operation). Defaults to "-1" (never).
File
- tests/
src/ Traits/ CredsUtilsTrait.php, line 66
Class
- CredsUtilsTrait
- A trait to common functions of Apigee Edge credential entity tests.
Namespace
Drupal\Tests\apigee_edge\TraitsCode
protected function operationOnCredential(DeveloperAppInterface $app, $op = 'revoke', $cred_index = 0, $expires_in = -1) {
$controller = $this
->getAppCredentialController($app
->getAppOwner(), $app
->getName());
if ($op == 'generate') {
$controller
->generate([
$this->apiProduct
->id(),
], $app
->getAttributes(), '', [], $expires_in);
return;
}
$key = $app
->getCredentials()[$cred_index]
->getConsumerKey();
if ($op == 'revoke') {
$controller
->setStatus($key, AppCredentialControllerInterface::STATUS_REVOKE);
}
elseif ($op == 'delete') {
$controller
->delete($key);
}
}