2
0

V2Test.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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-2010 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 dirname(__FILE__) . '/../../../../TestHelper.php';
  23. require_once 'Zend/Service/Amazon/Authentication/V2.php';
  24. /**
  25. * Amazon V2 authentication test case
  26. *
  27. * @category Zend
  28. * @package Zend_Service_Amazon_Authentication
  29. * @subpackage UnitTests
  30. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. class Zend_Service_Amazon_Authentication_V2Test extends PHPUnit_Framework_TestCase
  34. {
  35. /**
  36. * @var Zend_Service_Amazon_Authentication_V2
  37. */
  38. private $Zend_Service_Amazon_Authentication_V2;
  39. /**
  40. * Prepares the environment before running a test.
  41. */
  42. protected function setUp()
  43. {
  44. parent::setUp();
  45. $this->Zend_Service_Amazon_Authentication_V2 = new Zend_Service_Amazon_Authentication_V2('0PN5J17HBGZHT7JJ3X82', 'uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o', '2009-07-15');
  46. }
  47. /**
  48. * Cleans up the environment after running a test.
  49. */
  50. protected function tearDown()
  51. {
  52. $this->Zend_Service_Amazon_Authentication_V2 = null;
  53. parent::tearDown();
  54. }
  55. /**
  56. * Tests Zend_Service_Amazon_Authentication_V2::generateSignature()
  57. */
  58. public function testGenerateEc2PostSignature()
  59. {
  60. $url = "https://ec2.amazonaws.com/";
  61. $params = array();
  62. $params['Action'] = "DescribeImages";
  63. $params['ImageId.1'] = "ami-2bb65342";
  64. $params['Timestamp'] = "2009-11-11T13:52:38Z";
  65. $ret = $this->Zend_Service_Amazon_Authentication_V2->generateSignature($url, $params);
  66. $this->assertEquals('8B2cxwK/dfezT49KEzD+wjo1ZbJCddyFOLA0RNZobbc=', $params['Signature']);
  67. $this->assertEquals(file_get_contents(dirname(__FILE__) . '/_files/ec2_v2_return.txt'), $ret);
  68. }
  69. public function testGenerateSqsGetSignature()
  70. {
  71. $url = "https://queue.amazonaws.com/770098461991/queue2";
  72. $params = array();
  73. $params['Action'] = "SetQueueAttributes";
  74. $params['Attribute.Name'] = "VisibilityTimeout";
  75. $params['Attribute.Value'] = "90";
  76. $params['Timestamp'] = "2009-11-11T13:52:38Z";
  77. $this->Zend_Service_Amazon_Authentication_V2->setHttpMethod('GET');
  78. $ret = $this->Zend_Service_Amazon_Authentication_V2->generateSignature($url, $params);
  79. $this->assertEquals('YSw7HXDqokM/A6DhLz8kG+sd+oD5eMjqx3a02A0+GkE=', $params['Signature']);
  80. $this->assertEquals(file_get_contents(dirname(__FILE__) . '/_files/sqs_v2_get_return.txt'), $ret);
  81. }
  82. }