GoogleCloudStorageTest.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. <?php
  2. use Google\Auth\HttpHandler\HttpHandlerFactory;
  3. use Google\Cloud\Core\Exception\BadRequestException;
  4. use Google\Cloud\Core\Exception\NotFoundException;
  5. use Google\Cloud\Storage\Bucket;
  6. use Google\Cloud\Storage\Connection\ConnectionInterface;
  7. use Google\Cloud\Storage\StorageClient;
  8. use Google\Cloud\Storage\StorageObject;
  9. use GuzzleHttp\Client;
  10. use PrivateBin\Data\GoogleCloudStorage;
  11. class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase
  12. {
  13. private static $_client;
  14. private static $_bucket;
  15. public static function setUpBeforeClass()
  16. {
  17. $httpClient = new Client(array('debug'=>false));
  18. $handler = HttpHandlerFactory::build($httpClient);
  19. $name = 'pb-';
  20. $alphabet = 'abcdefghijklmnopqrstuvwxyz';
  21. for ($i = 0; $i < 29; ++$i) {
  22. $name .= $alphabet[rand(0, strlen($alphabet) - 1)];
  23. }
  24. self::$_client = new StorageClientStub(array());
  25. self::$_bucket = self::$_client->createBucket($name);
  26. }
  27. public function setUp()
  28. {
  29. ini_set('error_log', stream_get_meta_data(tmpfile())['uri']);
  30. $this->_model = GoogleCloudStorage::getInstance(array(
  31. 'bucket' => self::$_bucket->name(),
  32. 'prefix' => 'pastes',
  33. 'client' => self::$_client, ));
  34. }
  35. public function tearDown()
  36. {
  37. foreach (self::$_bucket->objects() as $object) {
  38. $object->delete();
  39. }
  40. error_reporting(E_ALL);
  41. }
  42. public static function tearDownAfterClass()
  43. {
  44. self::$_bucket->delete();
  45. }
  46. public function testFileBasedDataStoreWorks()
  47. {
  48. $this->_model->delete(Helper::getPasteId());
  49. // storing pastes
  50. $paste = Helper::getPaste(2, array('expire_date' => 1344803344));
  51. $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not yet exist');
  52. $this->assertTrue($this->_model->create(Helper::getPasteId(), $paste), 'store new paste');
  53. $this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists after storing it');
  54. $this->assertFalse($this->_model->create(Helper::getPasteId(), $paste), 'unable to store the same paste twice');
  55. $this->assertEquals($paste, $this->_model->read(Helper::getPasteId()));
  56. // storing comments
  57. $this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment does not yet exist');
  58. $this->assertTrue($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), Helper::getComment()), 'store comment');
  59. $this->assertTrue($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment exists after storing it');
  60. $this->assertFalse($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), Helper::getComment()), 'unable to store the same comment twice');
  61. $comment = Helper::getComment();
  62. $comment['id'] = Helper::getCommentId();
  63. $comment['parentid'] = Helper::getPasteId();
  64. $this->assertEquals(
  65. array($comment['meta']['created'] => $comment),
  66. $this->_model->readComments(Helper::getPasteId())
  67. );
  68. // deleting pastes
  69. $this->_model->delete(Helper::getPasteId());
  70. $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste successfully deleted');
  71. $this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment was deleted with paste');
  72. $this->assertFalse($this->_model->read(Helper::getPasteId()), 'paste can no longer be found');
  73. }
  74. /**
  75. * pastes a-g are expired and should get deleted, x never expires and y-z expire in an hour
  76. */
  77. public function testPurge()
  78. {
  79. $expired = Helper::getPaste(2, array('expire_date' => 1344803344));
  80. $paste = Helper::getPaste(2, array('expire_date' => time() + 3600));
  81. $keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z');
  82. $ids = array();
  83. foreach ($keys as $key) {
  84. $ids[$key] = hash('fnv164', $key);
  85. $this->assertFalse($this->_model->exists($ids[$key]), "paste $key does not yet exist");
  86. if (in_array($key, array('x', 'y', 'z'))) {
  87. $this->assertTrue($this->_model->create($ids[$key], $paste), "store $key paste");
  88. } elseif ($key === 'x') {
  89. $this->assertTrue($this->_model->create($ids[$key], Helper::getPaste()), "store $key paste");
  90. } else {
  91. $this->assertTrue($this->_model->create($ids[$key], $expired), "store $key paste");
  92. }
  93. $this->assertTrue($this->_model->exists($ids[$key]), "paste $key exists after storing it");
  94. }
  95. $this->_model->purge(10);
  96. foreach ($ids as $key => $id) {
  97. if (in_array($key, array('x', 'y', 'z'))) {
  98. $this->assertTrue($this->_model->exists($id), "paste $key exists after purge");
  99. $this->_model->delete($id);
  100. } else {
  101. $this->assertFalse($this->_model->exists($id), "paste $key was purged");
  102. }
  103. }
  104. }
  105. public function testErrorDetection()
  106. {
  107. $this->_model->delete(Helper::getPasteId());
  108. $paste = Helper::getPaste(2, array('expire' => "Invalid UTF-8 sequence: \xB1\x31"));
  109. $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not yet exist');
  110. $this->assertFalse($this->_model->create(Helper::getPasteId(), $paste), 'unable to store broken paste');
  111. $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does still not exist');
  112. }
  113. public function testCommentErrorDetection()
  114. {
  115. $this->_model->delete(Helper::getPasteId());
  116. $comment = Helper::getComment(1, array('nickname' => "Invalid UTF-8 sequence: \xB1\x31"));
  117. $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not yet exist');
  118. $this->assertTrue($this->_model->create(Helper::getPasteId(), Helper::getPaste()), 'store new paste');
  119. $this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists after storing it');
  120. $this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment does not yet exist');
  121. $this->assertFalse($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), $comment), 'unable to store broken comment');
  122. $this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment does still not exist');
  123. }
  124. /**
  125. * @throws Exception
  126. */
  127. public function testKeyValueStore()
  128. {
  129. $salt = bin2hex(random_bytes(256));
  130. $this->_model->setValue($salt, 'salt', 'master');
  131. $storedSalt = $this->_model->getValue('salt', 'master');
  132. $this->assertEquals($salt, $storedSalt);
  133. $client = hash_hmac('sha512', '127.0.0.1', $salt);
  134. $expire = time();
  135. $this->_model->setValue($expire, 'traffic_limiter', $client);
  136. $storedExpired = $this->_model->getValue('traffic_limiter', $client);
  137. $this->assertEquals($expire, $storedExpired);
  138. $purgeAt = $expire + (15 * 60);
  139. $this->_model->setValue($purgeAt, 'purge_limiter', 'at');
  140. $storedPurgedAt = $this->_model->getValue('purge_limiter', 'at');
  141. $this->assertEquals($purgeAt, $storedPurgedAt);
  142. }
  143. }
  144. /**
  145. * Class StorageClientStub provides a limited stub for performing the unit test
  146. */
  147. class StorageClientStub extends StorageClient
  148. {
  149. private $_config = null;
  150. private $_connection = null;
  151. private $_buckets = array();
  152. public function __construct(array $config = array())
  153. {
  154. $this->_config = $config;
  155. $this->_connection = new ConnectionInterfaceStub();
  156. }
  157. public function bucket($name, $userProject = false)
  158. {
  159. if (!key_exists($name, $this->_buckets)) {
  160. $b = new BucketStub($this->_connection, $name, array(), $this);
  161. $this->_buckets[$name] = $b;
  162. }
  163. return $this->_buckets[$name];
  164. }
  165. /**
  166. * @throws \Google\Cloud\Core\Exception\NotFoundException
  167. */
  168. public function deleteBucket($name)
  169. {
  170. if (key_exists($name, $this->_buckets)) {
  171. unset($this->_buckets[$name]);
  172. } else {
  173. throw new NotFoundException();
  174. }
  175. }
  176. public function buckets(array $options = array())
  177. {
  178. throw new BadMethodCallException('not supported by this stub');
  179. }
  180. public function registerStreamWrapper($protocol = null)
  181. {
  182. throw new BadMethodCallException('not supported by this stub');
  183. }
  184. public function unregisterStreamWrapper($protocol = null)
  185. {
  186. throw new BadMethodCallException('not supported by this stub');
  187. }
  188. public function signedUrlUploader($uri, $data, array $options = array())
  189. {
  190. throw new BadMethodCallException('not supported by this stub');
  191. }
  192. public function timestamp(\DateTimeInterface $timestamp, $nanoSeconds = null)
  193. {
  194. throw new BadMethodCallException('not supported by this stub');
  195. }
  196. public function getServiceAccount(array $options = array())
  197. {
  198. throw new BadMethodCallException('not supported by this stub');
  199. }
  200. public function hmacKeys(array $options = array())
  201. {
  202. throw new BadMethodCallException('not supported by this stub');
  203. }
  204. public function hmacKey($accessId, $projectId = null, array $metadata = array())
  205. {
  206. throw new BadMethodCallException('not supported by this stub');
  207. }
  208. public function createHmacKey($serviceAccountEmail, array $options = array())
  209. {
  210. throw new BadMethodCallException('not supported by this stub');
  211. }
  212. public function createBucket($name, array $options = array())
  213. {
  214. if (key_exists($name, $this->_buckets)) {
  215. throw new BadRequestException('already exists');
  216. }
  217. $b = new BucketStub($this->_connection, $name, array(), $this);
  218. $this->_buckets[$name] = $b;
  219. return $b;
  220. }
  221. }
  222. /**
  223. * Class BucketStub stubs a GCS bucket.
  224. */
  225. class BucketStub extends Bucket
  226. {
  227. public $_objects;
  228. private $_name;
  229. private $_info;
  230. private $_connection;
  231. private $_client;
  232. public function __construct(ConnectionInterface $connection, $name, array $info = array(), $client = null)
  233. {
  234. $this->_name = $name;
  235. $this->_info = $info;
  236. $this->_connection = $connection;
  237. $this->_objects = array();
  238. $this->_client = $client;
  239. }
  240. public function acl()
  241. {
  242. throw new BadMethodCallException('not supported by this stub');
  243. }
  244. public function defaultAcl()
  245. {
  246. throw new BadMethodCallException('not supported by this stub');
  247. }
  248. public function exists()
  249. {
  250. return true;
  251. }
  252. public function upload($data, array $options = array())
  253. {
  254. if (!is_string($data) || !key_exists('name', $options)) {
  255. throw new BadMethodCallException('not supported by this stub');
  256. }
  257. $name = $options['name'];
  258. $generation = '1';
  259. $o = new StorageObjectStub($this->_connection, $name, $this, $generation, $options);
  260. $this->_objects[$options['name']] = $o;
  261. $o->setData($data);
  262. }
  263. public function uploadAsync($data, array $options = array())
  264. {
  265. throw new BadMethodCallException('not supported by this stub');
  266. }
  267. public function getResumableUploader($data, array $options = array())
  268. {
  269. throw new BadMethodCallException('not supported by this stub');
  270. }
  271. public function getStreamableUploader($data, array $options = array())
  272. {
  273. throw new BadMethodCallException('not supported by this stub');
  274. }
  275. public function object($name, array $options = array())
  276. {
  277. if (key_exists($name, $this->_objects)) {
  278. return $this->_objects[$name];
  279. } else {
  280. return new StorageObjectStub($this->_connection, $name, $this, null, $options);
  281. }
  282. }
  283. public function objects(array $options = array())
  284. {
  285. $prefix = key_exists('prefix', $options) ? $options['prefix'] : '';
  286. return new CallbackFilterIterator(
  287. new ArrayIterator($this->_objects),
  288. function ($current, $key, $iterator) use ($prefix) {
  289. return substr($key, 0, strlen($prefix)) == $prefix;
  290. }
  291. );
  292. }
  293. public function createNotification($topic, array $options = array())
  294. {
  295. throw new BadMethodCallException('not supported by this stub');
  296. }
  297. public function notification($id)
  298. {
  299. throw new BadMethodCallException('not supported by this stub');
  300. }
  301. public function notifications(array $options = array())
  302. {
  303. throw new BadMethodCallException('not supported by this stub');
  304. }
  305. public function delete(array $options = array())
  306. {
  307. $this->_client->deleteBucket($this->_name);
  308. }
  309. public function update(array $options = array())
  310. {
  311. throw new BadMethodCallException('not supported by this stub');
  312. }
  313. public function compose(array $sourceObjects, $name, array $options = array())
  314. {
  315. throw new BadMethodCallException('not supported by this stub');
  316. }
  317. public function info(array $options = array())
  318. {
  319. throw new BadMethodCallException('not supported by this stub');
  320. }
  321. public function reload(array $options = array())
  322. {
  323. throw new BadMethodCallException('not supported by this stub');
  324. }
  325. public function name()
  326. {
  327. return $this->_name;
  328. }
  329. public static function lifecycle(array $lifecycle = array())
  330. {
  331. throw new BadMethodCallException('not supported by this stub');
  332. }
  333. public function currentLifecycle(array $options = array())
  334. {
  335. throw new BadMethodCallException('not supported by this stub');
  336. }
  337. public function isWritable($file = null)
  338. {
  339. throw new BadMethodCallException('not supported by this stub');
  340. }
  341. public function iam()
  342. {
  343. throw new BadMethodCallException('not supported by this stub');
  344. }
  345. public function lockRetentionPolicy(array $options = array())
  346. {
  347. throw new BadMethodCallException('not supported by this stub');
  348. }
  349. public function signedUrl($expires, array $options = array())
  350. {
  351. throw new BadMethodCallException('not supported by this stub');
  352. }
  353. public function generateSignedPostPolicyV4($objectName, $expires, array $options = array())
  354. {
  355. throw new BadMethodCallException('not supported by this stub');
  356. }
  357. }
  358. /**
  359. * Class StorageObjectStub stubs a GCS storage object.
  360. */
  361. class StorageObjectStub extends StorageObject
  362. {
  363. private $_name;
  364. private $_data;
  365. private $_info;
  366. private $_bucket;
  367. private $_generation;
  368. private $_exists = false;
  369. private $_connection;
  370. public function __construct(ConnectionInterface $connection, $name, $bucket, $generation = null, array $info = array(), $encryptionKey = null, $encryptionKeySHA256 = null)
  371. {
  372. $this->_name = $name;
  373. $this->_bucket = $bucket;
  374. $this->_generation = $generation;
  375. $this->_info = $info;
  376. $this->_connection = $connection;
  377. }
  378. public function acl()
  379. {
  380. throw new BadMethodCallException('not supported by this stub');
  381. }
  382. public function exists(array $options = array())
  383. {
  384. return key_exists($this->_name, $this->_bucket->_objects);
  385. }
  386. /**
  387. * @throws NotFoundException
  388. */
  389. public function delete(array $options = array())
  390. {
  391. if (key_exists($this->_name, $this->_bucket->_objects)) {
  392. unset($this->_bucket->_objects[$this->_name]);
  393. } else {
  394. throw new NotFoundException('key ' . $this->_name . ' not found.');
  395. }
  396. }
  397. /**
  398. * @throws NotFoundException
  399. */
  400. public function update(array $metadata, array $options = array())
  401. {
  402. if (!$this->_exists) {
  403. throw new NotFoundException('key ' . $this->_name . ' not found.');
  404. }
  405. $this->_info = $metadata;
  406. }
  407. public function copy($destination, array $options = array())
  408. {
  409. throw new BadMethodCallException('not supported by this stub');
  410. }
  411. public function rewrite($destination, array $options = array())
  412. {
  413. throw new BadMethodCallException('not supported by this stub');
  414. }
  415. public function rename($name, array $options = array())
  416. {
  417. throw new BadMethodCallException('not supported by this stub');
  418. }
  419. /**
  420. * @throws NotFoundException
  421. */
  422. public function downloadAsString(array $options = array())
  423. {
  424. if (!$this->_exists) {
  425. throw new NotFoundException('key ' . $this->_name . ' not found.');
  426. }
  427. return $this->_data;
  428. }
  429. public function downloadToFile($path, array $options = array())
  430. {
  431. throw new BadMethodCallException('not supported by this stub');
  432. }
  433. public function downloadAsStream(array $options = array())
  434. {
  435. throw new BadMethodCallException('not supported by this stub');
  436. }
  437. public function downloadAsStreamAsync(array $options = array())
  438. {
  439. throw new BadMethodCallException('not supported by this stub');
  440. }
  441. public function signedUrl($expires, array $options = array())
  442. {
  443. throw new BadMethodCallException('not supported by this stub');
  444. }
  445. public function signedUploadUrl($expires, array $options = array())
  446. {
  447. throw new BadMethodCallException('not supported by this stub');
  448. }
  449. public function beginSignedUploadSession(array $options = array())
  450. {
  451. throw new BadMethodCallException('not supported by this stub');
  452. }
  453. public function info(array $options = array())
  454. {
  455. return key_exists('metadata',$this->_info) ? $this->_info['metadata'] : array();
  456. }
  457. public function reload(array $options = array())
  458. {
  459. throw new BadMethodCallException('not supported by this stub');
  460. }
  461. public function name()
  462. {
  463. return $this->_name;
  464. }
  465. public function identity()
  466. {
  467. throw new BadMethodCallException('not supported by this stub');
  468. }
  469. public function gcsUri()
  470. {
  471. return sprintf(
  472. 'gs://%s/%s',
  473. $this->_bucket->name(),
  474. $this->_name
  475. );
  476. }
  477. public function setData($data)
  478. {
  479. $this->_data = $data;
  480. $this->_exists = true;
  481. }
  482. }
  483. /**
  484. * Class ConnectionInterfaceStub required for the stubs.
  485. */
  486. class ConnectionInterfaceStub implements ConnectionInterface
  487. {
  488. public function deleteAcl(array $args = array())
  489. {
  490. throw new BadMethodCallException('not supported by this stub');
  491. }
  492. public function getAcl(array $args = array())
  493. {
  494. throw new BadMethodCallException('not supported by this stub');
  495. }
  496. public function listAcl(array $args = array())
  497. {
  498. throw new BadMethodCallException('not supported by this stub');
  499. }
  500. public function insertAcl(array $args = array())
  501. {
  502. throw new BadMethodCallException('not supported by this stub');
  503. }
  504. public function patchAcl(array $args = array())
  505. {
  506. throw new BadMethodCallException('not supported by this stub');
  507. }
  508. public function deleteBucket(array $args = array())
  509. {
  510. throw new BadMethodCallException('not supported by this stub');
  511. }
  512. public function getBucket(array $args = array())
  513. {
  514. throw new BadMethodCallException('not supported by this stub');
  515. }
  516. public function listBuckets(array $args = array())
  517. {
  518. throw new BadMethodCallException('not supported by this stub');
  519. }
  520. public function insertBucket(array $args = array())
  521. {
  522. throw new BadMethodCallException('not supported by this stub');
  523. }
  524. public function getBucketIamPolicy(array $args)
  525. {
  526. throw new BadMethodCallException('not supported by this stub');
  527. }
  528. public function setBucketIamPolicy(array $args)
  529. {
  530. throw new BadMethodCallException('not supported by this stub');
  531. }
  532. public function testBucketIamPermissions(array $args)
  533. {
  534. throw new BadMethodCallException('not supported by this stub');
  535. }
  536. public function patchBucket(array $args = array())
  537. {
  538. throw new BadMethodCallException('not supported by this stub');
  539. }
  540. public function deleteObject(array $args = array())
  541. {
  542. throw new BadMethodCallException('not supported by this stub');
  543. }
  544. public function copyObject(array $args = array())
  545. {
  546. throw new BadMethodCallException('not supported by this stub');
  547. }
  548. public function rewriteObject(array $args = array())
  549. {
  550. throw new BadMethodCallException('not supported by this stub');
  551. }
  552. public function composeObject(array $args = array())
  553. {
  554. throw new BadMethodCallException('not supported by this stub');
  555. }
  556. public function getObject(array $args = array())
  557. {
  558. throw new BadMethodCallException('not supported by this stub');
  559. }
  560. public function listObjects(array $args = array())
  561. {
  562. throw new BadMethodCallException('not supported by this stub');
  563. }
  564. public function patchObject(array $args = array())
  565. {
  566. throw new BadMethodCallException('not supported by this stub');
  567. }
  568. public function downloadObject(array $args = array())
  569. {
  570. throw new BadMethodCallException('not supported by this stub');
  571. }
  572. public function insertObject(array $args = array())
  573. {
  574. throw new BadMethodCallException('not supported by this stub');
  575. }
  576. public function getNotification(array $args = array())
  577. {
  578. throw new BadMethodCallException('not supported by this stub');
  579. }
  580. public function deleteNotification(array $args = array())
  581. {
  582. throw new BadMethodCallException('not supported by this stub');
  583. }
  584. public function insertNotification(array $args = array())
  585. {
  586. throw new BadMethodCallException('not supported by this stub');
  587. }
  588. public function listNotifications(array $args = array())
  589. {
  590. throw new BadMethodCallException('not supported by this stub');
  591. }
  592. public function getServiceAccount(array $args = array())
  593. {
  594. throw new BadMethodCallException('not supported by this stub');
  595. }
  596. public function lockRetentionPolicy(array $args = array())
  597. {
  598. throw new BadMethodCallException('not supported by this stub');
  599. }
  600. public function createHmacKey(array $args = array())
  601. {
  602. throw new BadMethodCallException('not supported by this stub');
  603. }
  604. public function deleteHmacKey(array $args = array())
  605. {
  606. throw new BadMethodCallException('not supported by this stub');
  607. }
  608. public function getHmacKey(array $args = array())
  609. {
  610. throw new BadMethodCallException('not supported by this stub');
  611. }
  612. public function updateHmacKey(array $args = array())
  613. {
  614. throw new BadMethodCallException('not supported by this stub');
  615. }
  616. public function listHmacKeys(array $args = array())
  617. {
  618. throw new BadMethodCallException('not supported by this stub');
  619. }
  620. }