cf-uaac 1.3.0 → 1.3.1

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/README.md CHANGED
@@ -1,32 +1,24 @@
1
1
  # CloudFoundry UAA Command Line Client
2
2
 
3
- Command line gem for interacting with the CloudFoundry UAA server.
3
+ ## Build the gem
4
4
 
5
- Set up a local ruby environment (so sudo not required):
5
+ $ bundle install
6
+ $ gem build cf-uaac.gemspec
6
7
 
7
- `$ rvm use 1.9.2`
8
+ ## Install it
8
9
 
9
- or
10
+ $ gem install cf-uaac*.gem
10
11
 
11
- `$ rbenv global 1.9.2-p180`
12
+ or from rubygems
12
13
 
13
- see: https://rvm.io/ or http://rbenv.org/
14
+ $ gem install cf-uaac
14
15
 
15
- Build the gem
16
+ ## Run it
16
17
 
17
- `$ bundle install`
18
- `$ gem build cf-uaac.gemspec`
19
-
20
- Install it
21
-
22
- `$ gem install cf-uaac*.gem`
23
-
24
- Run it
25
-
26
- `$ uaac help`
27
- `$ uaac target uaa.cloudfoundry.com`
28
- `$ uaac token get <your-cf-username>`
29
- `$ uaac token decode`
18
+ $ uaac help
19
+ $ uaac target uaa.cloudfoundry.com
20
+ $ uaac token get <your-cf-username>
21
+ $ uaac token decode
30
22
 
31
23
  To use the APIs, see: https://github.com/cloudfoundry/cf-uaa-lib
32
24
 
@@ -34,15 +26,15 @@ To use the APIs, see: https://github.com/cloudfoundry/cf-uaa-lib
34
26
 
35
27
  Run the tests with rake:
36
28
 
37
- `$ bundle exec rake test`
29
+ $ bundle exec rake test
38
30
 
39
31
  Run the tests and see a fancy coverage report:
40
32
 
41
- `$ bundle exec rake cov`
33
+ $ bundle exec rake cov
42
34
 
43
35
  Run integration tests (on a server running on localhost:8080/uaa):
44
36
 
45
- `$ export UAA_CLIENT_ID="admin"`
46
- `$ export UAA_CLIENT_SECRET="adminsecret"`
47
- `$ export UAA_CLIENT_TARGET="http://localhost:8080/uaa"`
48
- `$ bundle exec rspec spec/integration_spec.rb`
37
+ $ export UAA_CLIENT_ID="admin"
38
+ $ export UAA_CLIENT_SECRET="adminsecret"
39
+ $ export UAA_CLIENT_TARGET="http://localhost:8080/uaa"
40
+ $ bundle exec rspec spec/integration_spec.rb
data/cf-uaac.gemspec CHANGED
@@ -38,9 +38,8 @@ Gem::Specification.new do |s|
38
38
  s.add_development_dependency "simplecov"
39
39
  s.add_development_dependency "simplecov-rcov"
40
40
  s.add_development_dependency "ci_reporter"
41
+ s.add_runtime_dependency "cf-uaa-lib", ">= 1.3.1"
41
42
  s.add_runtime_dependency "highline"
42
- s.add_runtime_dependency "cf-uaa-lib", ">= 1.3.0"
43
- s.add_runtime_dependency "multi_json"
44
43
  s.add_runtime_dependency "eventmachine"
45
44
  s.add_runtime_dependency "launchy"
46
45
  s.add_runtime_dependency "em-http-request", ">= 1.0.0.beta.3"
@@ -19,26 +19,31 @@ class ClientCli < CommonCli
19
19
 
20
20
  topic "Client Application Registrations", "reg"
21
21
 
22
- CLIENT_SCHEMA = { scope: "list", authorized_grant_types: "list",
23
- authorities: "list", access_token_validity: "seconds",
24
- refresh_token_validity: "seconds", redirect_uri: "list" }
22
+ CLIENT_SCHEMA = { scope: "list", authorized_grant_types: "list",
23
+ authorities: "list", access_token_validity: "seconds",
24
+ refresh_token_validity: "seconds", redirect_uri: "list",
25
+ autoapprove: "list" }
25
26
  CLIENT_SCHEMA.each { |k, v| define_option(k, "--#{k} <#{v}>") }
26
27
 
27
28
  def client_info(defaults)
28
- info = {client_id: defaults["client_id"] || opts[:client_id]}
29
+ info = {client_id: defaults[:client_id] || opts[:client_id]}
29
30
  info[:client_secret] = opts[:secret] if opts[:secret]
30
31
  del_attrs = Util.arglist(opts[:del_attrs], [])
31
32
  CLIENT_SCHEMA.each_with_object(info) do |(k, p), info|
32
33
  next if del_attrs.include?(k)
33
- default = Util.strlist(defaults[k.to_s])
34
+ default = Util.strlist(defaults[k])
34
35
  if opts.key?(k)
35
36
  info[k] = opts[k].nil? || opts[k].empty? ? default : opts[k]
36
- else
37
- info[k] = opts[:interact] ?
37
+ else
38
+ info[k] = opts[:interact] ?
38
39
  info[k] = askd("#{k.to_s.gsub('_', ' ')} (#{p})", default): default
39
40
  end
40
- info[k] = Util.arglist(info[k]) if p == "list"
41
- info.delete(k) unless info[k]
41
+ if k == :autoapprove && (info[k] == "true" || info[k] == "false")
42
+ info[k] = !!(info[k] == "true")
43
+ else
44
+ info[k] = Util.arglist(info[k]) if p == "list"
45
+ info.delete(k) unless info[k]
46
+ end
42
47
  end
43
48
  end
44
49
 
@@ -58,24 +63,26 @@ class ClientCli < CommonCli
58
63
  pp scim_request { |cr|
59
64
  opts[:client_id] = clientname(name)
60
65
  opts[:secret] = verified_pwd("New client secret", opts[:secret])
61
- defaults = opts[:clone] ? cr.get(opts[:clone]) : {}
62
- defaults.delete("client_id")
66
+ defaults = opts[:clone] ? Util.hash_keys!(cr.get(opts[:clone]), :tosym) : {}
67
+ defaults.delete(:client_id)
63
68
  cr.add(:client, client_info(defaults))
64
69
  }
65
70
  end
66
71
 
67
- desc "client update [name]", "Update client registration", *CLIENT_SCHEMA.keys,
72
+ desc "client update [name]", "Update client registration", *CLIENT_SCHEMA.keys,
68
73
  :del_attrs, :interact do |name|
69
74
  pp scim_request { |cr|
70
75
  opts[:client_id] = clientname(name)
71
- info = client_info(cr.get(:client, opts[:client_id]))
72
- info.length > 1 ? cr.put(:client, info) : gripe("Nothing to update. Use -i for interactive update.")
76
+ orig = Util.hash_keys!(cr.get(:client, opts[:client_id]), :tosym)
77
+ info = client_info(orig)
78
+ info.any? { |k, v| v != orig[k] } ? cr.put(:client, info) :
79
+ gripe("Nothing to update. Use -i for interactive update.")
73
80
  }
74
81
  end
75
82
 
76
83
  desc "client delete [name]", "Delete client registration" do |name|
77
- pp scim_request { |cr|
78
- cr.delete(:client, clientname(name))
84
+ pp scim_request { |cr|
85
+ cr.delete(:client, clientname(name))
79
86
  "client registration deleted"
80
87
  }
81
88
  end
data/lib/cli/common.rb CHANGED
@@ -51,7 +51,7 @@ class CommonCli < Topic
51
51
 
52
52
  def complain(e)
53
53
  case e
54
- when TargetError then gripe "\n#{e.message}:\n#{JSON.pretty_generate(e.info)}"
54
+ when TargetError then gripe "\n#{e.message}:\n#{Util.json_pretty(e.info)}"
55
55
  when Exception
56
56
  gripe "\n#{e.class}: #{e.message}\n\n"
57
57
  gripe e.backtrace if trace?
data/lib/cli/info.rb CHANGED
@@ -37,7 +37,9 @@ class InfoCli < CommonCli
37
37
  desc "signing key", "get the UAA's token signing key(s)", :client, :secret do
38
38
  info = misc_request { Misc.validation_key(Config.target,
39
39
  (clientname if opts.key?(:client)), (clientsecret if opts.key?(:client))) }
40
- Config.target_opts(signing_alg: info['alg'], signing_key: info['value'])
40
+ if info && info['value']
41
+ Config.target_opts(signing_alg: info['alg'], signing_key: info['value'])
42
+ end
41
43
  pp info
42
44
  end
43
45
 
data/lib/cli/token.rb CHANGED
@@ -30,7 +30,7 @@ class TokenCatcher < Stub::Base
30
30
  server.info.update(Util.hash_keys!(tkn.info, :tosym))
31
31
  reply.text "you are now logged in and can close this window"
32
32
  rescue TargetError => e
33
- reply.text "#{e.message}:\r\n#{JSON.pretty_generate(e.info)}\r\n#{e.backtrace}"
33
+ reply.text "#{e.message}:\r\n#{Util.json_pretty(e.info)}\r\n#{e.backtrace}"
34
34
  rescue Exception => e
35
35
  reply.text "#{e.message}\r\n#{e.backtrace}"
36
36
  ensure
data/lib/cli/version.rb CHANGED
@@ -13,6 +13,6 @@
13
13
 
14
14
  module CF
15
15
  module UAA
16
- CLI_VERSION = "1.3.0"
16
+ CLI_VERSION = "1.3.1"
17
17
  end
18
18
  end
data/spec/http_spec.rb CHANGED
@@ -28,6 +28,7 @@ end
28
28
 
29
29
  class HttpClient
30
30
  include Http
31
+ def get(target, path = nil, headers = {}) http_get(target, path, headers) end
31
32
  end
32
33
 
33
34
  describe Http do
@@ -91,21 +92,21 @@ describe Http do
91
92
  # to just make the domain name invalid with tildes, but this may not test
92
93
  # the desired code paths
93
94
  it "fails cleanly for a failed dns lookup" do
94
- result = frequest(@on_fiber) { @client.http_get("http://bad~host~name/") }
95
+ result = frequest(@on_fiber) { @client.get("http://bad~host~name/") }
95
96
  result.should be_an_instance_of BadTarget
96
97
  end
97
98
 
98
99
  it "fails cleanly for a get operation, no connection to address" do
99
- result = frequest(@on_fiber) { @client.http_get("http://127.0.0.1:30000/") }
100
+ result = frequest(@on_fiber) { @client.get("http://127.0.0.1:30000/") }
100
101
  result.should be_an_instance_of BadTarget
101
102
  end
102
103
 
103
104
  it "fails cleanly for a get operation with bad response" do
104
- frequest(@on_fiber) { @client.http_get(@stub_http.url, "/bad") }.should be_an_instance_of HTTPException
105
+ frequest(@on_fiber) { @client.get(@stub_http.url, "/bad") }.should be_an_instance_of HTTPException
105
106
  end
106
107
 
107
108
  it "works for a get operation to a valid address" do
108
- status, body, headers = frequest(@on_fiber) { @client.http_get(@stub_http.url, "/") }
109
+ status, body, headers = frequest(@on_fiber) { @client.get(@stub_http.url, "/") }
109
110
  status.should == 200
110
111
  body.should match /welcome to stub http/
111
112
  end
@@ -118,14 +119,14 @@ describe Http do
118
119
  end
119
120
  @client.logger = clog = CustomLogger.new
120
121
  clog.log.should be_empty
121
- frequest(@on_fiber) { @client.http_get(@stub_http.url, "/") }
122
+ frequest(@on_fiber) { @client.get(@stub_http.url, "/") }
122
123
  clog.log.should_not be_empty
123
124
  end
124
125
  end
125
126
 
126
127
  context "on a fiber" do
127
128
  before :all do
128
- @on_fiber = true
129
+ @on_fiber = true
129
130
  @client = HttpClient.new
130
131
  @client.set_request_handler do |url, method, body, headers|
131
132
  f = Fiber.current
@@ -154,7 +155,7 @@ describe Http do
154
155
 
155
156
  context "on a thread" do
156
157
  before :all do
157
- @on_fiber = false
158
+ @on_fiber = false
158
159
  @client = HttpClient.new
159
160
  end
160
161
  it_should_behave_like "http client"
data/spec/token_spec.rb CHANGED
@@ -51,7 +51,7 @@ describe TokenCli do
51
51
  Cli.output.string.should include(a)
52
52
  end
53
53
  Cli.output.string.should include("email: sam@example.com")
54
- #Cli.output.string.should include("user_name: #{@test_user}")
54
+ Cli.output.string.should include("user_name: #{@test_user}")
55
55
  end
56
56
 
57
57
  it "gets authenticated user information" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cf-uaac
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2012-12-05 00:00:00.000000000 Z
16
+ date: 2012-12-09 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: bundler
@@ -111,22 +111,6 @@ dependencies:
111
111
  - - ! '>='
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
- - !ruby/object:Gem::Dependency
115
- name: highline
116
- requirement: !ruby/object:Gem::Requirement
117
- none: false
118
- requirements:
119
- - - ! '>='
120
- - !ruby/object:Gem::Version
121
- version: '0'
122
- type: :runtime
123
- prerelease: false
124
- version_requirements: !ruby/object:Gem::Requirement
125
- none: false
126
- requirements:
127
- - - ! '>='
128
- - !ruby/object:Gem::Version
129
- version: '0'
130
114
  - !ruby/object:Gem::Dependency
131
115
  name: cf-uaa-lib
132
116
  requirement: !ruby/object:Gem::Requirement
@@ -134,7 +118,7 @@ dependencies:
134
118
  requirements:
135
119
  - - ! '>='
136
120
  - !ruby/object:Gem::Version
137
- version: 1.3.0
121
+ version: 1.3.1
138
122
  type: :runtime
139
123
  prerelease: false
140
124
  version_requirements: !ruby/object:Gem::Requirement
@@ -142,9 +126,9 @@ dependencies:
142
126
  requirements:
143
127
  - - ! '>='
144
128
  - !ruby/object:Gem::Version
145
- version: 1.3.0
129
+ version: 1.3.1
146
130
  - !ruby/object:Gem::Dependency
147
- name: multi_json
131
+ name: highline
148
132
  requirement: !ruby/object:Gem::Requirement
149
133
  none: false
150
134
  requirements:
@@ -273,7 +257,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
273
257
  version: '0'
274
258
  segments:
275
259
  - 0
276
- hash: -3878497912978208519
260
+ hash: 3930876394037723232
277
261
  required_rubygems_version: !ruby/object:Gem::Requirement
278
262
  none: false
279
263
  requirements:
@@ -282,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
266
  version: '0'
283
267
  segments:
284
268
  - 0
285
- hash: -3878497912978208519
269
+ hash: 3930876394037723232
286
270
  requirements: []
287
271
  rubyforge_project: cf-uaac
288
272
  rubygems_version: 1.8.21