cf-uaac 1.3.6 → 1.3.8

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/cf-uaac.gemspec CHANGED
@@ -38,7 +38,7 @@ 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.6", "<= 1.3.6"
41
+ s.add_runtime_dependency "cf-uaa-lib", ">= 1.3.6", "<= 1.3.7"
42
42
  s.add_runtime_dependency "highline"
43
43
  s.add_runtime_dependency "eventmachine"
44
44
  s.add_runtime_dependency "launchy"
data/lib/cli/base.rb CHANGED
@@ -240,7 +240,7 @@ class BaseCli
240
240
  @input ||= $stdin
241
241
  @output ||= $stdout
242
242
  @output.string = "" if @output.respond_to?(:string)
243
- args = args.split if args.respond_to?(:split)
243
+ args = Shellwords.split(args) if args.respond_to?(:split)
244
244
  @option_defs, @parser, orig = {}, OptionParser.new, args
245
245
  opts = @topics.each_with_object({}) do |tpc, o|
246
246
  tpc.option_defs.each do |k, optdef|
@@ -94,7 +94,7 @@ class ClientCli < CommonCli
94
94
  }
95
95
  end
96
96
 
97
- define_option :old_secret, "-o", "--old_secret <secret>", "current secret"
97
+ define_option :old_secret, "--old_secret <secret>", "current secret"
98
98
  desc "secret change", "Change secret for authenticated client in current context", :old_secret, :secret do
99
99
  return gripe "context not set" unless client_id = Config.context.to_s
100
100
  scim_request { |cr|
data/lib/cli/token.rb CHANGED
@@ -27,7 +27,7 @@ class TokenCatcher < Stub::Base
27
27
  token_target: Config.target_value(:token_target))
28
28
  tkn = secret ? ti.authcode_grant(server.info.delete(:uri), data) :
29
29
  ti.implicit_grant(server.info.delete(:uri), data)
30
- server.info.update(Util.hash_keys!(tkn.info, :sym))
30
+ server.info.update(token_info: tkn.info)
31
31
  reply.text "you are now logged in and can close this window"
32
32
  rescue TargetError => e
33
33
  reply.text "#{e.message}:\r\n#{Util.json_pretty(e.info)}\r\n#{e.backtrace}"
@@ -151,11 +151,11 @@ class TokenCli < CommonCli
151
151
  say "launching browser with #{uri}" if trace?
152
152
  Launchy.open(uri, debug: true, dry_run: false)
153
153
  print "waiting for token "
154
- while catcher.info[:uri] || !catcher.info[:access_token]
154
+ while catcher.info[:uri] || !catcher.info[:token_info]
155
155
  sleep 5
156
156
  print "."
157
157
  end
158
- say_success(secret ? "authorization code" : "implicit") if set_context(catcher.info)
158
+ say_success(secret ? "authorization code" : "implicit") if set_context(catcher.info[:token_info])
159
159
  return unless opts[:vmc]
160
160
  begin
161
161
  vmc_target = File.open(VMC_TARGET_FILE, 'r') { |f| f.read.strip }
data/lib/cli/version.rb CHANGED
@@ -14,6 +14,6 @@
14
14
  # Cloud Foundry namespace
15
15
  module CF
16
16
  module UAA
17
- CLI_VERSION = "1.3.6"
17
+ CLI_VERSION = "1.3.8"
18
18
  end
19
19
  end
data/lib/stub/uaa.rb CHANGED
@@ -366,15 +366,16 @@ class StubUAAConn < Stub::Base
366
366
 
367
367
  route :put, %r{^/oauth/clients/([^/]+)/secret$}, "content-type" => %r{application/json} do
368
368
  info = Util.json_parse(request.body, :down)
369
+ return not_found(match[1]) unless id = server.scim.id(match[1], :client)
370
+ return bad_request("no new secret given") unless info['secret']
369
371
  if oldsecret = info['oldsecret']
370
372
  return unless valid_token("clients.secret")
371
- return not_found(match[1]) unless client = server.scim.get(match[1], :client, :client_secret)
373
+ return not_found(match[1]) unless client = server.scim.get(id, :client, :client_secret)
372
374
  return bad_request("old secret does not match") unless oldsecret == client[:client_secret]
373
375
  else
374
376
  return unless valid_token("uaa.admin")
375
377
  end
376
- return bad_request("no new secret given") unless info['secret']
377
- server.scim.set_hidden_attr(match[1], :client_secret, info['secret'])
378
+ server.scim.set_hidden_attr(id, :client_secret, info['secret'])
378
379
  reply.json(status: "ok", message: "secret updated")
379
380
  end
380
381
 
@@ -23,7 +23,7 @@ describe ClientCli do
23
23
  before :all do
24
24
  #Util.default_logger(:trace)
25
25
  Cli.configure("", nil, StringIO.new, true)
26
- setup_target(authorities: "scim.read", grant_types: "client_credentials")
26
+ setup_target(authorities: "scim.read,clients.secret", grant_types: "client_credentials")
27
27
  @test_user, @test_pwd = "sam_#{Time.now.to_i}", "correcthorsebatterystaple"
28
28
  end
29
29
 
@@ -54,6 +54,15 @@ describe ClientCli do
54
54
  Cli.output.string.should include "access_token", @test_client
55
55
  end
56
56
 
57
+ it "changes it's client secret" do
58
+ Cli.run("token client get #{@test_client} -s #{@test_secret}").should be
59
+ Cli.run("token decode").should be
60
+ Cli.run("secret change --old_secret #{@test_secret} --secret newclientsecret").should be
61
+ Cli.run("token client get #{@test_client} -s newclientsecret").should be
62
+ Cli.run("secret change --old_secret newclientsecret -s #{@test_secret}").should be
63
+ Cli.run("token client get #{@test_client} -s #{@test_secret}").should be
64
+ end
65
+
57
66
  it "fails to create a user account as test client" do
58
67
  Cli.run("user add #{@test_user} -p #{@test_pwd}").should be_nil
59
68
  Cli.output.string.should include "access_denied"
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #--
4
+ # Cloud Foundry 2012.02.03 Beta
5
+ # Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved.
6
+ #
7
+ # This product is licensed to you under the Apache License, Version 2.0 (the "License").
8
+ # You may not use this product except in compliance with the License.
9
+ #
10
+ # This product includes a number of subcomponents with
11
+ # separate copyright notices and license terms. Your use of these
12
+ # subcomponents is subject to the terms and conditions of the
13
+ # subcomponent's license, as noted in the LICENSE file.
14
+ #++
15
+
16
+ $:.unshift File.expand_path File.join __FILE__, '..', '..', 'lib'
17
+ require 'cli'
18
+
19
+ client = ENV["UAA_CLIENT_ID"] || "admin"
20
+ secret = ENV["UAA_CLIENT_SECRET"] || "adminsecret"
21
+ abort("UAA_CLIENT_TARGET is not set") unless target = ENV["UAA_CLIENT_TARGET"]
22
+
23
+ [
24
+ "target #{target}",
25
+ "token client get #{client} -s #{secret}",
26
+ "client update #{client} --authorities scim.read,scim.write,clients.read,clients.write,clients.secret,scim.password,uaa.admin,uaa.resource",
27
+ "token client get #{client} -s #{secret}",
28
+ "client -t add clapp -s clapp --scope scim.me,scim.read,openid,password.write --authorized_grant_types password,refresh_token,authorization_code --autoapprove true",
29
+ "user add joe -p joe --email joe@email.com",
30
+ ].each { |cmd| abort("'#{cmd}' failed") unless CF::UAA::Cli.run(cmd) }
31
+
data/spec/spec_helper.rb CHANGED
@@ -65,7 +65,7 @@ module SpecHelper
65
65
  Cli.run("token client get #{@admin_client} -s #{@admin_secret}")
66
66
  Config.yaml.should include("access_token")
67
67
  test_client = "test_client_#{Time.now.to_i}"
68
- @test_secret = "+=tEsTsEcRet~!@"
68
+ @test_secret = Shellwords.escape("+=tEsTsEcRet~!@--")
69
69
  Cli.run("client add #{test_client} -s #{@test_secret} " +
70
70
  "--authorities #{opts[:authorities]} --scope #{opts[:scope]} " +
71
71
  "--authorized_grant_types #{opts[:grant_types]} " +
data/spec/token_spec.rb CHANGED
@@ -26,7 +26,7 @@ describe TokenCli do
26
26
  setup_target(authorities: "clients.read,scim.read,scim.write,uaa.resource")
27
27
  Cli.run("token client get #{@test_client} -s #{@test_secret}").should be
28
28
  Config.yaml.should include("access_token")
29
- @test_pwd = "@~`!$@%#%^$^&*)(|}{[]\":';?><,./"
29
+ @test_pwd = Shellwords.escape("@~`!$@%#%^$^&*)(|}{[]\":';?><,./")
30
30
  @test_user = "test_user_#{Time.now.to_i}"
31
31
  Cli.run("user add #{@test_user} -p #{@test_pwd} " +
32
32
  "--emails sam@example.com,joNES@sample.com --given_name SamueL " +
data/spec/user_spec.rb CHANGED
@@ -48,8 +48,10 @@ describe UserCli do
48
48
 
49
49
  it "changes a user's password" do
50
50
  Cli.run("token get #{@test_user} #{@test_pwd}").should be
51
- Cli.run("password change -p newpwd --old_password #{@test_pwd}").should be
51
+ Cli.run("password change --password newpwd --old_password #{@test_pwd}").should be
52
52
  Cli.run("token get #{@test_user} newpwd").should be
53
+ Cli.run("password change -p #{@test_pwd} -o newpwd").should be
54
+ Cli.run("token get #{@test_user} #{@test_pwd}").should be
53
55
  Cli.output.string.should include "Successfully fetched token"
54
56
  end
55
57
 
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.6
4
+ version: 1.3.8
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: 2013-01-29 00:00:00.000000000 Z
16
+ date: 2013-01-30 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: bundler
@@ -121,7 +121,7 @@ dependencies:
121
121
  version: 1.3.6
122
122
  - - <=
123
123
  - !ruby/object:Gem::Version
124
- version: 1.3.6
124
+ version: 1.3.7
125
125
  type: :runtime
126
126
  prerelease: false
127
127
  version_requirements: !ruby/object:Gem::Requirement
@@ -132,7 +132,7 @@ dependencies:
132
132
  version: 1.3.6
133
133
  - - <=
134
134
  - !ruby/object:Gem::Version
135
- version: 1.3.6
135
+ version: 1.3.7
136
136
  - !ruby/object:Gem::Dependency
137
137
  name: highline
138
138
  requirement: !ruby/object:Gem::Requirement
@@ -265,6 +265,7 @@ files:
265
265
  - spec/group_spec.rb
266
266
  - spec/http_spec.rb
267
267
  - spec/info_spec.rb
268
+ - spec/setup_helper.rb
268
269
  - spec/spec_helper.rb
269
270
  - spec/token_spec.rb
270
271
  - spec/user_spec.rb
@@ -282,7 +283,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
282
283
  version: '0'
283
284
  segments:
284
285
  - 0
285
- hash: 4530157202147700966
286
+ hash: 1602838962021256721
286
287
  required_rubygems_version: !ruby/object:Gem::Requirement
287
288
  none: false
288
289
  requirements:
@@ -291,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
292
  version: '0'
292
293
  segments:
293
294
  - 0
294
- hash: 4530157202147700966
295
+ hash: 1602838962021256721
295
296
  requirements: []
296
297
  rubyforge_project: cf-uaac
297
298
  rubygems_version: 1.8.23