Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

doc update, support autoapprove scopes in clients

Change-Id: I2565439427af69a643ae4a0335c32553da0d90bd
  • Loading branch information...
commit d2f925009b89b42eda3837b42a4c252f9f577f26 1 parent 8c99c30
@daleolds daleolds authored
View
44 README.md
@@ -1,32 +1,24 @@
# CloudFoundry UAA Command Line Client
-Command line gem for interacting with the CloudFoundry UAA server.
+## Build the gem
-Set up a local ruby environment (so sudo not required):
+ $ bundle install
+ $ gem build cf-uaac.gemspec
- `$ rvm use 1.9.2`
+## Install it
-or
+ $ gem install cf-uaac*.gem
- `$ rbenv global 1.9.2-p180`
+or from rubygems
-see: https://rvm.io/ or http://rbenv.org/
+ $ gem install cf-uaac
-Build the gem
+## Run it
- `$ bundle install`
- `$ gem build cf-uaac.gemspec`
-
-Install it
-
- `$ gem install cf-uaac*.gem`
-
-Run it
-
- `$ uaac help`
- `$ uaac target uaa.cloudfoundry.com`
- `$ uaac token get <your-cf-username>`
- `$ uaac token decode`
+ $ uaac help
+ $ uaac target uaa.cloudfoundry.com
+ $ uaac token get <your-cf-username>
+ $ uaac token decode
To use the APIs, see: https://github.com/cloudfoundry/cf-uaa-lib
@@ -34,15 +26,15 @@ To use the APIs, see: https://github.com/cloudfoundry/cf-uaa-lib
Run the tests with rake:
- `$ bundle exec rake test`
+ $ bundle exec rake test
Run the tests and see a fancy coverage report:
- `$ bundle exec rake cov`
+ $ bundle exec rake cov
Run integration tests (on a server running on localhost:8080/uaa):
- `$ export UAA_CLIENT_ID="admin"`
- `$ export UAA_CLIENT_SECRET="adminsecret"`
- `$ export UAA_CLIENT_TARGET="http://localhost:8080/uaa"`
- `$ bundle exec rspec spec/integration_spec.rb`
+ $ export UAA_CLIENT_ID="admin"
+ $ export UAA_CLIENT_SECRET="adminsecret"
+ $ export UAA_CLIENT_TARGET="http://localhost:8080/uaa"
+ $ bundle exec rspec spec/integration_spec.rb
View
3  cf-uaac.gemspec
@@ -38,9 +38,8 @@ Gem::Specification.new do |s|
s.add_development_dependency "simplecov"
s.add_development_dependency "simplecov-rcov"
s.add_development_dependency "ci_reporter"
+ s.add_runtime_dependency "cf-uaa-lib", ">= 1.3.1"
s.add_runtime_dependency "highline"
- s.add_runtime_dependency "cf-uaa-lib", ">= 1.3.0"
- s.add_runtime_dependency "multi_json"
s.add_runtime_dependency "eventmachine"
s.add_runtime_dependency "launchy"
s.add_runtime_dependency "em-http-request", ">= 1.0.0.beta.3"
View
39 lib/cli/client_reg.rb
@@ -19,26 +19,31 @@ class ClientCli < CommonCli
topic "Client Application Registrations", "reg"
- CLIENT_SCHEMA = { scope: "list", authorized_grant_types: "list",
- authorities: "list", access_token_validity: "seconds",
- refresh_token_validity: "seconds", redirect_uri: "list" }
+ CLIENT_SCHEMA = { scope: "list", authorized_grant_types: "list",
+ authorities: "list", access_token_validity: "seconds",
+ refresh_token_validity: "seconds", redirect_uri: "list",
+ autoapprove: "list" }
CLIENT_SCHEMA.each { |k, v| define_option(k, "--#{k} <#{v}>") }
def client_info(defaults)
- info = {client_id: defaults["client_id"] || opts[:client_id]}
+ info = {client_id: defaults[:client_id] || opts[:client_id]}
info[:client_secret] = opts[:secret] if opts[:secret]
del_attrs = Util.arglist(opts[:del_attrs], [])
CLIENT_SCHEMA.each_with_object(info) do |(k, p), info|
next if del_attrs.include?(k)
- default = Util.strlist(defaults[k.to_s])
+ default = Util.strlist(defaults[k])
if opts.key?(k)
info[k] = opts[k].nil? || opts[k].empty? ? default : opts[k]
- else
- info[k] = opts[:interact] ?
+ else
+ info[k] = opts[:interact] ?
info[k] = askd("#{k.to_s.gsub('_', ' ')} (#{p})", default): default
end
- info[k] = Util.arglist(info[k]) if p == "list"
- info.delete(k) unless info[k]
+ if k == :autoapprove && (info[k] == "true" || info[k] == "false")
+ info[k] = !!(info[k] == "true")
+ else
+ info[k] = Util.arglist(info[k]) if p == "list"
+ info.delete(k) unless info[k]
+ end
end
end
@@ -58,24 +63,26 @@ def client_info(defaults)
pp scim_request { |cr|
opts[:client_id] = clientname(name)
opts[:secret] = verified_pwd("New client secret", opts[:secret])
- defaults = opts[:clone] ? cr.get(opts[:clone]) : {}
- defaults.delete("client_id")
+ defaults = opts[:clone] ? Util.hash_keys!(cr.get(opts[:clone]), :tosym) : {}
+ defaults.delete(:client_id)
cr.add(:client, client_info(defaults))
}
end
- desc "client update [name]", "Update client registration", *CLIENT_SCHEMA.keys,
+ desc "client update [name]", "Update client registration", *CLIENT_SCHEMA.keys,
:del_attrs, :interact do |name|
pp scim_request { |cr|
opts[:client_id] = clientname(name)
- info = client_info(cr.get(:client, opts[:client_id]))
- info.length > 1 ? cr.put(:client, info) : gripe("Nothing to update. Use -i for interactive update.")
+ orig = Util.hash_keys!(cr.get(:client, opts[:client_id]), :tosym)
+ info = client_info(orig)
+ info.any? { |k, v| v != orig[k] } ? cr.put(:client, info) :
+ gripe("Nothing to update. Use -i for interactive update.")
}
end
desc "client delete [name]", "Delete client registration" do |name|
- pp scim_request { |cr|
- cr.delete(:client, clientname(name))
+ pp scim_request { |cr|
+ cr.delete(:client, clientname(name))
"client registration deleted"
}
end
View
2  lib/cli/common.rb
@@ -51,7 +51,7 @@ def askd(prompt, defary)
def complain(e)
case e
- when TargetError then gripe "\n#{e.message}:\n#{JSON.pretty_generate(e.info)}"
+ when TargetError then gripe "\n#{e.message}:\n#{Util.json_pretty(e.info)}"
when Exception
gripe "\n#{e.class}: #{e.message}\n\n"
gripe e.backtrace if trace?
View
4 lib/cli/info.rb
@@ -37,7 +37,9 @@ def misc_request(&blk) Config.target ? handle_request(&blk) : gripe("target not
desc "signing key", "get the UAA's token signing key(s)", :client, :secret do
info = misc_request { Misc.validation_key(Config.target,
(clientname if opts.key?(:client)), (clientsecret if opts.key?(:client))) }
- Config.target_opts(signing_alg: info['alg'], signing_key: info['value'])
+ if info && info['value']
+ Config.target_opts(signing_alg: info['alg'], signing_key: info['value'])
+ end
pp info
end
View
2  lib/cli/token.rb
@@ -30,7 +30,7 @@ def process_grant(data)
server.info.update(Util.hash_keys!(tkn.info, :tosym))
reply.text "you are now logged in and can close this window"
rescue TargetError => e
- reply.text "#{e.message}:\r\n#{JSON.pretty_generate(e.info)}\r\n#{e.backtrace}"
+ reply.text "#{e.message}:\r\n#{Util.json_pretty(e.info)}\r\n#{e.backtrace}"
rescue Exception => e
reply.text "#{e.message}\r\n#{e.backtrace}"
ensure
View
2  lib/cli/version.rb
@@ -13,6 +13,6 @@
module CF
module UAA
- CLI_VERSION = "1.3.0"
+ CLI_VERSION = "1.3.1"
end
end
View
2  spec/token_spec.rb
@@ -51,7 +51,7 @@ module CF::UAA
Cli.output.string.should include(a)
end
Cli.output.string.should include("email: sam@example.com")
- #Cli.output.string.should include("user_name: #{@test_user}")
+ Cli.output.string.should include("user_name: #{@test_user}")
end
it "gets authenticated user information" do
Please sign in to comment.
Something went wrong with that request. Please try again.