deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject git commit: Adds Unit test for EC2 driver - part of JIRA DTACLOUD_300
Date Thu, 04 Oct 2012 09:16:31 GMT
Updated Branches:
  refs/heads/master 37706ac1d -> 633b9b958


Adds Unit test for EC2 driver - part of JIRA DTACLOUD_300

https://issues.apache.org/jira/browse/DTACLOUD-300


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/633b9b95
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/633b9b95
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/633b9b95

Branch: refs/heads/master
Commit: 633b9b9588a24fe639771a7a53f2410a9a052f0d
Parents: 37706ac
Author: marios <marios@redhat.com>
Authored: Thu Oct 4 12:14:38 2012 +0300
Committer: marios <marios@redhat.com>
Committed: Thu Oct 4 12:14:38 2012 +0300

----------------------------------------------------------------------
 server/tests/drivers/ec2/buckets_test.rb           |   45 +++
 ...ow_error_when_wrong_credentials_for_buckets.yml |   45 +++
 ...t_handle_us-east_buckets_from_other_regions.yml |  241 +++++++++++++++
 server/tests/drivers/ec2/keys_test.rb              |    2 +-
 4 files changed, 332 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/633b9b95/server/tests/drivers/ec2/buckets_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/drivers/ec2/buckets_test.rb b/server/tests/drivers/ec2/buckets_test.rb
new file mode 100644
index 0000000..bf058ba
--- /dev/null
+++ b/server/tests/drivers/ec2/buckets_test.rb
@@ -0,0 +1,45 @@
+require 'minitest/autorun'
+
+require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'api.rb')
+require_relative 'common.rb'
+
+describe 'Ec2Driver Buckets' do
+
+  def credentials
+  {
+    :user => "AKIAJATNOR5HKG3FK27Q",
+    :password => "dPe47rAlKhlBdTYNbL4ZsMthDga08vEL9d3MS5UO"
+  }
+  end
+
+  before do
+    @driver = Deltacloud::new(:ec2, credentials)
+    VCR.insert_cassette __name__
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'must throw error when wrong credentials for buckets' do
+    Proc.new do
+      @driver.backend.buckets(OpenStruct.new(:user => 'unknown', :password => 'wrong'))
+    end.must_raise Deltacloud::ExceptionHandler::AuthenticationFailure, 'Authentication Failure'
+  end
+
+
+  it 'must handle us-east buckets from other regions' do
+    #create us-east bucket:
+    bucket = @driver.create_bucket("deltacloud-unit-test-bucket-2012-08-20-1704")
+    #get a new deltacloud handle using eu-west-1
+    @dcloud_other_provider = Deltacloud::new(:ec2, credentials.merge!(:provider=>"eu-west-1"))
+    #get the bucket and check
+    retrieved_bucket = @dcloud_other_provider.bucket(:id=>bucket.name)
+    retrieved_bucket.must_be_kind_of Bucket
+    retrieved_bucket.name.must_equal bucket.name
+    #delete the bucket
+    @driver.delete_bucket(bucket.id)
+  end
+
+end
+

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/633b9b95/server/tests/drivers/ec2/fixtures/test_0001_must_throw_error_when_wrong_credentials_for_buckets.yml
----------------------------------------------------------------------
diff --git a/server/tests/drivers/ec2/fixtures/test_0001_must_throw_error_when_wrong_credentials_for_buckets.yml
b/server/tests/drivers/ec2/fixtures/test_0001_must_throw_error_when_wrong_credentials_for_buckets.yml
new file mode 100644
index 0000000..3f0dd19
--- /dev/null
+++ b/server/tests/drivers/ec2/fixtures/test_0001_must_throw_error_when_wrong_credentials_for_buckets.yml
@@ -0,0 +1,45 @@
+---
+http_interactions:
+- request:
+    method: get
+    uri: https://s3.amazonaws.com/
+    body:
+      encoding: US-ASCII
+      string: ''
+    headers:
+      Accept:
+      - ! '*/*'
+      User-Agent:
+      - ''
+      Content-Type:
+      - ''
+      Date:
+      - Mon, 20 Aug 2012 14:06:08 GMT
+      Authorization:
+      - AWS unknown:p8j2Xe8l9rpxPtrKTCB38A3Gj70=
+  response:
+    status:
+      code: 403
+      message: Forbidden
+    headers:
+      X-Amz-Request-Id:
+      - 2B20922621B929F8
+      X-Amz-Id-2:
+      - IPzHlEuNqVDDS4X6IZPpbzMn2SyX2I9gKAx5iNKFnjxfR/63SBMwEdqSsZf7sBVs
+      Content-Type:
+      - application/xml
+      Transfer-Encoding:
+      - chunked
+      Date:
+      - Mon, 20 Aug 2012 14:06:38 GMT
+      Server:
+      - AmazonS3
+    body:
+      encoding: US-ASCII
+      string: ! '<?xml version="1.0" encoding="UTF-8"?>
+
+        <Error><Code>InvalidAccessKeyId</Code><Message>The AWS Access
Key Id you provided
+        does not exist in our records.</Message><RequestId>2B20922621B929F8</RequestId><HostId>IPzHlEuNqVDDS4X6IZPpbzMn2SyX2I9gKAx5iNKFnjxfR/63SBMwEdqSsZf7sBVs</HostId><AWSAccessKeyId>unknown</AWSAccessKeyId></Error>'
+    http_version: 
+  recorded_at: Mon, 20 Aug 2012 14:06:08 GMT
+recorded_with: VCR 2.2.4

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/633b9b95/server/tests/drivers/ec2/fixtures/test_0002_must_handle_us-east_buckets_from_other_regions.yml
----------------------------------------------------------------------
diff --git a/server/tests/drivers/ec2/fixtures/test_0002_must_handle_us-east_buckets_from_other_regions.yml
b/server/tests/drivers/ec2/fixtures/test_0002_must_handle_us-east_buckets_from_other_regions.yml
new file mode 100644
index 0000000..d3eae31
--- /dev/null
+++ b/server/tests/drivers/ec2/fixtures/test_0002_must_handle_us-east_buckets_from_other_regions.yml
@@ -0,0 +1,241 @@
+---
+http_interactions:
+- request:
+    method: put
+    uri: https://deltacloud-unit-test-bucket-2012-08-20-1704.s3.amazonaws.com/
+    body:
+      encoding: US-ASCII
+      string: ''
+    headers:
+      Accept:
+      - ! '*/*'
+      User-Agent:
+      - ''
+      Content-Type:
+      - ''
+      Date:
+      - Mon, 20 Aug 2012 14:06:08 GMT
+      Authorization:
+      - AWS AKIAJATNOR5HKG3FK27Q:pZyM6A8WVe0/+yLg95Eb0S2atoU=
+  response:
+    status:
+      code: 200
+      message: OK
+    headers:
+      X-Amz-Id-2:
+      - 3WmPGTXyN1qVuZtEUuGPBGsG3fBRFdmgeWle4UawtBKKtsxbv9mFD5f9OiDhuQVR
+      X-Amz-Request-Id:
+      - EE4EFF4E050A0F73
+      Date:
+      - Mon, 20 Aug 2012 14:06:33 GMT
+      Location:
+      - /deltacloud-unit-test-bucket-2012-08-20-1704
+      Content-Length:
+      - '0'
+      Server:
+      - AmazonS3
+    body:
+      encoding: US-ASCII
+      string: ''
+    http_version: 
+  recorded_at: Mon, 20 Aug 2012 14:06:08 GMT
+- request:
+    method: get
+    uri: https://deltacloud-unit-test-bucket-2012-08-20-1704.s3.amazonaws.com/
+    body:
+      encoding: US-ASCII
+      string: ''
+    headers:
+      Accept:
+      - ! '*/*'
+      User-Agent:
+      - ''
+      Content-Type:
+      - ''
+      Date:
+      - Mon, 20 Aug 2012 14:06:08 GMT
+      Authorization:
+      - AWS AKIAJATNOR5HKG3FK27Q:diWaoSnrqX5+KMsYW37szZNyAjk=
+  response:
+    status:
+      code: 200
+      message: OK
+    headers:
+      X-Amz-Id-2:
+      - FWZg1qYxzENl3WZy1xfmcy/ZLnfncCRGp0l8guPbvkARlsFiExGWTKLGFFztlF21
+      X-Amz-Request-Id:
+      - 9808A15AB1C16636
+      Date:
+      - Mon, 20 Aug 2012 14:06:34 GMT
+      Content-Type:
+      - application/xml
+      Transfer-Encoding:
+      - chunked
+      Server:
+      - AmazonS3
+    body:
+      encoding: US-ASCII
+      string: ! '<?xml version="1.0" encoding="UTF-8"?>
+
+        <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>deltacloud-unit-test-bucket-2012-08-20-1704</Name><Prefix></Prefix><Marker></Marker><MaxKeys>1000</MaxKeys><IsTruncated>false</IsTruncated></ListBucketResult>'
+    http_version: 
+  recorded_at: Mon, 20 Aug 2012 14:06:08 GMT
+- request:
+    method: get
+    uri: https://deltacloud-unit-test-bucket-2012-08-20-1704.s3-eu-west-1.amazonaws.com/?location
+    body:
+      encoding: US-ASCII
+      string: ''
+    headers:
+      Accept:
+      - ! '*/*'
+      User-Agent:
+      - ''
+      Content-Type:
+      - ''
+      Date:
+      - Mon, 20 Aug 2012 14:06:08 GMT
+      Authorization:
+      - AWS AKIAJATNOR5HKG3FK27Q:soqKXfjSbvSgMDEKDboLJyA2S7c=
+  response:
+    status:
+      code: 200
+      message: OK
+    headers:
+      X-Amz-Id-2:
+      - 482vVm6hy7nrd30vvmmgjO97UtTo+w3IoB5aKwNIbKSJ26VYtZOBgE/oGlHiC6kb
+      X-Amz-Request-Id:
+      - A43716F84533C587
+      Date:
+      - Mon, 20 Aug 2012 14:06:35 GMT
+      Content-Type:
+      - application/xml
+      Transfer-Encoding:
+      - chunked
+      Server:
+      - AmazonS3
+    body:
+      encoding: US-ASCII
+      string: ! '<?xml version="1.0" encoding="UTF-8"?>
+
+        <LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/"/>'
+    http_version: 
+  recorded_at: Mon, 20 Aug 2012 14:06:08 GMT
+- request:
+    method: get
+    uri: https://deltacloud-unit-test-bucket-2012-08-20-1704.s3.amazonaws.com/
+    body:
+      encoding: US-ASCII
+      string: ''
+    headers:
+      Accept:
+      - ! '*/*'
+      User-Agent:
+      - ''
+      Content-Type:
+      - ''
+      Date:
+      - Mon, 20 Aug 2012 14:06:08 GMT
+      Authorization:
+      - AWS AKIAJATNOR5HKG3FK27Q:diWaoSnrqX5+KMsYW37szZNyAjk=
+  response:
+    status:
+      code: 200
+      message: OK
+    headers:
+      X-Amz-Id-2:
+      - YYuAnkUgGeuv1HL9nnowa1HuyLhPCdipX9pwAwVWP38MNqqkaIt35SHFlCJcrvhk
+      X-Amz-Request-Id:
+      - CD2B4328F5D2DFE7
+      Date:
+      - Mon, 20 Aug 2012 14:06:36 GMT
+      Content-Type:
+      - application/xml
+      Transfer-Encoding:
+      - chunked
+      Server:
+      - AmazonS3
+    body:
+      encoding: US-ASCII
+      string: ! '<?xml version="1.0" encoding="UTF-8"?>
+
+        <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>deltacloud-unit-test-bucket-2012-08-20-1704</Name><Prefix></Prefix><Marker></Marker><MaxKeys>1000</MaxKeys><IsTruncated>false</IsTruncated></ListBucketResult>'
+    http_version: 
+  recorded_at: Mon, 20 Aug 2012 14:06:08 GMT
+- request:
+    method: get
+    uri: https://deltacloud-unit-test-bucket-2012-08-20-1704.s3-eu-west-1.amazonaws.com/?location
+    body:
+      encoding: US-ASCII
+      string: ''
+    headers:
+      Accept:
+      - ! '*/*'
+      User-Agent:
+      - ''
+      Content-Type:
+      - ''
+      Date:
+      - Mon, 20 Aug 2012 14:06:08 GMT
+      Authorization:
+      - AWS AKIAJATNOR5HKG3FK27Q:soqKXfjSbvSgMDEKDboLJyA2S7c=
+  response:
+    status:
+      code: 200
+      message: OK
+    headers:
+      X-Amz-Id-2:
+      - /WQCyNf2yLrqpDraMM+xRaDlR3es8AZgr1ZD8pZCj8Hdxcsrm9RrIdxbcIgilG1K
+      X-Amz-Request-Id:
+      - 6FFE9B2B10AEC796
+      Date:
+      - Mon, 20 Aug 2012 14:06:37 GMT
+      Content-Type:
+      - application/xml
+      Transfer-Encoding:
+      - chunked
+      Server:
+      - AmazonS3
+    body:
+      encoding: US-ASCII
+      string: ! '<?xml version="1.0" encoding="UTF-8"?>
+
+        <LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/"/>'
+    http_version: 
+  recorded_at: Mon, 20 Aug 2012 14:06:08 GMT
+- request:
+    method: delete
+    uri: https://deltacloud-unit-test-bucket-2012-08-20-1704.s3.amazonaws.com/
+    body:
+      encoding: US-ASCII
+      string: ''
+    headers:
+      Accept:
+      - ! '*/*'
+      User-Agent:
+      - ''
+      Content-Type:
+      - ''
+      Date:
+      - Mon, 20 Aug 2012 14:06:08 GMT
+      Authorization:
+      - AWS AKIAJATNOR5HKG3FK27Q:SDWagYCEvCteLf3g7e5ACMf4/D8=
+  response:
+    status:
+      code: 204
+      message: No Content
+    headers:
+      X-Amz-Id-2:
+      - OONqTQzrZaFbzejOys6I/QpCZR3UOhUS6GADBU2Y4XIm2WTTXXQ9i1aMqxgEDmVX
+      X-Amz-Request-Id:
+      - D731A368D9C9D744
+      Date:
+      - Mon, 20 Aug 2012 14:06:38 GMT
+      Server:
+      - AmazonS3
+    body:
+      encoding: US-ASCII
+      string: ''
+    http_version: 
+  recorded_at: Mon, 20 Aug 2012 14:06:08 GMT
+recorded_with: VCR 2.2.4

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/633b9b95/server/tests/drivers/ec2/keys_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/drivers/ec2/keys_test.rb b/server/tests/drivers/ec2/keys_test.rb
index ac66e23..ca2ab62 100644
--- a/server/tests/drivers/ec2/keys_test.rb
+++ b/server/tests/drivers/ec2/keys_test.rb
@@ -3,7 +3,7 @@ require 'require_relative' if RUBY_VERSION < '1.9'
 
 require_relative 'common.rb'
 
-describe 'Ec2Driver Instances' do
+describe 'Ec2Driver Keys' do
 
   before do
     @driver = Deltacloud::new(:ec2, credentials)


Mime
View raw message