ey_services_api 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ey_services_api/provisioned_service_creation.rb +1 -1
- data/lib/ey_services_api/provisioned_service_response.rb +3 -1
- data/lib/ey_services_api/service_account_response.rb +5 -5
- data/lib/ey_services_api/version.rb +1 -1
- data/spec/provisioned_service_creation_spec.rb +86 -0
- data/spec/service_account_creation_spec.rb +83 -0
- metadata +8 -8
@@ -1,6 +1,7 @@
|
|
1
1
|
module EY
|
2
2
|
module ServicesAPI
|
3
3
|
class ProvisionedServiceResponse < APIStruct.new(:configuration_required, :configuration_url, :message, :vars, :url)
|
4
|
+
|
4
5
|
def to_hash
|
5
6
|
{
|
6
7
|
:provisioned_service => {
|
@@ -9,9 +10,10 @@ module EY
|
|
9
10
|
:configuration_url => self.configuration_url,
|
10
11
|
:vars => self.vars,
|
11
12
|
},
|
12
|
-
:message => self.message.to_hash,
|
13
|
+
:message => self.message && self.message.to_hash,
|
13
14
|
}
|
14
15
|
end
|
16
|
+
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -3,13 +3,13 @@ module EY
|
|
3
3
|
class ServiceAccountResponse < APIStruct.new(:configuration_required, :configuration_url, :message, :provisioned_services_url, :url)
|
4
4
|
def to_hash
|
5
5
|
{
|
6
|
-
:service_account
|
7
|
-
:url
|
8
|
-
:configuration_required
|
9
|
-
:configuration_url
|
6
|
+
:service_account => {
|
7
|
+
:url => self.url,
|
8
|
+
:configuration_required => self.configuration_required,
|
9
|
+
:configuration_url => self.configuration_url,
|
10
10
|
:provisioned_services_url => self.provisioned_services_url
|
11
11
|
},
|
12
|
-
:message
|
12
|
+
:message => self.message && self.message.to_hash
|
13
13
|
}
|
14
14
|
end
|
15
15
|
end
|
@@ -3,6 +3,92 @@ require 'sinatra'
|
|
3
3
|
|
4
4
|
describe EY::ServicesAPI::ProvisionedServiceCreation do
|
5
5
|
|
6
|
+
describe "attributes given in service provisioning" do
|
7
|
+
before do
|
8
|
+
class SaveThis
|
9
|
+
class << self
|
10
|
+
attr_accessor :stuff
|
11
|
+
end
|
12
|
+
end
|
13
|
+
EyServicesFake::MockingBirdService.service_provisioning_handler = Proc.new do
|
14
|
+
SaveThis.stuff = EY::ServicesAPI::ProvisionedServiceCreation.from_request(request.body.read)
|
15
|
+
{}.to_json
|
16
|
+
end
|
17
|
+
end
|
18
|
+
it "matches" do
|
19
|
+
@provisioned_service_hash = @tresfiestas.provisioned_service
|
20
|
+
provisioned_service = SaveThis.stuff
|
21
|
+
app_deployment = @provisioned_service_hash[:app_deployment]
|
22
|
+
provisioned_service.environment.id.should eq app_deployment[:environment][:id]
|
23
|
+
provisioned_service.environment.name.should eq app_deployment[:environment][:name]
|
24
|
+
provisioned_service.environment.framework_env.should eq app_deployment[:environment][:framework_env]
|
25
|
+
provisioned_service.environment.aws_region.should eq app_deployment[:environment][:aws_region]
|
26
|
+
provisioned_service.app.id.should eq app_deployment[:app][:id]
|
27
|
+
provisioned_service.app.name.should eq app_deployment[:app][:name]
|
28
|
+
provisioned_service.messages_url.should eq @provisioned_service_hash[:messages_url]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "with all possible attributes returned" do
|
33
|
+
before do
|
34
|
+
EyServicesFake::MockingBirdService.service_provisioning_handler = Proc.new do
|
35
|
+
provisioned_service = EY::ServicesAPI::ProvisionedServiceCreation.from_request(request.body.read)
|
36
|
+
EY::ServicesAPI::ProvisionedServiceResponse.new(
|
37
|
+
:url => "some url",
|
38
|
+
:vars => {'some_key' => "some value"},
|
39
|
+
:configuration_required => true,
|
40
|
+
:configuration_url => "some configuration url",
|
41
|
+
:message => EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some provisioned service message or something")
|
42
|
+
).to_hash.to_json
|
43
|
+
end
|
44
|
+
end
|
45
|
+
it "works" do
|
46
|
+
@pushed_provisioned_service = @tresfiestas.provisioned_service[:pushed_provisioned_service]
|
47
|
+
@pushed_provisioned_service[:url].should eq "some url"
|
48
|
+
@pushed_provisioned_service[:vars].should eq({'some_key' => "some value"})
|
49
|
+
@pushed_provisioned_service[:configuration_required].should eq true
|
50
|
+
@pushed_provisioned_service[:configuration_url].should eq "some configuration url"
|
51
|
+
status_message = @tresfiestas.latest_status_message
|
52
|
+
status_message.should_not be_nil
|
53
|
+
status_message[:subject].should eq "some provisioned service message or something"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "with no attributes returned" do
|
58
|
+
before do
|
59
|
+
EyServicesFake::MockingBirdService.service_provisioning_handler = Proc.new do
|
60
|
+
SaveThis.stuff = EY::ServicesAPI::ProvisionedServiceCreation.from_request(request.body.read)
|
61
|
+
EY::ServicesAPI::ProvisionedServiceResponse.new.to_hash.to_json
|
62
|
+
end
|
63
|
+
end
|
64
|
+
it "works" do
|
65
|
+
@pushed_provisioned_service = @tresfiestas.provisioned_service[:pushed_provisioned_service]
|
66
|
+
@pushed_provisioned_service[:url].should be_nil
|
67
|
+
@pushed_provisioned_service[:vars].should be_nil
|
68
|
+
@pushed_provisioned_service[:configuration_required].should be_nil
|
69
|
+
@pushed_provisioned_service[:configuration_url].should be_nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "rejecting the provisioning request gracefully" do
|
74
|
+
before do
|
75
|
+
EyServicesFake::MockingBirdService.service_provisioning_handler = Proc.new do
|
76
|
+
status 400
|
77
|
+
{:error_messages => ["This service is not currently supported in us-west"]}.to_json
|
78
|
+
end
|
79
|
+
end
|
80
|
+
it "works" do
|
81
|
+
raised_error = nil
|
82
|
+
begin
|
83
|
+
@tresfiestas.provisioned_service
|
84
|
+
rescue EY::ApiHMAC::BaseConnection::ValidationError => e
|
85
|
+
raised_error = e
|
86
|
+
end
|
87
|
+
raised_error.should_not be_nil
|
88
|
+
raised_error.error_messages.should eq ["This service is not currently supported in us-west"]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
6
92
|
describe "with a service account created" do
|
7
93
|
before do
|
8
94
|
@service_account_hash = @tresfiestas.service_account[:pushed_service_account]
|
@@ -3,6 +3,89 @@ require 'sinatra'
|
|
3
3
|
|
4
4
|
describe EY::ServicesAPI::ServiceAccountCreation do
|
5
5
|
|
6
|
+
describe "attributes given in service account creation" do
|
7
|
+
before do
|
8
|
+
class SaveThis
|
9
|
+
class << self
|
10
|
+
attr_accessor :stuff
|
11
|
+
end
|
12
|
+
end
|
13
|
+
EyServicesFake::MockingBirdService.service_account_creation_handler = Proc.new do
|
14
|
+
SaveThis.stuff = EY::ServicesAPI::ServiceAccountCreation.from_request(request.body.read)
|
15
|
+
{}.to_json
|
16
|
+
end
|
17
|
+
end
|
18
|
+
it "matches" do
|
19
|
+
@service_account_hash = @tresfiestas.service_account
|
20
|
+
service_account = SaveThis.stuff
|
21
|
+
service_account.name.should eq @service_account_hash[:name]
|
22
|
+
service_account.url.should eq @service_account_hash[:url]
|
23
|
+
service_account.messages_url.should eq @service_account_hash[:messages_url]
|
24
|
+
service_account.invoices_url.should eq @service_account_hash[:invoices_url]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "with all possible attributes returned" do
|
29
|
+
before do
|
30
|
+
EyServicesFake::MockingBirdService.service_account_creation_handler = Proc.new do
|
31
|
+
service_account = EY::ServicesAPI::ServiceAccountCreation.from_request(request.body.read)
|
32
|
+
EY::ServicesAPI::ServiceAccountResponse.new(
|
33
|
+
:provisioned_services_url => "some provinioning url",
|
34
|
+
:url => "some resource url",
|
35
|
+
:configuration_url => "some configuration url",
|
36
|
+
:configuration_required => true,
|
37
|
+
:message => EY::ServicesAPI::Message.new(:message_type => "status", :subject => "some message or something")
|
38
|
+
).to_hash.to_json
|
39
|
+
end
|
40
|
+
end
|
41
|
+
it "works" do
|
42
|
+
@service_account_hash = @tresfiestas.service_account[:pushed_service_account]
|
43
|
+
@service_account_hash[:configuration_required].should eq true
|
44
|
+
@service_account_hash[:configuration_url].should eq "some configuration url"
|
45
|
+
@service_account_hash[:provisioned_services_url].should eq "some provinioning url"
|
46
|
+
@service_account_hash[:url].should eq "some resource url"
|
47
|
+
status_message = @tresfiestas.latest_status_message
|
48
|
+
status_message.should_not be_nil
|
49
|
+
status_message[:subject].should eq "some message or something"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "with no attributes returned" do
|
54
|
+
before do
|
55
|
+
EyServicesFake::MockingBirdService.service_account_creation_handler = Proc.new do
|
56
|
+
EY::ServicesAPI::ServiceAccountResponse.new.to_hash.to_json
|
57
|
+
end
|
58
|
+
end
|
59
|
+
it "works" do
|
60
|
+
@service_account_hash = @tresfiestas.service_account[:pushed_service_account]
|
61
|
+
@service_account_hash[:configuration_required].should be_nil
|
62
|
+
@service_account_hash[:configuration_url].should be_nil
|
63
|
+
@service_account_hash[:provisioned_services_url].should be_nil
|
64
|
+
@service_account_hash[:url].should be_nil
|
65
|
+
status_message = @tresfiestas.latest_status_message
|
66
|
+
status_message.should be_nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "rejecting the creation request gracefully" do
|
71
|
+
before do
|
72
|
+
EyServicesFake::MockingBirdService.service_account_creation_handler = Proc.new do
|
73
|
+
status 400
|
74
|
+
{:error_messages => ["This service is not currently supported for trial customers"]}.to_json
|
75
|
+
end
|
76
|
+
end
|
77
|
+
it "works" do
|
78
|
+
raised_error = nil
|
79
|
+
begin
|
80
|
+
@tresfiestas.service_account
|
81
|
+
rescue EY::ApiHMAC::BaseConnection::ValidationError => e
|
82
|
+
raised_error = e
|
83
|
+
end
|
84
|
+
raised_error.should_not be_nil
|
85
|
+
raised_error.error_messages.should eq ["This service is not currently supported for trial customers"]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
6
89
|
describe "with a service account created" do
|
7
90
|
before do
|
8
91
|
@service_account_hash = @tresfiestas.service_account[:pushed_service_account]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ey_services_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2154994140 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2154994140
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &2154993700 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2154993700
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: ey_api_hmac
|
38
|
-
requirement: &
|
38
|
+
requirement: &2154993240 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2154993240
|
47
47
|
description: API for Partner Services (talks to services.engineyard.com)
|
48
48
|
email:
|
49
49
|
- jacob@engineyard.com
|