V2Test.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Service_Amazon_Authentication
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: AllTests.php 11973 2008-10-15 16:00:56Z matthew $
  21. */
  22. require_once 'Zend/Service/Amazon/Authentication/V2.php';
  23. /**
  24. * Amazon V2 authentication test case
  25. *
  26. * @category Zend
  27. * @package Zend_Service_Amazon_Authentication
  28. * @subpackage UnitTests
  29. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. class Zend_Service_Amazon_Authentication_V2Test extends PHPUnit_Framework_TestCase
  33. {
  34. /**
  35. * @var Zend_Service_Amazon_Authentication_V2
  36. */
  37. private $Zend_Service_Amazon_Authentication_V2;
  38. /**
  39. * Prepares the environment before running a test.
  40. */
  41. protected function setUp()
  42. {
  43. parent::setUp();
  44. $this->Zend_Service_Amazon_Authentication_V2 = new Zend_Service_Amazon_Authentication_V2('0PN5J17HBGZHT7JJ3X82', 'uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o', '2009-07-15');
  45. }
  46. /**
  47. * Cleans up the environment after running a test.
  48. */
  49. protected function tearDown()
  50. {
  51. $this->Zend_Service_Amazon_Authentication_V2 = null;
  52. parent::tearDown();
  53. }
  54. /**
  55. * Tests Zend_Service_Amazon_Authentication_V2::generateSignature()
  56. */
  57. public function testGenerateEc2PostSignature()
  58. {
  59. $url = "https://ec2.amazonaws.com/";
  60. $params = array();
  61. $params['Action'] = "DescribeImages";
  62. $params['ImageId.1'] = "ami-2bb65342";
  63. $params['Timestamp'] = "2009-11-11T13:52:38Z";
  64. $ret = $this->Zend_Service_Amazon_Authentication_V2->generateSignature($url, $params);
  65. $this->assertEquals('8B2cxwK/dfezT49KEzD+wjo1ZbJCddyFOLA0RNZobbc=', $params['Signature']);
  66. $this->assertEquals(file_get_contents(dirname(__FILE__) . '/_files/ec2_v2_return.txt'), $ret);
  67. }
  68. public function testGenerateSqsGetSignature()
  69. {
  70. $url = "https://queue.amazonaws.com/770098461991/queue2";
  71. $params = array();
  72. $params['Action'] = "SetQueueAttributes";
  73. $params['Attribute.Name'] = "VisibilityTimeout";
  74. $params['Attribute.Value'] = "90";
  75. $params['Timestamp'] = "2009-11-11T13:52:38Z";
  76. $this->Zend_Service_Amazon_Authentication_V2->setHttpMethod('GET');
  77. $ret = $this->Zend_Service_Amazon_Authentication_V2->generateSignature($url, $params);
  78. $this->assertEquals('YSw7HXDqokM/A6DhLz8kG+sd+oD5eMjqx3a02A0+GkE=', $params['Signature']);
  79. $this->assertEquals(file_get_contents(dirname(__FILE__) . '/_files/sqs_v2_get_return.txt'), $ret);
  80. }
  81. }