fog-terremark 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a64a4dc8465dbef97566ac40df9eadf55082645
4
- data.tar.gz: 51fe44d6f759172319b639f7a82346378f2dcc5e
3
+ metadata.gz: e34b03eb966c2bff4765e3a09fdb7c5b1acc922f
4
+ data.tar.gz: 07830710067565af142020e0c489ba13e5d71e4f
5
5
  SHA512:
6
- metadata.gz: ddef7490923c5fccb39199805cdc90c8e838a22142a84ffe01ba96cae45b2f69367c272d6c387f7e003fbad0ccb0731897114847c193fe24718a9c5e5c3810c9
7
- data.tar.gz: 3f1c094464eeeb8857560e2a7c88586777f31f9d5c4eb9ee85070510fa5ff3f8343593115d0eadc845fd2b9f0f1909c1ad26299c11dd8c57980d689cd8e32047
6
+ metadata.gz: f05d7f1cc4d1b922dc7b57dfbb9a64d74642d89ef7c50fd86b048e3ac0710e29083ec3d6034b22ec74cb4a11b91c47a392104d1870ce12ae0109ca2ec9e7f89f
7
+ data.tar.gz: 0dc74bdeb681d33d5cf7aa88c43db11af1ca720b31b4c692e1e56c545c2526ad17f7bd8f8e47377f7ba7c980083ece4ac212e51a572eb6dc25f422ce65645a71
data/.hound.yml ADDED
@@ -0,0 +1,20 @@
1
+ Metrics/LineLength:
2
+ Enabled: false
3
+
4
+ Style/EachWithObject:
5
+ Enabled: false
6
+
7
+ Style/Encoding:
8
+ EnforcedStyle: when_needed
9
+
10
+ Style/FormatString:
11
+ Enabled: false
12
+
13
+ Style/HashSyntax:
14
+ EnforcedStyle: hash_rockets
15
+
16
+ Style/SignalException:
17
+ EnforcedStyle: only_raise
18
+
19
+ Style/StringLiterals:
20
+ EnforcedStyle: double_quotes
data/CONTRIBUTORS.md CHANGED
@@ -5,6 +5,7 @@
5
5
  * James Herdman <james.herdman@me.com>
6
6
  * Juris Galang <jurisgalang@gmail.com>
7
7
  * marios <marios@redhat.com>
8
+ * Nathan Buesgens <nathan@natb1.com>
8
9
  * Paul Thornthwaite <tokengeek@gmail.com>
9
10
  * Paulo Henrique Lopes Ribeiro <plribeiro3000@gmail.com>
10
11
  * Wesley Beary <geemus@gmail.com>
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Fog::Terremark
2
2
 
3
+ ![Gem Version](https://badge.fury.io/rb/fog-terremark.svg) [![Build Status](https://travis-ci.org/fog/fog-terremark.svg?branch=master)](https://travis-ci.org/fog/fog-terremark) [![Dependency Status](https://gemnasium.com/fog/fog-terremark.svg)](https://gemnasium.com/fog/fog-terremark) [![Coverage Status](https://img.shields.io/coveralls/fog/fog-terremark.svg)](https://coveralls.io/r/fog/fog-terremark?branch=master) [![Code Climate](https://codeclimate.com/github/fog/fog-terremark.png)](https://codeclimate.com/github/fog/fog-terremark)
4
+
3
5
  Module for the 'fog' gem to support Terremark vCloud
4
6
 
5
7
  ## Help Needed
@@ -1,22 +1,25 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'fog/terremark/version'
4
+ require "fog/terremark/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "fog-terremark"
8
8
  spec.version = Fog::Terremark::VERSION
9
9
  spec.authors = ["Paulo Henrique Lopes Ribeiro"]
10
10
  spec.email = ["plribeiro3000@gmail.com"]
11
- spec.summary = %q{Module for the 'fog' gem to support Terremark vCloud.}
12
- spec.description = %q{This library can be used as a module for `fog` or as standalone provider
13
- to use the Terremark vCloud in applications.}
11
+ spec.summary = "Module for the 'fog' gem to support Terremark vCloud."
12
+ spec.description = <<-EOS
13
+ This library can be used as a module for `fog` or
14
+ as standalone provider to use the Terremark vCloud in
15
+ applications.
16
+ EOS
14
17
  spec.homepage = ""
15
18
  spec.license = "MIT"
16
19
 
17
20
  spec.files = `git ls-files -z`.split("\x0")
18
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
22
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
20
23
  spec.require_paths = ["lib"]
21
24
 
22
25
  spec.add_dependency "fog-core"
@@ -26,6 +29,7 @@ Gem::Specification.new do |spec|
26
29
  spec.add_development_dependency "minitest"
27
30
  spec.add_development_dependency "turn"
28
31
  spec.add_development_dependency "pry"
32
+ spec.add_development_dependency "vcr"
29
33
 
30
34
  if RUBY_VERSION.to_f > 1.9
31
35
  spec.add_development_dependency "coveralls"
@@ -1,12 +1,13 @@
1
1
  module Fog
2
2
  module Compute
3
3
  class Terremark
4
+ # doc stub
4
5
  module Common
5
6
  def default_organization_id
6
7
  @default_organization_id ||= begin
7
- org_list = get_organizations.body['OrgList']
8
+ org_list = organizations.body["OrgList"]
8
9
  if org_list.length == 1
9
- org_list.first['href'].split('/').last.to_i
10
+ org_list.first["href"].split("/").last.to_i
10
11
  else
11
12
  nil
12
13
  end
@@ -1,6 +1,7 @@
1
1
  module Fog
2
2
  module Compute
3
3
  class Terremark
4
+ # documentation stub
4
5
  class Real
5
6
  include Common
6
7
 
@@ -12,18 +13,28 @@ module Fog
12
13
  private
13
14
 
14
15
  def auth_token
15
- response = @connection.request({
16
- :expects => 200,
17
- :headers => {
18
- 'Authorization' => "Basic #{Base64.encode64("#{@terremark_username}:#{@terremark_password}").chomp!}",
19
- 'Content-Type' => "application/vnd.vmware.vcloud.orgList+xml"
20
- },
21
- :host => @host,
22
- :method => 'POST',
23
- :parser => Fog::Parsers::Terremark::GetOrganizations.new,
24
- :path => "#{@path}/login"
25
- })
26
- response.headers['Set-Cookie']
16
+ response = @connection.request(
17
+ :expects => 200,
18
+ :headers => auth_headers,
19
+ :host => @host,
20
+ :method => "POST",
21
+ :parser => Fog::Parsers::Terremark::GetOrganizations.new,
22
+ :path => "#{@path}/login"
23
+ )
24
+ response.headers["Set-Cookie"]
25
+ end
26
+
27
+ def auth_headers
28
+ credentials = "#{@terremark_username}:#{@terremark_password}"
29
+ encoded_credentials = Base64.encode64(credentials)
30
+ # remove newlines because strict_encode64 is not compatible with 1.8
31
+ encoded_credentials = encoded_credentials.gsub(/\n/, "")
32
+ {
33
+ "Authorization" => "Basic #{encoded_credentials}",
34
+ # Terremark said they're going to remove passing in the
35
+ # Content-Type to login in a future release
36
+ "Content-Type" => "application/vnd.vmware.vcloud.orgList+xml"
37
+ }
27
38
  end
28
39
 
29
40
  def reload
@@ -31,9 +42,7 @@ module Fog
31
42
  end
32
43
 
33
44
  def request(params)
34
- unless @cookie
35
- @cookie = auth_token
36
- end
45
+ @cookie ||= auth_token
37
46
  begin
38
47
  do_request(params)
39
48
  rescue Excon::Errors::Unauthorized
@@ -43,30 +52,35 @@ module Fog
43
52
  end
44
53
 
45
54
  def do_request(params)
55
+ @connection.request(
56
+ :body => params[:body],
57
+ :expects => params[:expects],
58
+ :headers => make_headers(params),
59
+ :host => @host,
60
+ :method => params[:method],
61
+ :parser => params[:parser],
62
+ :path => make_path(params)
63
+ )
64
+ end
65
+
66
+ def make_headers(params)
46
67
  headers = {}
47
- if @cookie
48
- headers.merge!('Cookie' => @cookie)
49
- end
68
+ headers.merge!("Cookie" => @cookie) if @cookie
69
+ headers.merge!(params[:headers] || {})
70
+ end
71
+
72
+ def make_path(params)
50
73
  if params[:path]
51
74
  if params[:override_path] == true
52
- path = params[:path]
75
+ params[:path]
53
76
  else
54
- path = "#{@path}/#{params[:path]}"
77
+ "#{@path}/#{params[:path]}"
55
78
  end
56
79
  else
57
- path = "#{@path}"
80
+ "#{@path}"
58
81
  end
59
- @connection.request({
60
- :body => params[:body],
61
- :expects => params[:expects],
62
- :headers => headers.merge!(params[:headers] || {}),
63
- :host => @host,
64
- :method => params[:method],
65
- :parser => params[:parser],
66
- :path => path
67
- })
68
82
  end
69
83
  end
70
84
  end
71
85
  end
72
- end
86
+ end
@@ -1,6 +1,7 @@
1
1
  module Fog
2
2
  module Compute
3
3
  class Terremark
4
+ # doc stub
4
5
  class Real
5
6
  # Get list of organizations
6
7
  #
@@ -10,34 +11,34 @@ module Fog
10
11
  # * 'description'<~String> - Description of organization
11
12
  # * 'links'<~Array> - An array of links to entities in the organization
12
13
  # * 'name'<~String> - Name of organization
13
- def get_organizations
14
- request({
15
- :expects => 200,
16
- :headers => {
17
- 'Authorization' => "Basic #{Base64.encode64("#{@terremark_username}:#{@terremark_password}").chomp!}",
18
- # Terremark said they're going to remove passing in the Content-Type to login in a future release
19
- 'Content-Type' => "application/vnd.vmware.vcloud.orgList+xml"
20
- },
21
- :method => 'POST',
22
- :parser => Fog::Parsers::Terremark::GetOrganizations.new,
23
- :path => 'login'
24
- })
14
+ def organizations
15
+ request(
16
+ :expects => 200,
17
+ :headers => auth_headers,
18
+ :method => "POST",
19
+ :parser => Fog::Parsers::Terremark::GetOrganizations.new,
20
+ :path => "login"
21
+ )
25
22
  end
26
23
  end
27
24
 
25
+ # doc stub
28
26
  class Mock
29
- def get_organizations
27
+ def organizations
30
28
  response = Excon::Response.new
31
- org_list = self.data[:organizations].map do |organization|
29
+ response.body = { "OrgList" => org_fixture }
30
+ response.status = 200
31
+ response.headers = Fog::Compute::Terremark::Mock.headers(response.body, "application/vnd.vmware.vcloud.orgList+xml")
32
+ response
33
+ end
34
+
35
+ def org_fixture
36
+ data[:organizations].map do |organization|
32
37
  { "name" => organization[:info][:name],
33
38
  "href" => "#{@base_url}/org/#{organization[:info][:id]}",
34
39
  "type" => "application/vnd.vmware.vcloud.org+xml"
35
40
  }
36
41
  end
37
- response.body = { "OrgList" => org_list }
38
- response.status = 200
39
- response.headers = Fog::Compute::Terremark::Mock.headers(response.body, "application/vnd.vmware.vcloud.orgList+xml")
40
- response
41
42
  end
42
43
  end
43
44
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Terremark
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/login
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - fog-core/1.25.0
12
+ Authorization:
13
+ - Basic CREDENTIALS
14
+ Content-Type:
15
+ - application/vnd.vmware.vcloud.orgList+xml
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ Cache-Control:
22
+ - private
23
+ Content-Length:
24
+ - '328'
25
+ Content-Type:
26
+ - application/vnd.vmware.vcloud.orgList+xml
27
+ Server:
28
+ - Microsoft-IIS/7.0
29
+ X-AspNet-Version:
30
+ - 4.0.30319
31
+ Set-Cookie:
32
+ - vcloud-token=TOKEN; path=/
33
+ X-Powered-By:
34
+ - ASP.NET
35
+ Date:
36
+ - Mon, 24 Nov 2014 20:39:30 GMT
37
+ body:
38
+ encoding: UTF-8
39
+ string: |-
40
+ <OrgList xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
41
+ <Org href="https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/org/ORG_ID" type="application/vnd.vmware.vcloud.org+xml" name="TERREMARK_VCLOUD_USERNAME"/>
42
+ </OrgList>
43
+ http_version:
44
+ recorded_at: Mon, 24 Nov 2014 20:39:30 GMT
45
+ recorded_with: VCR 2.9.3
@@ -1,9 +1,14 @@
1
- require 'minitest_helper'
1
+ require "minitest_helper"
2
2
 
3
- describe Fog::Compute::Terremark do
4
- it 'authenticates' do
5
- Fog::Compute::Terremark.new(
6
- :terremark_vcloud_username => 'test@example.com',
7
- :terremark_vcloud_password => '123456')
3
+ describe Fog::Terremark::Vcloud do
4
+
5
+ it "gets a login token" do
6
+ VCR.use_cassette("get_login_token") do
7
+ service = Fog::Terremark::Vcloud.new(
8
+ :terremark_vcloud_username => "test@example.com",
9
+ :terremark_vcloud_password => "123456")
10
+ service.send(:auth_token)
11
+ end
8
12
  end
9
- end
13
+
14
+ end
@@ -1,6 +1,7 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'turn'
1
+ require "minitest/spec"
2
+ require "minitest/autorun"
3
+ require "turn"
4
+ require "vcr"
4
5
 
5
6
  Turn.config do |c|
6
7
  # use one of output formats:
@@ -17,15 +18,21 @@ Turn.config do |c|
17
18
  c.natural = true
18
19
  end
19
20
 
20
- if ENV['COVERAGE']
21
- require 'coveralls'
22
- require 'simplecov'
21
+ VCR.configure do |c|
22
+ c.cassette_library_dir = "spec/cassettes"
23
+ c.hook_into :excon
24
+ c.debug_logger = $stderr
25
+ end
26
+
27
+ if ENV["COVERAGE"]
28
+ require "coveralls"
29
+ require "simplecov"
23
30
 
24
31
  SimpleCov.start do
25
- add_filter '/spec/'
32
+ add_filter "/spec/"
26
33
  end
27
34
  end
28
35
 
29
- require File.join(File.dirname(__FILE__), '../lib/fog/terremark.rb')
36
+ require File.join(File.dirname(__FILE__), "../lib/fog/terremark.rb")
30
37
 
31
- Coveralls.wear! if ENV['COVERAGE']
38
+ Coveralls.wear! if ENV["COVERAGE"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-terremark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Henrique Lopes Ribeiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-19 00:00:00.000000000 Z
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: vcr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: coveralls
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -122,9 +136,10 @@ dependencies:
122
136
  - - ">="
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
- description: |-
126
- This library can be used as a module for `fog` or as standalone provider
127
- to use the Terremark vCloud in applications.
139
+ description: |2
140
+ This library can be used as a module for `fog` or
141
+ as standalone provider to use the Terremark vCloud in
142
+ applications.
128
143
  email:
129
144
  - plribeiro3000@gmail.com
130
145
  executables: []
@@ -132,6 +147,7 @@ extensions: []
132
147
  extra_rdoc_files: []
133
148
  files:
134
149
  - ".gitignore"
150
+ - ".hound.yml"
135
151
  - ".rubocop.yml"
136
152
  - ".ruby-gemset"
137
153
  - ".ruby-version"
@@ -223,6 +239,7 @@ files:
223
239
  - lib/fog/terremark/vcloud/mock.rb
224
240
  - lib/fog/terremark/vcloud/real.rb
225
241
  - lib/fog/terremark/version.rb
242
+ - spec/cassettes/get_login_token.yml
226
243
  - spec/credentials_spec.rb
227
244
  - spec/minitest_helper.rb
228
245
  homepage: ''
@@ -250,5 +267,6 @@ signing_key:
250
267
  specification_version: 4
251
268
  summary: Module for the 'fog' gem to support Terremark vCloud.
252
269
  test_files:
270
+ - spec/cassettes/get_login_token.yml
253
271
  - spec/credentials_spec.rb
254
272
  - spec/minitest_helper.rb