cf 5.2.1.rc3 → 5.2.1.rc4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -6,12 +6,6 @@ specfile, _ = Dir["*.gemspec"]
6
6
  SPEC = Gem::Specification.load(specfile)
7
7
  CURRENT_VERSION = SPEC.version.to_s.freeze
8
8
 
9
- namespace :spec do
10
- RSpec::Core::RakeTask.new(:ci) do |t|
11
- t.rspec_opts = '-t ~type:integration'
12
- end
13
- end
14
-
15
9
  RSpec::Core::RakeTask.new(:spec)
16
10
  task :default => :spec
17
11
 
@@ -25,7 +25,7 @@ module CFAdmin::ServiceBroker
25
25
  broker.token = input[:token]
26
26
  finalize
27
27
 
28
- with_progress("Adding service broker #{broker.name}") do
28
+ with_progress("Adding service broker #{c(broker.name, :name)}") do
29
29
  broker.create!
30
30
  end
31
31
  end
@@ -18,7 +18,7 @@ module CFAdmin::ServiceBroker
18
18
  broker = input[:name]
19
19
  return unless input[:really, broker]
20
20
 
21
- with_progress("Removing service broker #{broker.name}") do
21
+ with_progress("Removing service broker #{c(broker.name, :name)}") do
22
22
  broker.delete!
23
23
  end
24
24
  end
@@ -1,4 +1,4 @@
1
- require "active_support/core_ext"
1
+ require 'active_support/core_ext/object/try'
2
2
 
3
3
  class TargetPrettifier
4
4
  def self.prettify(client, outputter)
@@ -15,4 +15,4 @@ class TargetPrettifier
15
15
  outputter.c('N/A', :bad)
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module CF
2
- VERSION = "5.2.1.rc3".freeze
2
+ VERSION = "5.2.1.rc4".freeze
3
3
  end
@@ -236,7 +236,6 @@ module CFManifests
236
236
 
237
237
  def warn_reset_changes
238
238
  line c("Not applying manifest changes without --reset", :warning)
239
- line "See `cf diff` for more details."
240
239
  line
241
240
  end
242
241
 
@@ -0,0 +1,151 @@
1
+ require "spec_helper"
2
+ require "sinatra"
3
+
4
+ class FakeCloudController < Sinatra::Base
5
+ @requests = []
6
+
7
+ class << self
8
+ attr_accessor :requests
9
+
10
+ def last_request
11
+ requests.last
12
+ end
13
+
14
+ def reset
15
+ requests.clear
16
+ end
17
+ end
18
+
19
+ get '/v2/service_brokers' do
20
+ self.class.requests << request
21
+
22
+ broker_guid = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
23
+ body = {
24
+ 'total_results' => 1,
25
+ 'total_pages' => 1,
26
+ 'prev_url' => nil,
27
+ 'next_url' => nil,
28
+ 'resources' => [{
29
+ 'metadata' => {
30
+ 'guid' => broker_guid,
31
+ 'url' => "http://cc.example.com/v2/service_brokers/#{broker_guid}",
32
+ 'created_at' => Time.now,
33
+ 'updated_at' => Time.now,
34
+ },
35
+ 'entity' => {
36
+ 'name' => 'my-custom-service',
37
+ 'broker_url' => 'http://broker.example.com/',
38
+ }
39
+ }]
40
+ }.to_json
41
+ [200, {}, body]
42
+ end
43
+
44
+ post '/v2/service_brokers' do
45
+ self.class.requests << request
46
+
47
+ body = {
48
+ metadata: {
49
+ guid: SecureRandom.uuid
50
+ }
51
+ }.to_json
52
+
53
+ [200, {}, body]
54
+ end
55
+
56
+ delete '/v2/service_brokers/:guid' do
57
+ self.class.requests << request
58
+ 204
59
+ end
60
+
61
+ get '/responsive' do
62
+ 200
63
+ end
64
+ end
65
+
66
+ describe "Service Brokers" do
67
+ let(:broker_url) { 'http://broker.example.com/' }
68
+ let(:broker_token) { 'opensesame' }
69
+ let(:last_request) { FakeCloudController.last_request }
70
+
71
+ before do
72
+ thr = Thread.new do
73
+ Rack::Handler::WEBrick.run(FakeCloudController, :Port => 12345, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
74
+ end
75
+
76
+ def responsive?
77
+ begin
78
+ resp = Net::HTTP.start('localhost', 12345) { |http| http.get('/responsive') }
79
+ resp.is_a? Net::HTTPSuccess
80
+ rescue Errno::ECONNREFUSED
81
+ false
82
+ end
83
+ end
84
+
85
+ Timeout.timeout(60) { thr.join(0.1) until responsive? }
86
+
87
+ @homedir = File.join(File.dirname(__FILE__), '..', '..', 'tmp')
88
+ FileUtils.mkdir_p(File.join(@homedir, '.cf'))
89
+
90
+ # cf target
91
+ File.open(File.join(@homedir, '.cf', 'target'), 'w') do |f|
92
+ f.puts 'http://127.0.0.1:12345'
93
+ end
94
+
95
+ # cf login
96
+ File.open(File.join(@homedir, '.cf', 'tokens.yml'), 'w') do |f|
97
+ f.puts <<-YAML
98
+ http://127.0.0.1:8181:
99
+ :version: 2
100
+ :token: bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI0MGE0YWJlOS0yYTgxLTQyZGYtODVjNS1kNDdlMzRiOTA0YTEiLCJ1c2VyX2lkIjoiMzI5YmIzYmYtMWU3NS00MGQ3LThhMDItMjI3Y2FjY2IyZGU3Iiwic3ViIjoiMzI5YmIzYmYtMWU3NS00MGQ3LThhMDItMjI3Y2FjY2IyZGU3IiwidXNlcl9uYW1lIjoiYWRtaW4iLCJlbWFpbCI6ImFkbWluIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiIsImNsb3VkX2NvbnRyb2xsZXIucmVhZCIsImNsb3VkX2NvbnRyb2xsZXIud3JpdGUiLCJvcGVuaWQiLCJwYXNzd29yZC53cml0ZSIsInNjaW0ucmVhZCIsInNjaW0ud3JpdGUiXSwiY2xpZW50X2lkIjoiY2YiLCJjaWQiOiJjZiIsImlhdCI6MTM3NjU5MzI3NiwiZXhwIjoxMzc2NjAwNDc2LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvdWFhL29hdXRoL3Rva2VuIiwiYXVkIjpbInNjaW0iLCJvcGVuaWQiLCJjbG91ZF9jb250cm9sbGVyIiwicGFzc3dvcmQiXX0.VSPhFetKLDvZal8bOK38uTBbkrDD2_IdSjHqluk1WIY
101
+ :refresh_token: eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI1MzA3ZGJmNC1iMTE1LTQ0MzgtOWRkNi00ZGVlMDVkZjgwN2IiLCJzdWIiOiIzMjliYjNiZi0xZTc1LTQwZDctOGEwMi0yMjdjYWNjYjJkZTciLCJ1c2VyX25hbWUiOiJhZG1pbiIsInNjb3BlIjpbImNsb3VkX2NvbnRyb2xsZXIuYWRtaW4iLCJjbG91ZF9jb250cm9sbGVyLnJlYWQiLCJjbG91ZF9jb250cm9sbGVyLndyaXRlIiwib3BlbmlkIiwicGFzc3dvcmQud3JpdGUiLCJzY2ltLnJlYWQiLCJzY2ltLndyaXRlIl0sImlhdCI6MTM3NjU5MzI3NiwiZXhwIjoxMzc3ODAyODc2LCJjaWQiOiJjZiIsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC91YWEvb2F1dGgvdG9rZW4iLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiIsImNsb3VkX2NvbnRyb2xsZXIucmVhZCIsImNsb3VkX2NvbnRyb2xsZXIud3JpdGUiLCJvcGVuaWQiLCJwYXNzd29yZC53cml0ZSIsInNjaW0ucmVhZCIsInNjaW0ud3JpdGUiXX0.7wlsnXoBuE-jSYTBZboy1U26NWs4-VHBEYYGMLz5YFQ
102
+ :space: 671847d5-9754-49b2-bc9f-977ee42c7e4c
103
+ :organization: 57944537-4f45-424d-a8af-b41ab6b4f0a0
104
+ YAML
105
+ end
106
+ end
107
+
108
+ after do
109
+ crash_log = File.join(@homedir, '.cf', 'crash')
110
+ if File.exists?(crash_log)
111
+ puts `cat #{crash_log}`
112
+ FileUtils.rm(crash_log)
113
+ end
114
+
115
+ FakeCloudController.reset
116
+ end
117
+
118
+ it "allows an admin user to add a service broker" do
119
+ BlueShell::Runner.run("env HOME=#{@homedir} #{cf_bin} add-service-broker --name my-custom-service --url #{broker_url} --token #{broker_token}") do |runner|
120
+ expect(runner).to say "Adding service broker my-custom-service... OK"
121
+ end
122
+
123
+ expect(last_request).to be_post
124
+ expect(last_request.path).to eq('/v2/service_brokers')
125
+ expect(JSON.load(last_request.body)).to eq(
126
+ 'name' => 'my-custom-service',
127
+ 'broker_url' => broker_url,
128
+ 'token' => broker_token
129
+ )
130
+ end
131
+
132
+ it "allows an admin user to list service brokers" do
133
+ BlueShell::Runner.run("env HOME=#{@homedir} #{cf_bin} service-brokers") do |runner|
134
+ expect(runner).to say /my-custom-service.*#{broker_url}/
135
+ end
136
+
137
+ expect(last_request).to be_get
138
+ expect(last_request.path).to eq('/v2/service_brokers')
139
+ end
140
+
141
+ it "allows an admin user to remove a service broker" do
142
+ BlueShell::Runner.run("env HOME=#{@homedir} #{cf_bin} remove-service-broker my-custom-service") do |runner|
143
+ expect(runner).to say "Really remove my-custom-service?> n"
144
+ runner.send_keys("y")
145
+ expect(runner).to say "Removing service broker my-custom-service... OK"
146
+ end
147
+
148
+ expect(last_request).to be_delete
149
+ expect(last_request.path).to eq('/v2/service_brokers/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa')
150
+ end
151
+ end
@@ -10,7 +10,6 @@ require "webmock/rspec"
10
10
  require "ostruct"
11
11
  require "fakefs/safe"
12
12
  require "blue-shell"
13
- require_relative '../vendor/integration-test-support/support/integration_example_group.rb'
14
13
 
15
14
  TRAVIS_BUILD_ID = ENV["TRAVIS_BUILD_ID"]
16
15
 
@@ -30,10 +29,6 @@ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each do |file|
30
29
  require file
31
30
  end
32
31
 
33
- tmp_dir = File.expand_path('../tmp', File.dirname(__FILE__))
34
- FileUtils.mkdir_p(tmp_dir)
35
- IntegrationExampleGroup.tmp_dir = tmp_dir
36
-
37
32
  RSpec.configure do |c|
38
33
  c.include BlueShell::Matchers
39
34
 
@@ -46,7 +41,6 @@ RSpec.configure do |c|
46
41
  c.include InteractHelper
47
42
  c.include ConfigHelper
48
43
  c.include FeaturesHelper
49
- c.include IntegrationExampleGroup, type: :integration, :example_group => {:file_path => /\/integration\//}
50
44
 
51
45
  c.before(:all) do
52
46
  WebMock.disable_net_connect!(:allow_localhost => true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cf
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.1.rc3
4
+ version: 5.2.1.rc4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-08-16 00:00:00.000000000 Z
13
+ date: 2013-08-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -307,55 +307,7 @@ dependencies:
307
307
  - !ruby/object:Gem::Version
308
308
  version: 0.2.4
309
309
  - !ruby/object:Gem::Dependency
310
- name: webmock
311
- requirement: !ruby/object:Gem::Requirement
312
- none: false
313
- requirements:
314
- - - ~>
315
- - !ruby/object:Gem::Version
316
- version: '1.9'
317
- type: :development
318
- prerelease: false
319
- version_requirements: !ruby/object:Gem::Requirement
320
- none: false
321
- requirements:
322
- - - ~>
323
- - !ruby/object:Gem::Version
324
- version: '1.9'
325
- - !ruby/object:Gem::Dependency
326
- name: httpclient
327
- requirement: !ruby/object:Gem::Requirement
328
- none: false
329
- requirements:
330
- - - ~>
331
- - !ruby/object:Gem::Version
332
- version: '2.3'
333
- type: :development
334
- prerelease: false
335
- version_requirements: !ruby/object:Gem::Requirement
336
- none: false
337
- requirements:
338
- - - ~>
339
- - !ruby/object:Gem::Version
340
- version: '2.3'
341
- - !ruby/object:Gem::Dependency
342
- name: yajl-ruby
343
- requirement: !ruby/object:Gem::Requirement
344
- none: false
345
- requirements:
346
- - - ! '>='
347
- - !ruby/object:Gem::Version
348
- version: '0'
349
- type: :development
350
- prerelease: false
351
- version_requirements: !ruby/object:Gem::Requirement
352
- none: false
353
- requirements:
354
- - - ! '>='
355
- - !ruby/object:Gem::Version
356
- version: '0'
357
- - !ruby/object:Gem::Dependency
358
- name: nats
310
+ name: sinatra
359
311
  requirement: !ruby/object:Gem::Requirement
360
312
  none: false
361
313
  requirements:
@@ -371,21 +323,21 @@ dependencies:
371
323
  - !ruby/object:Gem::Version
372
324
  version: '0'
373
325
  - !ruby/object:Gem::Dependency
374
- name: typhoeus
326
+ name: webmock
375
327
  requirement: !ruby/object:Gem::Requirement
376
328
  none: false
377
329
  requirements:
378
- - - ! '>='
330
+ - - ~>
379
331
  - !ruby/object:Gem::Version
380
- version: '0'
332
+ version: '1.9'
381
333
  type: :development
382
334
  prerelease: false
383
335
  version_requirements: !ruby/object:Gem::Requirement
384
336
  none: false
385
337
  requirements:
386
- - - ! '>='
338
+ - - ~>
387
339
  - !ruby/object:Gem::Version
388
- version: '0'
340
+ version: '1.9'
389
341
  description:
390
342
  email:
391
343
  - vcap-dev@googlegroups.com
@@ -656,10 +608,10 @@ files:
656
608
  - spec/features/manifests_spec.rb
657
609
  - spec/features/org_spec.rb
658
610
  - spec/features/push_flow_spec.rb
611
+ - spec/features/service_brokers_spec.rb
659
612
  - spec/features/services_spec.rb
660
613
  - spec/features/space_spec.rb
661
614
  - spec/features/switching_targets_spec.rb
662
- - spec/integration/service_broker_spec.rb
663
615
  - spec/manifests/errors_spec.rb
664
616
  - spec/manifests/loader/builder_spec.rb
665
617
  - spec/manifests/loader/normalizer_spec.rb
@@ -694,7 +646,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
694
646
  version: '0'
695
647
  segments:
696
648
  - 0
697
- hash: -1035576781016714598
649
+ hash: -2008180272161412010
698
650
  required_rubygems_version: !ruby/object:Gem::Requirement
699
651
  none: false
700
652
  requirements:
@@ -850,10 +802,10 @@ test_files:
850
802
  - spec/features/manifests_spec.rb
851
803
  - spec/features/org_spec.rb
852
804
  - spec/features/push_flow_spec.rb
805
+ - spec/features/service_brokers_spec.rb
853
806
  - spec/features/services_spec.rb
854
807
  - spec/features/space_spec.rb
855
808
  - spec/features/switching_targets_spec.rb
856
- - spec/integration/service_broker_spec.rb
857
809
  - spec/manifests/errors_spec.rb
858
810
  - spec/manifests/loader/builder_spec.rb
859
811
  - spec/manifests/loader/normalizer_spec.rb
@@ -1,77 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Service Broker Management", components: [:nats, :uaa, :ccng, :fake_service_broker] do
4
- let(:username) { 'admin' }
5
- let(:password) { 'the_admin_pw' }
6
- let(:target) { 'http://127.0.0.1:8181' }
7
-
8
- let(:broker_url) { 'http://127.0.0.1:54329' }
9
- let(:broker_token) { 'opensesame' }
10
-
11
- before do
12
- create_user_in_ccng
13
- logout
14
-
15
- BlueShell::Runner.run("#{cf_bin} target #{target}") do |runner|
16
- runner.wait_for_exit
17
- expect(runner).to be_successful
18
- end
19
-
20
- BlueShell::Runner.run("#{cf_bin} login #{username} --password #{password}") do |runner|
21
- expect(runner).to say "Authenticating... OK"
22
- end
23
- end
24
-
25
- after do
26
- logout
27
- end
28
-
29
- it "allows an admin user to add a service broker" do
30
- BlueShell::Runner.run("#{cf_bin} add-service-broker --name my-custom-service --url #{broker_url} --token #{broker_token}") do |runner|
31
- expect(runner).to say "Adding service broker my-custom-service... OK"
32
- end
33
- end
34
-
35
- context "with a service broker already registered" do
36
- before do
37
- BlueShell::Runner.run("#{cf_bin} add-service-broker --name my-custom-service --url #{broker_url} --token #{broker_token}") do |runner|
38
- expect(runner).to say "Adding service broker my-custom-service... OK"
39
- end
40
- end
41
-
42
- it "allows an admin user to list service brokers" do
43
- BlueShell::Runner.run("#{cf_bin} service-brokers") do |runner|
44
- expect(runner).to say /my-custom-service.*#{broker_url}/
45
- end
46
- end
47
-
48
- it "allows an admin user to remove a service broker" do
49
- BlueShell::Runner.run("#{cf_bin} remove-service-broker my-custom-service") do |runner|
50
- expect(runner).to say "Really remove my-custom-service?> n"
51
- runner.send_keys("y")
52
- expect(runner).to say "Removing service broker my-custom-service... OK"
53
- end
54
-
55
- BlueShell::Runner.run("#{cf_bin} service-brokers") do |runner|
56
- expect(runner).to_not say /my-custom-service/
57
- end
58
- end
59
- end
60
-
61
- def create_user_in_ccng
62
- ccng_post "/v2/users", {
63
- guid: user_guid
64
- }
65
- end
66
-
67
- def user_guid
68
- uaa_port = component!(:uaa).port
69
- token_issuer = CF::UAA::TokenIssuer.new("http://localhost:#{uaa_port}", 'cf')
70
- auth_header = token_issuer.owner_password_grant(username, password).auth_header
71
- response = Typhoeus::Request.new(
72
- "http://localhost:#{uaa_port}/Users?filter=userName+eq+'#{username}'",
73
- headers: {'Authorization' => auth_header}
74
- ).run
75
- JSON.parse(response.body).fetch("resources").first.fetch('id')
76
- end
77
- end