ey_services_fake 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,27 +16,35 @@ module EyServicesFake
16
16
  end
17
17
 
18
18
  post '/api/1/service_accounts_callback' do
19
- service_account = EY::ServicesAPI::ServiceAccountCreation.from_request(request.body.read)
20
- standard_response_params = MockingBirdService.service_account_creation_params
21
- EY::ServicesAPI::ServiceAccountResponse.new(
22
- :provisioned_services_url => standard_response_params[:provisioned_services_url],
23
- :url => standard_response_params[:url],
24
- :configuration_url => standard_response_params[:configuration_url],
25
- :configuration_required => standard_response_params[:configuration_required],
26
- :message => EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some messages")
27
- ).to_hash.to_json
19
+ if MockingBirdService.service_account_creation_handler
20
+ instance_eval(&MockingBirdService.service_account_creation_handler)
21
+ else
22
+ service_account = EY::ServicesAPI::ServiceAccountCreation.from_request(request.body.read)
23
+ standard_response_params = MockingBirdService.service_account_creation_params
24
+ EY::ServicesAPI::ServiceAccountResponse.new(
25
+ :provisioned_services_url => standard_response_params[:provisioned_services_url],
26
+ :url => standard_response_params[:url],
27
+ :configuration_url => standard_response_params[:configuration_url],
28
+ :configuration_required => standard_response_params[:configuration_required],
29
+ :message => EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some messages")
30
+ ).to_hash.to_json
31
+ end
28
32
  end
29
33
 
30
34
  post '/api/1/provisioned_services_callback' do
31
- provisioned_service = EY::ServicesAPI::ProvisionedServiceCreation.from_request(request.body.read)
32
- standard_response_params = MockingBirdService.service_provisioned_params
33
- EY::ServicesAPI::ProvisionedServiceResponse.new(
34
- :url => standard_response_params[:url],
35
- :vars => standard_response_params[:vars],
36
- :configuration_required => false,
37
- :configuration_url => standard_response_params[:configuration_url],
38
- :message => EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some provisioned service messages")
39
- ).to_hash.to_json
35
+ if MockingBirdService.service_provisioning_handler
36
+ instance_eval(&MockingBirdService.service_provisioning_handler)
37
+ else
38
+ provisioned_service = EY::ServicesAPI::ProvisionedServiceCreation.from_request(request.body.read)
39
+ standard_response_params = MockingBirdService.service_provisioned_params
40
+ EY::ServicesAPI::ProvisionedServiceResponse.new(
41
+ :url => standard_response_params[:url],
42
+ :vars => standard_response_params[:vars],
43
+ :configuration_required => false,
44
+ :configuration_url => standard_response_params[:configuration_url],
45
+ :message => EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some provisioned service messages")
46
+ ).to_hash.to_json
47
+ end
40
48
  end
41
49
 
42
50
  get '/sso/some_service_account' do
@@ -48,8 +56,14 @@ module EyServicesFake
48
56
  end
49
57
  end
50
58
 
59
+ class << self
60
+ attr_accessor :service_account_creation_handler
61
+ attr_accessor :service_provisioning_handler
62
+ end
63
+
51
64
  def reset!
52
- #no-op
65
+ MockingBirdService.service_account_creation_handler = nil
66
+ MockingBirdService.service_provisioning_handler = nil
53
67
  end
54
68
 
55
69
  def app
@@ -66,17 +66,20 @@ module EyServicesFake
66
66
  app_deployment && {
67
67
  :id => app_deployment.id,
68
68
  :app => {
69
+ :id => app_deployment.app.id,
69
70
  :name => app_deployment.app.name,
70
71
  },
71
72
  :environment => {
73
+ :id => app_deployment.environment.id,
72
74
  :name => app_deployment.environment.name,
73
75
  :framework_env => app_deployment.environment.framework_env,
76
+ :aws_region => app_deployment.environment.aws_region
74
77
  }
75
78
  }
76
79
  end
77
80
  def create_app_deployment(sso_account_id, app_name, env_name, framework_env)
78
81
  app = App.create(:name => app_name)
79
- env = Environment.create(:name => env_name, :framework_env => framework_env)
82
+ env = Environment.create(:name => env_name, :framework_env => framework_env, :aws_region => 'us-east-1')
80
83
  AppDeployment.create(:account_id => sso_account_id, :app_id => app.id, :environment_id => env.id)
81
84
  end
82
85
 
@@ -96,10 +99,12 @@ module EyServicesFake
96
99
  }
97
100
  @connection.post(service.service_accounts_url, creation_attributes) do |result, location|
98
101
  service_account.active = true
99
- service_account.provisioned_services_url = result["service_account"]['provisioned_services_url']
100
- service_account.configuration_url = result["service_account"]['configuration_url']
101
- service_account.url = result["service_account"]['url']
102
- service_account.configuration_required = result["service_account"]['configuration_required']
102
+ if result["service_account"]
103
+ service_account.provisioned_services_url = result["service_account"]['provisioned_services_url']
104
+ service_account.configuration_url = result["service_account"]['configuration_url']
105
+ service_account.url = result["service_account"]['url']
106
+ service_account.configuration_required = result["service_account"]['configuration_required']
107
+ end
103
108
  if result["message"] && result["message"]["message_type"]
104
109
  Message.create(
105
110
  :service_account_id => service_account.id,
@@ -127,20 +132,22 @@ module EyServicesFake
127
132
  :url => url_gen.partner_provisioned_service(service_account_object, provisioned_service),
128
133
  :messages_url => url_gen.messages(service_account_object.service, service_account_object, provisioned_service),
129
134
  :app => {:id => app.id, :name => app.name},
130
- :environment => {:id => environment.id, :name => environment.name, :framework_env => environment.framework_env},
135
+ :environment => {:id => environment.id, :name => environment.name, :framework_env => environment.framework_env, :aws_region => environment.aws_region},
131
136
  }
132
137
  @connection.post(service_account_object.provisioned_services_url, provision_attribtues) do |result, location|
133
138
  provisioned_service.active = true
134
- provisioned_service.vars = result['provisioned_service']["vars"]
135
- provisioned_service.configuration_url = result['provisioned_service']["configuration_url"]
136
- provisioned_service.configuration_required = result['provisioned_service']["configuration_required"]
137
- provisioned_service.url = result['provisioned_service']["url"]
138
- if result["message"] && result["message"]["message_type"]
139
- Message.create(
140
- :provisioned_service_id => provisioned_service.id,
141
- :message_type => result["message"]["message_type"],
142
- :subject => result["message"]["subject"],
143
- :body => result["message"]["body"])
139
+ if result['provisioned_service']
140
+ provisioned_service.vars = result['provisioned_service']["vars"]
141
+ provisioned_service.configuration_url = result['provisioned_service']["configuration_url"]
142
+ provisioned_service.configuration_required = result['provisioned_service']["configuration_required"]
143
+ provisioned_service.url = result['provisioned_service']["url"]
144
+ if result["message"] && result["message"]["message_type"]
145
+ Message.create(
146
+ :provisioned_service_id => provisioned_service.id,
147
+ :message_type => result["message"]["message_type"],
148
+ :subject => result["message"]["subject"],
149
+ :body => result["message"]["body"])
150
+ end
144
151
  end
145
152
  provisioned_service.save
146
153
  end
@@ -1,3 +1,3 @@
1
1
  module EyServicesFake
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,45 +1,62 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ey_services_fake
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.6
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Jacob Burkhart & Josh Lane
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-11-21 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2011-11-27 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: sinatra
16
- requirement: &70192357090200 !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
17
24
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
22
32
  type: :runtime
23
- prerelease: false
24
- version_requirements: *70192357090200
25
- - !ruby/object:Gem::Dependency
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
26
35
  name: cubbyhole
27
- requirement: &70192357089540 !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
28
38
  none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 23
43
+ segments:
44
+ - 0
45
+ - 2
46
+ - 0
32
47
  version: 0.2.0
33
48
  type: :runtime
34
- prerelease: false
35
- version_requirements: *70192357089540
49
+ version_requirements: *id002
36
50
  description: A fake for use when writting tests against the ey_services_api
37
- email:
51
+ email:
38
52
  - jacob@engineyard.com
39
53
  executables: []
54
+
40
55
  extensions: []
56
+
41
57
  extra_rdoc_files: []
42
- files:
58
+
59
+ files:
43
60
  - .gitignore
44
61
  - ey_services_fake.gemspec
45
62
  - lib/ey_services_fake/mock_backend.rb
@@ -50,28 +67,38 @@ files:
50
67
  - lib/ey_services_fake/tresfiestas_fake_rack_app.rb
51
68
  - lib/ey_services_fake/url_generator.rb
52
69
  - lib/ey_services_fake/version.rb
53
- homepage: ''
70
+ homepage: ""
54
71
  licenses: []
72
+
55
73
  post_install_message:
56
74
  rdoc_options: []
57
- require_paths:
75
+
76
+ require_paths:
58
77
  - lib
59
- required_ruby_version: !ruby/object:Gem::Requirement
78
+ required_ruby_version: !ruby/object:Gem::Requirement
60
79
  none: false
61
- requirements:
62
- - - ! '>='
63
- - !ruby/object:Gem::Version
64
- version: '0'
65
- required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
88
  none: false
67
- requirements:
68
- - - ! '>='
69
- - !ruby/object:Gem::Version
70
- version: '0'
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
71
96
  requirements: []
97
+
72
98
  rubyforge_project: ey_services_fake
73
99
  rubygems_version: 1.8.10
74
100
  signing_key:
75
101
  specification_version: 3
76
102
  summary: A fake for use when writting tests against the ey_services_api
77
103
  test_files: []
104
+