ey_services_api 0.3.11 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- data/EYIntegratedGemfile +4 -0
- data/Gemfile +1 -0
- data/lib/ey_services_api/service_account_response.rb +3 -2
- data/lib/ey_services_api/version.rb +1 -1
- data/spec/invoice_spec.rb +0 -1
- data/spec/message_spec.rb +0 -1
- data/spec/provisioned_service_creation_spec.rb +0 -1
- data/spec/service_account_creation_spec.rb +0 -1
- data/spec/users_spec.rb +116 -0
- metadata +7 -5
data/EYIntegratedGemfile
CHANGED
@@ -10,10 +10,14 @@ group :test, :development do
|
|
10
10
|
#private Gem deps of fake_awsm
|
11
11
|
gem 'ey_sso', :git => "git@github.com:engineyard/ey_sso.git"
|
12
12
|
gem 'ey_services_api_internal', :git => "git@github.com:engineyard/ey_services_api_internal.git"
|
13
|
+
# gem 'ey_services_api_internal', :path => "../ey_services_api_internal"
|
13
14
|
|
14
15
|
#"reals"
|
15
16
|
gem 'tresfiestas', :git => "git@github.com:engineyard/tresfiestas.git"
|
17
|
+
# gem 'tresfiestas', :path => "../tresfiestas"
|
16
18
|
gem 'fake_awsm', :git => "git@github.com:engineyard/fake_awsm.git"
|
19
|
+
# gem 'fake_awsm', :path => "../fake_awsm"
|
17
20
|
|
18
21
|
gem 'guard-rspec'
|
22
|
+
gem 'pry'
|
19
23
|
end
|
data/Gemfile
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
module EY
|
2
2
|
module ServicesAPI
|
3
|
-
class ServiceAccountResponse < APIStruct.new(:configuration_required, :configuration_url, :message, :provisioned_services_url, :url)
|
3
|
+
class ServiceAccountResponse < APIStruct.new(:configuration_required, :configuration_url, :message, :provisioned_services_url, :users_url, :url)
|
4
4
|
def to_hash
|
5
5
|
{
|
6
6
|
:service_account => {
|
7
7
|
:url => self.url,
|
8
8
|
:configuration_required => self.configuration_required,
|
9
9
|
:configuration_url => self.configuration_url,
|
10
|
-
:provisioned_services_url => self.provisioned_services_url
|
10
|
+
:provisioned_services_url => self.provisioned_services_url,
|
11
|
+
:users_url => self.users_url,
|
11
12
|
},
|
12
13
|
:message => self.message && self.message.to_hash
|
13
14
|
}
|
data/spec/invoice_spec.rb
CHANGED
data/spec/message_spec.rb
CHANGED
data/spec/users_spec.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
#because there may be multiple 'spec_helper' in load path when running from external test helper
|
2
|
+
require File.expand_path('../spec_helper.rb', __FILE__)
|
3
|
+
|
4
|
+
require 'ey_services_fake/mocking_bird_service'
|
5
|
+
class UserHavingService < EyServicesFake::MockingBirdService
|
6
|
+
def self.record_of_users
|
7
|
+
@record_of_users ||= {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.implement_the_app(app)
|
11
|
+
super(app)
|
12
|
+
app.class_eval do
|
13
|
+
get "/api/1/users" do
|
14
|
+
content_type :json
|
15
|
+
parent.record_of_users.map do |user_id, user|
|
16
|
+
{
|
17
|
+
"user" => user,
|
18
|
+
"url" => "#{parent.base_url}api/1/users/#{user_id}"
|
19
|
+
}
|
20
|
+
end.to_json
|
21
|
+
end
|
22
|
+
put "/api/1/users/:ey_user_id" do |ey_user_id|
|
23
|
+
content_type :json
|
24
|
+
json_post_body = JSON.parse(request.body.read)
|
25
|
+
parent.record_of_users[ey_user_id].merge! json_post_body['user']
|
26
|
+
{}.to_json
|
27
|
+
end
|
28
|
+
delete "/api/1/users/:ey_user_id" do |ey_user_id|
|
29
|
+
content_type :json
|
30
|
+
parent.record_of_users.delete(ey_user_id)
|
31
|
+
{}.to_json
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.account_sso_hook(params)
|
37
|
+
@record_of_users[params["ey_user_id"]] = {
|
38
|
+
'access_level' => params["access_level"],
|
39
|
+
'ey_user_id' => params["ey_user_id"],
|
40
|
+
'ey_user_email' => params["ey_user_email"],
|
41
|
+
'ey_user_name' => params["ey_user_name"],
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.service_account_creation_params
|
46
|
+
super.merge(:users_url => "#{base_url}api/1/users")
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "users" do
|
52
|
+
describe "with a service account" do
|
53
|
+
before do
|
54
|
+
UserHavingService.record_of_users.clear
|
55
|
+
@tresfiestas.actors[:service_provider] = UserHavingService.new
|
56
|
+
@service_account = @tresfiestas.service_account
|
57
|
+
@messages_url = @service_account[:messages_url]
|
58
|
+
@connection = EY::ServicesAPI.connection
|
59
|
+
@connection_to_partner_service = EY::ApiHMAC::BaseConnection.new
|
60
|
+
@connection_to_partner_service.backend = @tresfiestas.app_for(:service_provider)
|
61
|
+
@original_email = @tresfiestas.sso_user.email
|
62
|
+
@ey_user_id = @tresfiestas.sso_user.external_service_id.to_s
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "if the service doesn't provide a users_url, when a user SSOs to the service" do
|
66
|
+
before do
|
67
|
+
UserHavingService.record_of_users.should be_empty
|
68
|
+
@connection.update_service_account(@service_account[:url], :users_url => nil)
|
69
|
+
response = @connection_to_partner_service.get(@tresfiestas.service_account_sso_url)
|
70
|
+
response.status.should eq 200
|
71
|
+
UserHavingService.record_of_users.size.should eq 1
|
72
|
+
end
|
73
|
+
|
74
|
+
it "doesn't send the email" do
|
75
|
+
UserHavingService.record_of_users[@ey_user_id]['ey_user_email'].should be_nil
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "when a user SSOs to the service" do
|
80
|
+
before do
|
81
|
+
UserHavingService.record_of_users.should be_empty
|
82
|
+
response = @connection_to_partner_service.get(@tresfiestas.service_account_sso_url)
|
83
|
+
response.status.should eq 200
|
84
|
+
UserHavingService.record_of_users.size.should eq 1
|
85
|
+
end
|
86
|
+
|
87
|
+
it "saves the e-mail" do
|
88
|
+
UserHavingService.record_of_users[@ey_user_id]['ey_user_email'].should eq @original_email
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "when a user's e-mail changes" do
|
92
|
+
before do
|
93
|
+
@new_email = "new_email@example.com"
|
94
|
+
@tresfiestas.trigger_mock_user_update(@new_email)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "updates the saved value" do
|
98
|
+
@new_email.should_not eq @original_email
|
99
|
+
UserHavingService.record_of_users[@ey_user_id]['ey_user_email'].should eq @new_email
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "when a user is removed" do
|
104
|
+
before do
|
105
|
+
@tresfiestas.trigger_mock_user_delete
|
106
|
+
end
|
107
|
+
|
108
|
+
it "updates the saved value" do
|
109
|
+
UserHavingService.record_of_users.size.should eq 0
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ey_services_api
|
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 & Thorben & David & mkb & Josh & Others
|
@@ -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: rspec
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- spec/service_account_creation_spec.rb
|
102
102
|
- spec/service_spec.rb
|
103
103
|
- spec/spec_helper.rb
|
104
|
+
- spec/users_spec.rb
|
104
105
|
homepage: https://github.com/engineyard/ey_services_api
|
105
106
|
licenses: []
|
106
107
|
|
@@ -130,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
131
|
requirements: []
|
131
132
|
|
132
133
|
rubyforge_project: ey_services_api
|
133
|
-
rubygems_version: 1.8.
|
134
|
+
rubygems_version: 1.8.10
|
134
135
|
signing_key:
|
135
136
|
specification_version: 3
|
136
137
|
summary: API for Partner Services (talks to services.engineyard.com)
|
@@ -141,3 +142,4 @@ test_files:
|
|
141
142
|
- spec/service_account_creation_spec.rb
|
142
143
|
- spec/service_spec.rb
|
143
144
|
- spec/spec_helper.rb
|
145
|
+
- spec/users_spec.rb
|