public function NspiController::getSubscription in Acquia Connector 8.2
Same name and namespace in other branches
- 8 tests/modules/src/Controller/NspiController.php \Drupal\acquia_connector_test\Controller\NspiController::getSubscription()
- 3.x tests/modules/src/Controller/NspiController.php \Drupal\acquia_connector_test\Controller\NspiController::getSubscription()
Test validates an Acquia subscription.
Parameters
\GuzzleHttp\Psr7\Request $request: Request.
Return value
\GuzzleHttp\Psr7\Response JsonResponse.
File
- tests/
modules/ src/ Controller/ NspiController.php, line 456
Class
- NspiController
- Class NspiController.
Namespace
Drupal\acquia_connector_test\ControllerCode
public function getSubscription(Request $request) {
$data = json_decode($request
->getBody(), TRUE);
$result = $this
->validateAuthenticator($data);
if (empty($result['error'])) {
$result['authenticator']['hash'] = CryptConnector::acquiaHash($result['secret']['key'], $result['authenticator']['time'] . ':' . $result['authenticator']['nonce']);
unset($result['secret']);
return new Response(200, [], json_encode($result));
}
unset($result['secret']);
return new Response(self::ACQTEST_SUBSCRIPTION_SERVICE_UNAVAILABLE, [], json_encode($result));
}