cfoundry 4.3.5.rc1 → 4.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cc_api_stub/helper.rb +12 -3
- data/lib/cc_api_stub/spaces.rb +5 -0
- data/lib/cfoundry/uaaclient.rb +3 -2
- data/lib/cfoundry/v2/client.rb +2 -2
- data/lib/cfoundry/version.rb +1 -1
- data/lib/tasks/gem_release.rake +6 -0
- data/spec/cfoundry/uaaclient_spec.rb +41 -11
- data/spec/cfoundry/v2/client_spec.rb +1 -1
- data/spec/fixtures/fake_cc_space_apps.json +49 -0
- metadata +11 -6
data/lib/cc_api_stub/helper.rb
CHANGED
@@ -91,7 +91,7 @@ module CcApiStub
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def succeed_to_load(options={})
|
94
|
-
response_body =
|
94
|
+
response_body = response_from_options(options.reverse_merge!({:fixture => "fake_cc_#{object_name}"}))
|
95
95
|
stub_get(object_endpoint(options[:id]), {}, response(200, response_body))
|
96
96
|
end
|
97
97
|
|
@@ -100,7 +100,7 @@ module CcApiStub
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def succeed_to_load_many(options={})
|
103
|
-
response_body =
|
103
|
+
response_body = response_from_options(options.reverse_merge!({:fixture => "fake_cc_#{object_name.pluralize}"}))
|
104
104
|
stub_get(collection_endpoint, {}, response(200, response_body))
|
105
105
|
end
|
106
106
|
|
@@ -119,7 +119,7 @@ module CcApiStub
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def succeed_to_update(options = {})
|
122
|
-
stub_put(object_endpoint(options[:id]), nil, response(200,
|
122
|
+
stub_put(object_endpoint(options[:id]), nil, response(200, response_from_options(options)))
|
123
123
|
end
|
124
124
|
|
125
125
|
def fail_to_update(options = {})
|
@@ -135,5 +135,14 @@ module CcApiStub
|
|
135
135
|
def fixture_prefix
|
136
136
|
"_cc"
|
137
137
|
end
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
def response_from_options(options)
|
142
|
+
fixture = options.delete(:fixture)
|
143
|
+
return options[:response] if options[:response]
|
144
|
+
return CcApiStub::Helper.load_fixtures(fixture, options) if fixture
|
145
|
+
{}
|
146
|
+
end
|
138
147
|
end
|
139
148
|
end
|
data/lib/cc_api_stub/spaces.rb
CHANGED
@@ -23,6 +23,11 @@ module CcApiStub
|
|
23
23
|
stub_get(%r{/v2/spaces/[^/]+/summary$}, {}, response(200, response_body))
|
24
24
|
end
|
25
25
|
|
26
|
+
def succeed_to_load_apps(options={})
|
27
|
+
response = response_from_options(options.reverse_merge!({:fixture => "fake_cc_space_apps"}))
|
28
|
+
stub_get(%r{/v2/spaces/[^/]+/apps\?inline-relations-depth=1}, {}, response(200, response))
|
29
|
+
end
|
30
|
+
|
26
31
|
def space_fixture_hash
|
27
32
|
{
|
28
33
|
:metadata => {
|
data/lib/cfoundry/uaaclient.rb
CHANGED
@@ -60,14 +60,15 @@ module CFoundry
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
def add_user(email, password)
|
63
|
+
def add_user(email, password, options = {})
|
64
64
|
wrap_uaa_errors do
|
65
65
|
scim.add(
|
66
66
|
:user,
|
67
67
|
{:userName => email,
|
68
68
|
:emails => [{:value => email}],
|
69
69
|
:password => password,
|
70
|
-
:name => {:givenName =>
|
70
|
+
:name => {:givenName => options[:givenName] || email,
|
71
|
+
:familyName => options[:familyName] || email}
|
71
72
|
}
|
72
73
|
)
|
73
74
|
end
|
data/lib/cfoundry/v2/client.rb
CHANGED
@@ -50,8 +50,8 @@ module CFoundry::V2
|
|
50
50
|
super
|
51
51
|
end
|
52
52
|
|
53
|
-
def register(email, password)
|
54
|
-
uaa_user = @base.uaa.add_user(email, password)
|
53
|
+
def register(email, password, options = {})
|
54
|
+
uaa_user = @base.uaa.add_user(email, password, options)
|
55
55
|
cc_user = user
|
56
56
|
cc_user.guid = uaa_user[:id]
|
57
57
|
cc_user.create!
|
data/lib/cfoundry/version.rb
CHANGED
data/lib/tasks/gem_release.rake
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'active_support/time'
|
1
2
|
require 'active_support/core_ext'
|
2
3
|
|
3
4
|
namespace :gem do
|
@@ -7,6 +8,11 @@ namespace :gem do
|
|
7
8
|
old_version = gem_version
|
8
9
|
|
9
10
|
sh! "gem bump --version #{version} --no-commit"
|
11
|
+
|
12
|
+
print "About to bump version to #{gem_version}, continue? (Y): "
|
13
|
+
answer = STDIN.gets.strip
|
14
|
+
exit unless answer.length == 0 || answer.upcase.start_with?("Y")
|
15
|
+
|
10
16
|
sh! "git add lib/cfoundry/version.rb"
|
11
17
|
|
12
18
|
print_with_purpose "Bumping to version #{gem_version}"
|
@@ -255,11 +255,12 @@ EOF
|
|
255
255
|
let(:email) { 'test@test.com' }
|
256
256
|
let(:password) { 'secret' }
|
257
257
|
|
258
|
-
|
258
|
+
context "without given/family name" do
|
259
|
+
subject { uaa.add_user(email, password) }
|
259
260
|
|
260
|
-
|
261
|
-
|
262
|
-
|
261
|
+
context 'with valid data' do
|
262
|
+
it "should add a user" do
|
263
|
+
req =
|
263
264
|
stub_request(:post, "https://uaa.example.com/Users").with(
|
264
265
|
:body =>
|
265
266
|
{ :userName => email,
|
@@ -267,16 +268,45 @@ EOF
|
|
267
268
|
:password => password,
|
268
269
|
:name => { :givenName => email, :familyName => email }
|
269
270
|
}
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
271
|
+
).to_return(
|
272
|
+
:status => 200,
|
273
|
+
:body => '{ "id" : "id" }',
|
274
|
+
:headers => { "Content-Type" => 'application/json' }
|
275
|
+
)
|
276
|
+
|
277
|
+
expect(subject).to eq({:id => "id"})
|
278
|
+
expect(req).to have_been_requested
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
275
282
|
|
276
|
-
|
277
|
-
|
283
|
+
context "with given/family name" do
|
284
|
+
let(:givenName) { 'givenName' }
|
285
|
+
let(:familyName) { 'familyName' }
|
286
|
+
subject { uaa.add_user(email, password, givenName: givenName, familyName: familyName) }
|
287
|
+
|
288
|
+
context 'with valid data' do
|
289
|
+
it "should add a user" do
|
290
|
+
req =
|
291
|
+
stub_request(:post, "https://uaa.example.com/Users").with(
|
292
|
+
:body =>
|
293
|
+
{ :userName => email,
|
294
|
+
:emails => [{ :value => email }],
|
295
|
+
:password => password,
|
296
|
+
:name => { :givenName => givenName, :familyName => familyName }
|
297
|
+
}
|
298
|
+
).to_return(
|
299
|
+
:status => 200,
|
300
|
+
:body => '{ "id" : "id" }',
|
301
|
+
:headers => { "Content-Type" => 'application/json' }
|
302
|
+
)
|
303
|
+
|
304
|
+
expect(subject).to eq({:id => "id"})
|
305
|
+
expect(req).to have_been_requested
|
306
|
+
end
|
278
307
|
end
|
279
308
|
end
|
309
|
+
|
280
310
|
end
|
281
311
|
|
282
312
|
describe "#delete_user" do
|
@@ -14,7 +14,7 @@ module CFoundry
|
|
14
14
|
|
15
15
|
it "creates the user in uaa and ccng" do
|
16
16
|
client.base.stub(:uaa) { uaa }
|
17
|
-
uaa.stub(:add_user).with(email, password) { {:id => "1234"} }
|
17
|
+
uaa.stub(:add_user).with(email, password, {}) { {:id => "1234"} }
|
18
18
|
|
19
19
|
user = build(:user)
|
20
20
|
client.stub(:user) { user }
|
@@ -0,0 +1,49 @@
|
|
1
|
+
{
|
2
|
+
"total_results": 2,
|
3
|
+
"total_pages": 1,
|
4
|
+
"prev_url": null,
|
5
|
+
"next_url": null,
|
6
|
+
"resources": [
|
7
|
+
{
|
8
|
+
"metadata": {
|
9
|
+
"guid": "application-id-1",
|
10
|
+
"url": "/v2/apps/application-id-1",
|
11
|
+
"created_at": "2012-08-13 12:48:41 -0700",
|
12
|
+
"updated_at": "2012-08-13 12:55:10 -0700"
|
13
|
+
},
|
14
|
+
"entity": {
|
15
|
+
"name": "app-name-1",
|
16
|
+
"space_guid": "space-id-1",
|
17
|
+
"environment_json": null,
|
18
|
+
"memory": 2048,
|
19
|
+
"instances": 1,
|
20
|
+
"file_descriptors": 100,
|
21
|
+
"disk_quota": 500,
|
22
|
+
"state": "STARTED",
|
23
|
+
"service_bindings_url": "/v2/service_bindings?q=app_guid:application-id-1",
|
24
|
+
"space_url": "/v2/spaces/space-id-1"
|
25
|
+
}
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"metadata": {
|
29
|
+
"guid": "application-id-2",
|
30
|
+
"url": "/v2/apps/application-id-2",
|
31
|
+
"created_at": "2012-08-13 12:48:41 -0700",
|
32
|
+
"updated_at": "2012-08-13 12:55:10 -0700"
|
33
|
+
},
|
34
|
+
"entity": {
|
35
|
+
"name": "app-name-2",
|
36
|
+
"space_guid": "space-id-1",
|
37
|
+
"environment_json": null,
|
38
|
+
"memory": 2048,
|
39
|
+
"instances": 1,
|
40
|
+
"file_descriptors": 100,
|
41
|
+
"disk_quota": 500,
|
42
|
+
"state": "STARTED",
|
43
|
+
"service_bindings_url": "/v2/service_bindings?q=app_guid:application-id-2",
|
44
|
+
"space_url": "/v2/spaces/space-id-1"
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
]
|
49
|
+
}
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfoundry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.3.5
|
5
|
-
prerelease:
|
4
|
+
version: 4.3.5
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Cloud Foundry Team
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-08-
|
13
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
@@ -421,6 +421,7 @@ files:
|
|
421
421
|
- spec/fixtures/fake_cc_service_instances.json
|
422
422
|
- spec/fixtures/fake_cc_services.json
|
423
423
|
- spec/fixtures/fake_cc_space.json
|
424
|
+
- spec/fixtures/fake_cc_space_apps.json
|
424
425
|
- spec/fixtures/fake_cc_space_summary.json
|
425
426
|
- spec/fixtures/fake_cc_spaces.json
|
426
427
|
- spec/fixtures/fake_cc_stats.json
|
@@ -450,13 +451,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
450
451
|
version: '0'
|
451
452
|
segments:
|
452
453
|
- 0
|
453
|
-
hash:
|
454
|
+
hash: 1950247728872914231
|
454
455
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
455
456
|
none: false
|
456
457
|
requirements:
|
457
|
-
- - ! '
|
458
|
+
- - ! '>='
|
458
459
|
- !ruby/object:Gem::Version
|
459
|
-
version:
|
460
|
+
version: '0'
|
461
|
+
segments:
|
462
|
+
- 0
|
463
|
+
hash: 1950247728872914231
|
460
464
|
requirements: []
|
461
465
|
rubyforge_project: cfoundry
|
462
466
|
rubygems_version: 1.8.25
|
@@ -556,6 +560,7 @@ test_files:
|
|
556
560
|
- spec/fixtures/fake_cc_service_instances.json
|
557
561
|
- spec/fixtures/fake_cc_services.json
|
558
562
|
- spec/fixtures/fake_cc_space.json
|
563
|
+
- spec/fixtures/fake_cc_space_apps.json
|
559
564
|
- spec/fixtures/fake_cc_space_summary.json
|
560
565
|
- spec/fixtures/fake_cc_spaces.json
|
561
566
|
- spec/fixtures/fake_cc_stats.json
|