ey_services_api 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ v0.1.0:
2
+
3
+ * Removed creation_response_hash methods on ServiceAccountCreation and ProvisionedServiceCreation.
4
+ Create ServiceAccountResponse and ProvisionedServiceResponse objects directly instead.
5
+ * Tests depend on ey_services_fake gem.
@@ -4,17 +4,17 @@ source "http://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  group :test, :development do
7
+ gem 'ey_services_fake'
7
8
  gem 'rake'
9
+
8
10
  gem 'ey_sso', :git => "git@github.com:engineyard/ey_sso.git"
9
11
 
10
12
  # gem 'tresfiestas', :git => "git@github.com:engineyard/tresfiestas.git"
11
13
  gem 'tresfiestas', :path => "../tresfiestas"
12
14
 
13
- #TODO: this should just be a dep of tresfiestas
14
- gem 'lisonja', :path => "../lisonja"
15
- #TODO: this should just be a dep of lisonja
16
- gem 'ey_services_api', :path => "../ey_services_api"
15
+ gem 'fake_awsm', :path => "../tresfiestas/spike/fake_awsm"
16
+ #TODO: this should just be a dep of fakeawsm
17
+ gem 'ey_services_api_internal', :path => "../ey_services_api_internal"
17
18
 
18
- gem 'sinatra'
19
19
  gem 'guard-rspec'
20
20
  end
@@ -0,0 +1,192 @@
1
+ GIT
2
+ remote: git@github.com:engineyard/ey_sso.git
3
+ revision: ff38d25dd74174d284f469058d63918877304b5d
4
+ specs:
5
+ ey_sso (0.9.17.pre)
6
+ ZenTest (~> 4.5.0)
7
+ addressable (~> 2.2.2)
8
+ artifice (~> 0.6)
9
+ halorgium-auth-hmac (~> 1.1.0)
10
+ json (~> 1.1)
11
+ mechanize (~> 0.9.3)
12
+ rack (~> 1.1)
13
+ randexp (~> 0.1.4)
14
+ rest-client (~> 1.6.0)
15
+ ruby-openid (~> 2.1.7)
16
+ sinatra (~> 1.0)
17
+ uuid (~> 2.3.1)
18
+
19
+ PATH
20
+ remote: ../ey_services_api
21
+ specs:
22
+ ey_services_api (0.0.5)
23
+ ey_api_hmac
24
+ json
25
+
26
+ PATH
27
+ remote: ../ey_services_api_internal
28
+ specs:
29
+ ey_services_api_internal (0.0.4.pre)
30
+ ey_api_hmac
31
+
32
+ PATH
33
+ remote: ../tresfiestas
34
+ specs:
35
+ tresfiestas (0.1.TODO)
36
+ RedCloth
37
+ airbrake
38
+ ey_api_hmac
39
+ ey_sso
40
+ haml
41
+ rails (= 3.0.9)
42
+ sqlite3
43
+
44
+ PATH
45
+ remote: ../tresfiestas/spike/fake_awsm
46
+ specs:
47
+ fake_awsm (0.1.TODO)
48
+ activerecord (= 3.0.9)
49
+ ey_sso
50
+ haml
51
+ sinatra
52
+ sqlite3
53
+
54
+ GEM
55
+ remote: http://rubygems.org/
56
+ specs:
57
+ ParseTree (3.0.8)
58
+ RubyInline (>= 3.7.0)
59
+ sexp_processor (>= 3.0.0)
60
+ RedCloth (4.2.8)
61
+ RubyInline (3.11.0)
62
+ ZenTest (~> 4.3)
63
+ ZenTest (4.5.0)
64
+ abstract (1.0.0)
65
+ actionmailer (3.0.9)
66
+ actionpack (= 3.0.9)
67
+ mail (~> 2.2.19)
68
+ actionpack (3.0.9)
69
+ activemodel (= 3.0.9)
70
+ activesupport (= 3.0.9)
71
+ builder (~> 2.1.2)
72
+ erubis (~> 2.6.6)
73
+ i18n (~> 0.5.0)
74
+ rack (~> 1.2.1)
75
+ rack-mount (~> 0.6.14)
76
+ rack-test (~> 0.5.7)
77
+ tzinfo (~> 0.3.23)
78
+ activemodel (3.0.9)
79
+ activesupport (= 3.0.9)
80
+ builder (~> 2.1.2)
81
+ i18n (~> 0.5.0)
82
+ activerecord (3.0.9)
83
+ activemodel (= 3.0.9)
84
+ activesupport (= 3.0.9)
85
+ arel (~> 2.0.10)
86
+ tzinfo (~> 0.3.23)
87
+ activeresource (3.0.9)
88
+ activemodel (= 3.0.9)
89
+ activesupport (= 3.0.9)
90
+ activesupport (3.0.9)
91
+ addressable (2.2.6)
92
+ airbrake (3.0.4)
93
+ activesupport
94
+ builder
95
+ arel (2.0.10)
96
+ artifice (0.6)
97
+ rack-test
98
+ builder (2.1.2)
99
+ cubbyhole (0.2.0)
100
+ diff-lcs (1.1.3)
101
+ erubis (2.6.6)
102
+ abstract (>= 1.0.0)
103
+ ey_api_hmac (0.0.15)
104
+ json
105
+ rack-client
106
+ ey_services_fake (0.0.1)
107
+ cubbyhole (>= 0.2.0)
108
+ sinatra
109
+ guard (0.8.4)
110
+ thor (~> 0.14.6)
111
+ guard-rspec (0.4.5)
112
+ guard (>= 0.4.0)
113
+ halorgium-auth-hmac (1.1.1.2010100601)
114
+ haml (3.1.3)
115
+ i18n (0.5.0)
116
+ json (1.6.1)
117
+ macaddr (1.4.0)
118
+ systemu (~> 2.2.0)
119
+ mail (2.2.19)
120
+ activesupport (>= 2.3.6)
121
+ i18n (>= 0.4.0)
122
+ mime-types (~> 1.16)
123
+ treetop (~> 1.4.8)
124
+ mechanize (0.9.3)
125
+ nokogiri (>= 1.2.1)
126
+ mime-types (1.16)
127
+ nokogiri (1.5.0)
128
+ polyglot (0.3.2)
129
+ rack (1.2.4)
130
+ rack-client (0.4.0)
131
+ rack (>= 1.0.0)
132
+ rack-mount (0.6.14)
133
+ rack (>= 1.0.0)
134
+ rack-test (0.5.7)
135
+ rack (>= 1.0)
136
+ rails (3.0.9)
137
+ actionmailer (= 3.0.9)
138
+ actionpack (= 3.0.9)
139
+ activerecord (= 3.0.9)
140
+ activeresource (= 3.0.9)
141
+ activesupport (= 3.0.9)
142
+ bundler (~> 1.0)
143
+ railties (= 3.0.9)
144
+ railties (3.0.9)
145
+ actionpack (= 3.0.9)
146
+ activesupport (= 3.0.9)
147
+ rake (>= 0.8.7)
148
+ rdoc (~> 3.4)
149
+ thor (~> 0.14.4)
150
+ rake (0.9.2)
151
+ randexp (0.1.5)
152
+ ParseTree
153
+ rdoc (3.9.4)
154
+ rest-client (1.6.7)
155
+ mime-types (>= 1.16)
156
+ rspec (2.6.0)
157
+ rspec-core (~> 2.6.0)
158
+ rspec-expectations (~> 2.6.0)
159
+ rspec-mocks (~> 2.6.0)
160
+ rspec-core (2.6.4)
161
+ rspec-expectations (2.6.0)
162
+ diff-lcs (~> 1.1.2)
163
+ rspec-mocks (2.6.0)
164
+ ruby-openid (2.1.8)
165
+ sexp_processor (3.0.7)
166
+ sinatra (1.2.7)
167
+ rack (~> 1.1)
168
+ tilt (< 2.0, >= 1.2.2)
169
+ sqlite3 (1.3.4)
170
+ systemu (2.2.0)
171
+ thor (0.14.6)
172
+ tilt (1.3.3)
173
+ treetop (1.4.10)
174
+ polyglot
175
+ polyglot (>= 0.3.1)
176
+ tzinfo (0.3.30)
177
+ uuid (2.3.4)
178
+ macaddr (~> 1.0)
179
+
180
+ PLATFORMS
181
+ ruby
182
+
183
+ DEPENDENCIES
184
+ ey_services_api!
185
+ ey_services_api_internal!
186
+ ey_services_fake
187
+ ey_sso!
188
+ fake_awsm!
189
+ guard-rspec
190
+ rake
191
+ rspec
192
+ tresfiestas!
data/Gemfile CHANGED
@@ -4,8 +4,9 @@ source "http://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  group :test, :development do
7
+ gem 'ey_services_fake'
8
+
7
9
  gem 'rake'
8
- gem 'sinatra'
9
10
  gem 'rcov'
10
11
  gem 'guard-rspec'
11
12
  end
data/README.md CHANGED
@@ -31,5 +31,5 @@ To run specs mocked:
31
31
  To run against tresfiestas codebase: (internal only)
32
32
 
33
33
  * rvm use 1.9.2
34
- * BUNDLE_GEMFILE=InternalGemfile bundle
35
- * BUNDLE_GEMFILE=InternalGemfile bundle exec rake
34
+ * BUNDLE_GEMFILE=EYIntegratedGemfile bundle
35
+ * BUNDLE_GEMFILE=EYIntegratedGemfile bundle exec rake
data/Rakefile CHANGED
@@ -6,5 +6,5 @@ task :default => :spec
6
6
  desc "Run specs"
7
7
  RSpec::Core::RakeTask.new do |t|
8
8
  # Put spec opts in a file named .rspec in root
9
- t.rcov = true
9
+ # t.rcov = true
10
10
  end
@@ -16,20 +16,23 @@ module EY
16
16
  @connection = Connection.new(opts[:auth_id], opts[:auth_key])
17
17
  end
18
18
 
19
+ def self.setup?
20
+ @connection
21
+ end
22
+
19
23
  def self.connection
20
24
  @connection or raise "Not setup!"
21
25
  end
22
26
 
23
- def self.enable_mock!(provider = nil)
27
+ def self.enable_mock!(service_provider, tresfiestas = nil, awsm = nil)
24
28
  unless @mock_backend
25
- unless provider
26
- require "ey_services_api/test/tresfiestas_fake"
27
- provider = TresfiestasFake
28
- end
29
- @mock_backend = provider.setup!
29
+ require "ey_services_fake/mock_backend"
30
+ @mock_backend = EyServicesFake::MockBackend.setup!(
31
+ :awsm => awsm,
32
+ :tresfiestas => tresfiestas,
33
+ :service_provider => service_provider)
30
34
  end
31
35
  @mock_backend.reset!
32
- @mock_backend.initialize_api_connection
33
36
  end
34
37
 
35
38
  def self.mock_backend
@@ -19,17 +19,6 @@ module EY
19
19
  class Environment < APIStruct.new(:id, :name, :framework_env)
20
20
  end
21
21
 
22
- # def environment
23
- # debugger
24
- # Environment.new(@environment)
25
- # end
26
-
27
- def creation_response_hash
28
- response_presenter = ProvisionedServiceResponse.new
29
- yield response_presenter
30
- response_presenter.to_hash
31
- end
32
-
33
22
  end
34
23
  end
35
24
  end
@@ -1,6 +1,6 @@
1
1
  module EY
2
2
  module ServicesAPI
3
- class ProvisionedServiceResponse < Struct.new(:configuration_required, :configuration_url, :message, :vars, :url)
3
+ class ProvisionedServiceResponse < APIStruct.new(:configuration_required, :configuration_url, :message, :vars, :url)
4
4
  def to_hash
5
5
  {
6
6
  :provisioned_service => {
@@ -7,12 +7,6 @@ module EY
7
7
  new(json)
8
8
  end
9
9
 
10
- def creation_response_hash
11
- response_presenter = ServiceAccountResponse.new
12
- yield response_presenter
13
- response_presenter.to_hash
14
- end
15
-
16
10
  end
17
11
  end
18
12
  end
@@ -1,6 +1,6 @@
1
1
  module EY
2
2
  module ServicesAPI
3
- class ServiceAccountResponse < Struct.new(:configuration_required, :configuration_url, :message, :provisioned_services_url, :url)
3
+ class ServiceAccountResponse < APIStruct.new(:configuration_required, :configuration_url, :message, :provisioned_services_url, :url)
4
4
  def to_hash
5
5
  {
6
6
  :service_account => {
@@ -1,5 +1,5 @@
1
1
  module EY
2
2
  module ServicesAPI
3
- VERSION = "0.0.5"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -2,39 +2,29 @@ require 'spec_helper'
2
2
  require 'sinatra'
3
3
 
4
4
  describe EY::ServicesAPI::ProvisionedServiceCreation do
5
- describe "with a service account" do
5
+
6
+ describe "with a service account created" do
6
7
  before do
7
- @service_account_hash = @tresfiestas.service_account
8
- @creation_request = @tresfiestas.provisioned_service_creation_request(@service_account_hash)
9
- @provisioned_service = EY::ServicesAPI::ProvisionedServiceCreation.from_request(@creation_request.to_json)
8
+ @service_account_hash = @tresfiestas.service_account[:pushed_service_account]
10
9
  end
11
10
 
12
- it "can handle a provisioned service creation request" do
13
- @provisioned_service.url.should eq @creation_request[:url]
14
- @provisioned_service.messages_url.should eq @creation_request[:messages_url]
15
- @provisioned_service.environment.id.should eq @creation_request[:environment][:id]
16
- @provisioned_service.environment.name.should eq @creation_request[:environment][:name]
17
- @provisioned_service.environment.framework_env.should eq @creation_request[:environment][:framework_env]
18
- @provisioned_service.app.id.should eq @creation_request[:app][:id]
19
- @provisioned_service.app.name.should eq @creation_request[:app][:name]
20
- end
11
+ describe "with a provisioned service" do
12
+ before do
13
+ @pushed_provisioned_service = @tresfiestas.provisioned_service[:pushed_provisioned_service]
14
+ end
21
15
 
22
- it "can produce a response body hash for provisioned service creation requests" do
23
- response_hash = @provisioned_service.creation_response_hash do |presenter|
24
- # presenter.provisioned_services_url = "some provision url"
25
- presenter.url = "some resource url"
26
- presenter.vars = {"SOME_ENV_VAR" => "value", "OTHER_VAR" => "blah"}
27
- presenter.configuration_required = true
28
- presenter.configuration_url = "some config url" #doesn't even have to be valid here!
29
- presenter.message = EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some messages")
16
+ it "should have been provisioned correctly" do
17
+ standard_response_params = @tresfiestas.actor(:service_provider).service_provisioned_params
18
+ @pushed_provisioned_service[:configuration_required].should eq standard_response_params[:configuration_required]
19
+ @pushed_provisioned_service[:configuration_url].should eq standard_response_params[:configuration_url]
20
+ @pushed_provisioned_service[:provisioned_services_url].should eq standard_response_params[:provisioned_services_url]
21
+ @pushed_provisioned_service[:url].should eq standard_response_params[:url]
22
+ status_message = @tresfiestas.latest_status_message
23
+ status_message.should_not be_nil
24
+ status_message[:subject].should eq "some provisioned service messages"
30
25
  end
31
-
32
- provisioned_service_response = response_hash[:provisioned_service]
33
- provisioned_service_response[:configuration_required].should be true
34
- provisioned_service_response[:configuration_url].should eq "some config url"
35
- provisioned_service_response[:vars].should eq({"SOME_ENV_VAR" => "value", "OTHER_VAR" => "blah"})
36
- provisioned_service_response[:url].should eq "some resource url"
37
- response_hash[:message].should eq({:message_type => 'status', :subject => "some messages", :body => nil})
26
+
27
+ #Note: updating a provisioned service is not possible!
38
28
  end
39
29
  end
40
30
 
@@ -2,55 +2,36 @@ require 'spec_helper'
2
2
  require 'sinatra'
3
3
 
4
4
  describe EY::ServicesAPI::ServiceAccountCreation do
5
- describe "with a service account" do
5
+
6
+ describe "with a service account created" do
6
7
  before do
7
- @service_account_hash = @tresfiestas.service_account
8
- @creation_request = @tresfiestas.service_account_creation_request(@service_account_hash)
9
- @service_account = EY::ServicesAPI::ServiceAccountCreation.from_request(@creation_request.to_json)
8
+ @service_account_hash = @tresfiestas.service_account[:pushed_service_account]
10
9
  end
11
10
 
12
- it "can handle a service account creation request" do
13
- @service_account.url.should eq @creation_request[:url]
14
- @service_account.messages_url.should eq @creation_request[:messages_url]
15
- @service_account.invoices_url.should eq @creation_request[:invoices_url]
16
- @service_account.name.should eq @creation_request[:name]
11
+ it "got the right attributes" do
12
+ standard_response_params = @tresfiestas.actor(:service_provider).service_account_creation_params
13
+ @service_account_hash[:configuration_required].should eq standard_response_params[:configuration_required]
14
+ @service_account_hash[:configuration_url].should eq standard_response_params[:configuration_url]
15
+ @service_account_hash[:provisioned_services_url].should eq standard_response_params[:provisioned_services_url]
16
+ @service_account_hash[:url].should eq standard_response_params[:url]
17
+ status_message = @tresfiestas.latest_status_message
18
+ status_message.should_not be_nil
19
+ status_message[:subject].should eq "some messages"
17
20
  end
18
21
 
19
- describe "with a pushed service account" do
22
+ describe "updating a service account" do
20
23
  before do
21
- @tresfiestas.pushed_service_account #make sure it's already pushed to the partner
24
+ @connection = EY::ServicesAPI.connection
25
+ service_account = @tresfiestas.service_account
26
+ @connection.update_service_account(service_account[:url], {:configuration_required => true, :configuration_url => "a different url"})
22
27
  end
23
28
 
24
- describe "updating a service account" do
25
- before do
26
- @connection = EY::ServicesAPI.connection
27
- @connection.update_service_account(@service_account.url, {:configuration_required => true, :configuration_url => "a different url"})
28
- end
29
-
30
- it "should work" do
31
- pushed_service = @tresfiestas.pushed_service_account
32
- pushed_service[:configuration_url].should eq "a different url"
33
- pushed_service[:configuration_required].should eq true
34
- end
29
+ it "works" do
30
+ pushed_service = @tresfiestas.service_account[:pushed_service_account]
31
+ pushed_service[:configuration_url].should eq "a different url"
32
+ pushed_service[:configuration_required].should eq true
35
33
  end
36
34
  end
37
35
 
38
- it "can produce a response body hash for service account creation requests" do
39
- response_hash = @service_account.creation_response_hash do |presenter|
40
- presenter.provisioned_services_url = "some provision url"
41
- presenter.url = "some resource url"
42
- presenter.configuration_required = true
43
- presenter.configuration_url = "some config url" #doesn't even have to be valid here!
44
- presenter.message = EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some messages")
45
- end
46
-
47
- service_account_response = response_hash[:service_account]
48
- service_account_response[:configuration_required].should be true
49
- service_account_response[:configuration_url].should eq "some config url"
50
- service_account_response[:provisioned_services_url].should eq "some provision url"
51
- service_account_response[:url].should eq "some resource url"
52
- response_hash[:message].should eq({:message_type => 'status', :subject => "some messages", :body => nil})
53
- end
54
36
  end
55
-
56
37
  end
@@ -2,20 +2,6 @@ require 'spec_helper'
2
2
  require 'sinatra'
3
3
 
4
4
  describe EY::ServicesAPI::Service do
5
- before do
6
- @valid_params = @tresfiestas.service_registration_params
7
- @service = EY::ServicesAPI::Service.new(@valid_params)
8
- end
9
-
10
- it "can be initialized with a hash" do
11
- @service.should be_a EY::ServicesAPI::Service
12
- @service.name.should eq @valid_params[:name]
13
- @service.description.should eq @valid_params[:description]
14
- @service.service_accounts_url.should eq @valid_params[:service_accounts_url]
15
- @service.home_url.should eq @valid_params[:home_url]
16
- @service.terms_and_conditions_url.should eq @valid_params[:terms_and_conditions_url]
17
- @service.vars.should eq @valid_params[:vars]
18
- end
19
5
 
20
6
  describe "#register_service" do
21
7
 
@@ -23,7 +9,7 @@ describe EY::ServicesAPI::Service do
23
9
  before do
24
10
  partner = @tresfiestas.partner
25
11
  @registration_url = partner[:registration_url]
26
- @registration_params = @tresfiestas.service_registration_params
12
+ @registration_params = @tresfiestas.actor(:service_provider).registration_params
27
13
  @connection = EY::ServicesAPI.connection
28
14
  end
29
15
 
@@ -51,7 +37,7 @@ describe EY::ServicesAPI::Service do
51
37
 
52
38
  it "can list services" do
53
39
  services = @connection.list_services(@registration_url)
54
- services.last.should eq @service
40
+ services.index(@service).should_not be_nil
55
41
  end
56
42
 
57
43
  it "can fetch your service" do
@@ -1,13 +1,17 @@
1
1
  require 'ey_services_api'
2
2
  require 'rspec'
3
+ require 'sinatra/base'
3
4
 
4
5
  RSpec.configure do |config|
5
6
  config.before(:each) do
6
- if ENV["BUNDLE_GEMFILE"] == "InternalGemfile"
7
+ if ENV["BUNDLE_GEMFILE"] == "EYIntegratedGemfile"
8
+ require 'ey_services_fake/mocking_bird_service'
7
9
  require 'tresfiestas/gem_integration_test'
8
- EY::ServicesAPI.enable_mock!(Tresfiestas::GemIntegrationTest)
10
+ require 'fake_awsm/test_helper'
11
+ EY::ServicesAPI.enable_mock!(EyServicesFake::MockingBirdService.new, Tresfiestas::GemIntegrationTest.new, FakeAWSM::TestHelper.new)
9
12
  else
10
- EY::ServicesAPI.enable_mock!
13
+ require 'ey_services_fake/mocking_bird_service'
14
+ EY::ServicesAPI.enable_mock!(EyServicesFake::MockingBirdService.new)
11
15
  end
12
16
  @tresfiestas = EY::ServicesAPI.mock_backend
13
17
  end
metadata CHANGED
@@ -1,80 +1,63 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ey_services_api
3
- version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 5
10
- version: 0.0.5
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
13
- - "Jacob Burkhart & Thorben Schr\xC3\xB6der & David Calavera & Michael Brodhead & Others"
7
+ authors:
8
+ - Jacob Burkhart & Thorben Schröder & David Calavera & Michael Brodhead & Others
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-09-25 00:00:00 -07:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-10-06 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2154007720 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :development
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: json
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2154007720
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &2156101880 !ruby/object:Gem::Requirement
39
28
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
47
33
  type: :runtime
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: ey_api_hmac
51
34
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2156101880
36
+ - !ruby/object:Gem::Dependency
37
+ name: ey_api_hmac
38
+ requirement: &2156101460 !ruby/object:Gem::Requirement
53
39
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
61
44
  type: :runtime
62
- version_requirements: *id003
45
+ prerelease: false
46
+ version_requirements: *2156101460
63
47
  description: API for Partner Services (talks to services.engineyard.com)
64
- email:
48
+ email:
65
49
  - jacob@engineyard.com
66
50
  executables: []
67
-
68
51
  extensions: []
69
-
70
52
  extra_rdoc_files: []
71
-
72
- files:
53
+ files:
73
54
  - .gitignore
74
55
  - .rspec
56
+ - CHANGELOG
57
+ - EYIntegratedGemfile
58
+ - EYIntegratedGemfile.lock
75
59
  - Gemfile
76
60
  - Guardfile
77
- - InternalGemfile
78
61
  - README.md
79
62
  - Rakefile
80
63
  - ey_services_api.gemspec
@@ -88,7 +71,6 @@ files:
88
71
  - lib/ey_services_api/service.rb
89
72
  - lib/ey_services_api/service_account_creation.rb
90
73
  - lib/ey_services_api/service_account_response.rb
91
- - lib/ey_services_api/test/tresfiestas_fake.rb
92
74
  - lib/ey_services_api/version.rb
93
75
  - spec/invoice_spec.rb
94
76
  - spec/message_spec.rb
@@ -96,41 +78,31 @@ files:
96
78
  - spec/service_account_creation_spec.rb
97
79
  - spec/service_spec.rb
98
80
  - spec/spec_helper.rb
99
- has_rdoc: true
100
- homepage: ""
81
+ homepage: ''
101
82
  licenses: []
102
-
103
83
  post_install_message:
104
84
  rdoc_options: []
105
-
106
- require_paths:
85
+ require_paths:
107
86
  - lib
108
- required_ruby_version: !ruby/object:Gem::Requirement
87
+ required_ruby_version: !ruby/object:Gem::Requirement
109
88
  none: false
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- hash: 3
114
- segments:
115
- - 0
116
- version: "0"
117
- required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
94
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- hash: 3
123
- segments:
124
- - 0
125
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
126
99
  requirements: []
127
-
128
100
  rubyforge_project: ey_services_api
129
- rubygems_version: 1.3.7
101
+ rubygems_version: 1.8.10
130
102
  signing_key:
131
103
  specification_version: 3
132
104
  summary: API for Partner Services (talks to services.engineyard.com)
133
- test_files:
105
+ test_files:
134
106
  - spec/invoice_spec.rb
135
107
  - spec/message_spec.rb
136
108
  - spec/provisioned_service_creation_spec.rb
@@ -1,288 +0,0 @@
1
- class TresfiestasFake
2
- BASE_URL = "http://mockservice.test"
3
-
4
- def self.setup!
5
- @mock_helper = MockHelper.new
6
- end
7
- def self.reset!
8
- @services = {}
9
- @invoices = []
10
- @status_messages = []
11
- @service_accounts = {}
12
- end
13
- def self.services
14
- @services ||= {}
15
- end
16
- def self.invoices
17
- @invoices ||= []
18
- end
19
- def self.service_accounts
20
- @service_accounts ||= {}
21
- end
22
- def self.status_messages
23
- @status_messages ||= []
24
- end
25
-
26
- def self.mock_helper
27
- MockHelper.new
28
- end
29
-
30
- class MockHelper
31
- def reset!
32
- TresfiestasFake.reset!
33
- end
34
- def initialize_api_connection
35
- EY::ServicesAPI.setup!(:auth_id => "123", :auth_key => "456")
36
- EY::ServicesAPI.connection.backend = TresfiestasFake::RackApp
37
- end
38
-
39
- def partner
40
- {
41
- :registration_url => "#{BASE_URL}/api/1/register_a_new_service",
42
- :auth_id => "123",
43
- :auth_key => "456",
44
- }
45
- end
46
-
47
- #TODO: make an equivalent in tresfiestas!
48
- def connection_to_partner
49
- @connection_to_partner ||= EY::ApiHMAC::BaseConnection.new(partner[:auth_id], partner[:auth_key])
50
- end
51
-
52
- def service_registration_params
53
- {
54
- :name => "Mocking Bird",
55
- :description => "a mock service",
56
- :service_accounts_url => "#{BASE_URL}/api/1/customers/regular",
57
- :home_url => "#{BASE_URL}/",
58
- :terms_and_conditions_url => "#{BASE_URL}/terms",
59
- :vars => [
60
- "MOCK_API_KEY"
61
- ]
62
- }
63
- end
64
-
65
- def service_account
66
- {:invoices_url => "#{BASE_URL}/api/1/invoices/12",
67
- :messages_url => "#{BASE_URL}/api/1/messages/12",
68
- :url => "#{BASE_URL}/api/1/serviceaccounts/12",
69
- :id => 12}
70
- end
71
-
72
- def pushed_service_account
73
- pushed = TresfiestasFake.service_accounts[12] || {}
74
- service_account.merge({
75
- :provisioned_services_url => pushed['provisioned_services_url'],
76
- :configuration_url => pushed['configuration_url'],
77
- :url => pushed['url'],
78
- :configuration_required => pushed['configuration_required'],
79
- })
80
- end
81
-
82
- #TODO: test this!, put in tresfiestas too!
83
- def create_service_account
84
- service = TresfiestasFake.services.values.first
85
- service_accounts_url = service['service_accounts_url']
86
- post_params = {
87
- :name => "my-account",
88
- # :url => "TODO url",
89
- :messages_url => "#{BASE_URL}/api/1/messages/???service_account_id???",
90
- :invoices_url => "#{BASE_URL}/api/1/invoices/???service_account_id???",
91
- }
92
- connection_to_partner.post(service_accounts_url, post_params) do |json_body, location|
93
- service["service_accounts"] ||= {}
94
- service["service_accounts"][location] = json_body
95
- end
96
- end
97
- #TODO: test this!, put in tresfiestas too!
98
- def destroy_service_account
99
- service = TresfiestasFake.services.values.first
100
- service_account_url = service["service_accounts"].keys.first
101
- connection_to_partner.delete(service_account_url)
102
- end
103
- #TODO: test this!, put in tresfiestas too!
104
- def create_provisioned_service
105
- service = TresfiestasFake.services.values.first
106
- service_account = service["service_accounts"].values.first["service_account"]
107
- provisioned_services_url = service_account["provisioned_services_url"]
108
- post_params = {
109
- # :url => "TODO: url",
110
- :messages_url => "#{BASE_URL}/api/1/provisioned_service_messages/???provisioned_service_id???",
111
- :environment => {:id => 5, :name => 'myenv'},
112
- :app => {:id => 6, :name => "myapp"},
113
- }
114
- connection_to_partner.post(provisioned_services_url, post_params) do |json_body, location|
115
- service_account["provisioned_services"] ||= {}
116
- service_account["provisioned_services"][location] = json_body
117
- end
118
- end
119
- #TODO: test this!, put in tresfiestas too!
120
- def destroy_provisioned_service
121
- service = TresfiestasFake.services.values.first
122
- service_account = service["service_accounts"].values.first["service_account"]
123
- provisioned_service_url = service_account["provisioned_services"].keys.first
124
- connection_to_partner.delete(provisioned_service_url)
125
- end
126
- #TODO: tests this, put in tresfiestas too???!
127
- def created_provisioned_service
128
- service = TresfiestasFake.services.values.first
129
- service_account = service["service_accounts"].values.first["service_account"]
130
- service_account["provisioned_services"].values.first["provisioned_service"]
131
- end
132
-
133
- def service_account_creation_request(service_account_hash)
134
- {
135
- :url => service_account_hash[:url],
136
- :name => service_account_hash[:name],
137
- :messages_url => service_account_hash[:messages_url],
138
- :invoices_url => service_account_hash[:invoices_url]
139
- }
140
- end
141
-
142
- def provisioned_service_creation_request(service_account_hash)
143
- {:environment => {}, :app => {}}
144
- end
145
-
146
- def latest_invoice
147
- invoice = TresfiestasFake.invoices.last
148
- {
149
- :total_amount_cents => invoice['total_amount_cents'],
150
- :line_item_description => invoice['line_item_description'],
151
- :service_account_id => invoice['service_account_id'],
152
- }
153
- end
154
-
155
- def latest_status_message
156
- message = TresfiestasFake.status_messages.last
157
- to_return = {
158
- :subject => message["subject"],
159
- :body => message["body"],
160
- }
161
- if message['provisioned_service_id']
162
- to_return.merge!(:provisioned_service_id => message['provisioned_service_id'])
163
- end
164
- to_return
165
- end
166
-
167
- def provisioned_service
168
- {:messages_url => "#{BASE_URL}/api/1/provisioned_service_messages/64",
169
- :id => 64}
170
- end
171
- end
172
-
173
- class RackApp < Sinatra::Base
174
- enable :raise_errors
175
- disable :dump_errors
176
- disable :show_exceptions
177
-
178
- get '/api/1/register_a_new_service' do
179
- to_return = []
180
- TresfiestasFake.services.each do |k, v|
181
- to_return << {"service" => v.merge('url' => "#{BASE_URL}/api/1/services/#{k}") }
182
- end
183
- to_return.to_json
184
- end
185
-
186
- #TODO: auth!
187
- post '/api/1/register_a_new_service' do
188
- service_id = TresfiestasFake.services.size + 100
189
- service = JSON.parse(request.body.read)["service"]
190
- if service["name"].to_s.empty?
191
- status 400
192
- {:error_messages => ["Name can't be blank"]}.to_json
193
- else
194
- TresfiestasFake.services[service_id.to_s] = service
195
- status 201
196
- headers 'Location' => "#{BASE_URL}/api/1/services/#{service_id}"
197
- {}.to_json
198
- end
199
- end
200
-
201
- get '/api/1/services/:service_id' do |service_id|
202
- if service = TresfiestasFake.services[service_id.to_s]
203
- {"service" => service}.to_json
204
- else
205
- status 404
206
- {}.to_json
207
- end
208
- end
209
-
210
- put '/api/1/services/:service_id' do |service_id|
211
- service = TresfiestasFake.services[service_id.to_s]
212
- update_params = JSON.parse(request.body.read)["service"]
213
- if update_params.key?("name") && update_params["name"].to_s.empty?
214
- status 400
215
- {:error_messages => ["Name can't be blank"]}.to_json
216
- else
217
- service.merge!(update_params)
218
- {}.to_json
219
- end
220
- end
221
-
222
- delete '/api/1/services/:service_id' do |service_id|
223
- TresfiestasFake.services.delete(service_id.to_s)
224
- {}.to_json
225
- end
226
-
227
- put '/api/1/serviceaccounts/12' do
228
- TresfiestasFake.service_accounts ||= {}
229
- TresfiestasFake.service_accounts[12] = JSON.parse(request.body.read)["service_account"]
230
- {}.to_json
231
- end
232
-
233
- post '/api/1/invoices/:service_account_id' do |service_account_id|
234
- invoice_params = JSON.parse(request.body.read)["invoice"]
235
- unless invoice_params['total_amount_cents'].is_a?(Fixnum)
236
- status 400
237
- return {:error_messages => ["Total Amount Cents must be an integer"]}.to_json
238
- end
239
- if invoice_params["line_item_description"].to_s.empty?
240
- status 400
241
- return {:error_messages => ["Line item description can't be blank"]}.to_json
242
- end
243
- if invoice_params['total_amount_cents'] < 0
244
- status 400
245
- return {:error_messages => ["Total amount cents must be greater than or equal to 0"]}.to_json
246
- end
247
- TresfiestasFake.invoices << invoice_params.merge('service_account_id' => service_account_id.to_i)
248
- {}.to_json
249
- end
250
-
251
- post '/api/1/messages/:service_account_id' do |service_account_id|
252
- message_params = JSON.parse(request.body.read)["message"]
253
-
254
- if message_params['subject'].to_s.empty?
255
- status 400
256
- return {:error_messages => ["Subject can't be blank."]}.to_json
257
- end
258
-
259
- unless ['status', 'notification', 'alert'].include? message_params['message_type']
260
- status 400
261
- return {:error_messages => ['Message type must be one of: status, notification or alert']}.to_json
262
- end
263
-
264
- TresfiestasFake.status_messages << message_params
265
- {}.to_json
266
- end
267
-
268
-
269
- post '/api/1/provisioned_service_messages/:provisioned_service_id' do |provisioned_service_id|
270
- message_params = JSON.parse(request.body.read)["message"]
271
-
272
- if message_params['subject'].to_s.empty?
273
- status 400
274
- return {:error_messages => ["Subject can't be blank."]}.to_json
275
- end
276
-
277
- unless ['status', 'notification', 'alert'].include? message_params['message_type']
278
- status 400
279
- return {:error_messages => ['Message type must be one of: status, notification or alert']}.to_json
280
- end
281
-
282
- TresfiestasFake.status_messages << message_params.merge('provisioned_service_id' => provisioned_service_id.to_i)
283
- {}.to_json
284
- end
285
-
286
- end
287
-
288
- end