ey_services_fake 0.3.11 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
@@ -67,6 +67,8 @@ module EyServicesFake
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def reset!
|
70
|
+
@app = nil
|
71
|
+
@apps = nil
|
70
72
|
@actors.values.each do |v|
|
71
73
|
v.reset!
|
72
74
|
end
|
@@ -126,6 +128,7 @@ module EyServicesFake
|
|
126
128
|
def service_enablement
|
127
129
|
sso_account_hash = self.sso_account
|
128
130
|
service_hash = self.service
|
131
|
+
|
129
132
|
unless actor(:tresfiestas).service_available_for_account?(service_hash[:id], sso_account_hash[:id])
|
130
133
|
actor(:tresfiestas).make_service_available_for_account(service_hash[:id], sso_account_hash[:id])
|
131
134
|
end
|
@@ -193,18 +196,19 @@ module EyServicesFake
|
|
193
196
|
end
|
194
197
|
|
195
198
|
def service_account_sso_url
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
199
|
+
actor(:awsm).service_account_sso_url(service[:id], sso_user, sso_account[:id])
|
200
|
+
end
|
201
|
+
|
202
|
+
def provisioned_service_sso_url
|
203
|
+
actor(:awsm).provisioned_service_sso_url(service_account[:id], app_deployment[:id], sso_user, sso_account[:id])
|
204
|
+
end
|
205
|
+
|
206
|
+
def trigger_mock_user_update(new_email)
|
207
|
+
actor(:tresfiestas).trigger_mock_user_update(sso_user, new_email)
|
208
|
+
end
|
209
|
+
|
210
|
+
def trigger_mock_user_delete
|
211
|
+
actor(:tresfiestas).trigger_mock_user_delete(sso_user)
|
208
212
|
end
|
209
213
|
|
210
214
|
end
|
@@ -40,8 +40,8 @@ module EyServicesFake
|
|
40
40
|
instance_eval(&parent.service_account_creation_handler)
|
41
41
|
else
|
42
42
|
service_account = EY::ServicesAPI::ServiceAccountCreation.from_request(request.body.read)
|
43
|
-
|
44
|
-
EY::ServicesAPI::ServiceAccountResponse.new(
|
43
|
+
response_params = parent.service_account_creation_params
|
44
|
+
EY::ServicesAPI::ServiceAccountResponse.new(response_params).to_hash.to_json
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -57,6 +57,7 @@ module EyServicesFake
|
|
57
57
|
end
|
58
58
|
|
59
59
|
get '/sso/some_service_account' do
|
60
|
+
parent.account_sso_hook(params)
|
60
61
|
"SSO Hello Service Account"
|
61
62
|
end
|
62
63
|
|
@@ -129,7 +130,7 @@ module EyServicesFake
|
|
129
130
|
:url => "#{base_url}api/1/some_service_account",
|
130
131
|
:configuration_url => "#{base_url}sso/some_service_account",
|
131
132
|
:configuration_required => false,
|
132
|
-
:message => EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some messages")
|
133
|
+
:message => EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some messages"),
|
133
134
|
}
|
134
135
|
end
|
135
136
|
|
@@ -146,6 +147,10 @@ module EyServicesFake
|
|
146
147
|
}
|
147
148
|
end
|
148
149
|
|
150
|
+
def self.account_sso_hook(params)
|
151
|
+
#no-op
|
152
|
+
end
|
153
|
+
|
149
154
|
def register_service(registration_url)
|
150
155
|
EY::ServicesAPI.connection.register_service(registration_url, self.class.registration_params)
|
151
156
|
end
|
@@ -50,7 +50,7 @@ module EyServicesFake
|
|
50
50
|
|
51
51
|
def sso_user
|
52
52
|
the_one_email = "the-one-user@example.com"
|
53
|
-
User.first(:email => the_one_email) || User.create(:email => the_one_email)
|
53
|
+
User.first(:email => the_one_email) || User.create(:email => the_one_email, :external_service_id => Object.new.object_id)
|
54
54
|
end
|
55
55
|
|
56
56
|
def find_sso_account(sso_user)
|
@@ -108,6 +108,7 @@ module EyServicesFake
|
|
108
108
|
service_account.configuration_url = result["service_account"]['configuration_url']
|
109
109
|
service_account.url = result["service_account"]['url']
|
110
110
|
service_account.configuration_required = result["service_account"]['configuration_required']
|
111
|
+
service_account.users_url = result["service_account"]['users_url']
|
111
112
|
end
|
112
113
|
if result["message"] && result["message"]["message_type"]
|
113
114
|
Message.create(
|
@@ -162,5 +163,27 @@ module EyServicesFake
|
|
162
163
|
@connection.delete(provisioned_service.url)
|
163
164
|
end
|
164
165
|
|
166
|
+
def service_account_sso_url(service_id, sso_user, sso_account_id)
|
167
|
+
service_account = ServiceAccount.first(
|
168
|
+
:sso_account_id => sso_account_id, :service_id => service_id)
|
169
|
+
partner = service_account.service.partner
|
170
|
+
configuration_url = service_account.configuration_url
|
171
|
+
params = {
|
172
|
+
'timestamp' => Time.now.iso8601,
|
173
|
+
'ey_user_id' => sso_user.external_service_id,
|
174
|
+
'ey_user_name' => "Person Name",
|
175
|
+
'ey_return_to_url' => "https://cloud.engineyard.com/dashboard",
|
176
|
+
'access_level' => 'owner',
|
177
|
+
}
|
178
|
+
if service_account.users_url
|
179
|
+
params['ey_user_email'] = sso_user.email
|
180
|
+
end
|
181
|
+
require 'cgi'
|
182
|
+
EY::ApiHMAC::SSO.sign(configuration_url,
|
183
|
+
params,
|
184
|
+
partner.auth_id,
|
185
|
+
partner.auth_key)
|
186
|
+
end
|
187
|
+
|
165
188
|
end
|
166
189
|
end
|
@@ -64,7 +64,7 @@ module EyServicesFake
|
|
64
64
|
:home_url => service_object.home_url,
|
65
65
|
:label => service_object.label,
|
66
66
|
:revenue_share => service_object.revenue_share,
|
67
|
-
:service_accounts_url => service_object.service_accounts_url
|
67
|
+
:service_accounts_url => service_object.service_accounts_url,
|
68
68
|
}
|
69
69
|
end
|
70
70
|
|
@@ -88,6 +88,7 @@ module EyServicesFake
|
|
88
88
|
:provisioned_services_url => service_account_object.provisioned_services_url,
|
89
89
|
:configuration_url => service_account_object.configuration_url,
|
90
90
|
:url => service_account_object.url,
|
91
|
+
:users_url => service_account_object.users_url,
|
91
92
|
:configuration_required => service_account_object.configuration_required,
|
92
93
|
}
|
93
94
|
}
|
@@ -135,5 +136,33 @@ module EyServicesFake
|
|
135
136
|
end
|
136
137
|
end
|
137
138
|
|
139
|
+
def trigger_mock_user_update(sso_user, new_email)
|
140
|
+
sso_user.accounts.each do |account|
|
141
|
+
ServiceAccount.all(:sso_account_id => account.id).each do |service_account|
|
142
|
+
if service_account.users_url
|
143
|
+
users = app.partner_connection.get(service_account.users_url){|json,_| json }
|
144
|
+
users.each do |user|
|
145
|
+
unless user["user"]["ey_user_email"] == new_email
|
146
|
+
app.partner_connection.put(user["url"], :user => {:ey_user_email => new_email})
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def trigger_mock_user_delete(sso_user)
|
155
|
+
sso_user.accounts.each do |account|
|
156
|
+
ServiceAccount.all(:sso_account_id => account.id).each do |service_account|
|
157
|
+
if service_account.users_url
|
158
|
+
users = app.partner_connection.get(service_account.users_url){|json,_| json }
|
159
|
+
users.each do |user|
|
160
|
+
app.partner_connection.delete(user["url"])
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
138
167
|
end
|
139
168
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ey_services_fake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 12
|
10
|
+
version: 0.3.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jacob Burkhart & Josh Lane
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-05-
|
18
|
+
date: 2012-05-08 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: sinatra
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
requirements: []
|
110
110
|
|
111
111
|
rubyforge_project: ey_services_fake
|
112
|
-
rubygems_version: 1.8.
|
112
|
+
rubygems_version: 1.8.10
|
113
113
|
signing_key:
|
114
114
|
specification_version: 3
|
115
115
|
summary: A fake for use when writting tests against the ey_services_api
|