cf-uaac 1.3.1 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -74,7 +74,7 @@ class StubUAAConn < Stub::Base
74
74
  route :get, '/token_key' do reply_in_kind(alg: "none", value: "none") end
75
75
 
76
76
  route :post, '/password/score', "content-type" => %r{application/x-www-form-urlencoded} do
77
- info = Util.decode_form_to_hash(request.body)
77
+ info = Util.decode_form(request.body)
78
78
  return bad_request "no password to score" unless pwd = info["password"]
79
79
  score = pwd.length > 10 || pwd.length < 0 ? 10 : pwd.length
80
80
  reply_in_kind(score: score, requiredScore: 0)
@@ -110,7 +110,7 @@ class StubUAAConn < Stub::Base
110
110
  end
111
111
 
112
112
  route :post, '/login.do', "content-type" => %r{application/x-www-form-urlencoded} do
113
- creds = Util.decode_form_to_hash(request.body)
113
+ creds = Util.decode_form(request.body)
114
114
  user = find_user(creds['username'], creds['password'])
115
115
  reply.headers[:location] = "login"
116
116
  reply.status = 302
@@ -118,7 +118,7 @@ class StubUAAConn < Stub::Base
118
118
  end
119
119
 
120
120
  route :get, %r{^/logout.do(\?|$)(.*)} do
121
- query = Util.decode_form_to_hash(match[2])
121
+ query = Util.decode_form(match[2])
122
122
  reply.headers[:location] = query['redirect_uri'] || "login"
123
123
  reply.status = 302
124
124
  reply.set_cookie(:stubsession, encode_cookie, max_age: -1)
@@ -140,7 +140,7 @@ class StubUAAConn < Stub::Base
140
140
  token_body[:email] = primary_email(user[:emails])
141
141
  token_body[:user_name] = user[:username]
142
142
  end
143
- info = { access_token: TokenCoder.encode(token_body, nil, nil, 'none'),
143
+ info = { access_token: TokenCoder.encode(token_body, :algorithm => 'none'),
144
144
  token_type: "bearer", expires_in: interval, scope: scope}
145
145
  info[:state] = state if state
146
146
  info[:refresh_token] = "universal_refresh_token" if refresh
@@ -169,14 +169,14 @@ class StubUAAConn < Stub::Base
169
169
  def redir_with_fragment(cburi, params)
170
170
  reply.status = 302
171
171
  uri = URI.parse(cburi)
172
- uri.fragment = URI.encode_www_form(params)
172
+ uri.fragment = Util.encode_form(params)
173
173
  reply.headers[:location] = uri.to_s
174
174
  end
175
175
 
176
176
  def redir_with_query(cburi, params)
177
177
  reply.status = 302
178
178
  uri = URI.parse(cburi)
179
- uri.query = URI.encode_www_form(params)
179
+ uri.query = Util.encode_form(params)
180
180
  reply.headers[:location] = uri.to_s
181
181
  end
182
182
 
@@ -195,7 +195,7 @@ class StubUAAConn < Stub::Base
195
195
  end
196
196
 
197
197
  route [:post, :get], %r{^/oauth/authorize\?(.*)} do
198
- query = Util.decode_form_to_hash(match[1])
198
+ query = Util.decode_form(match[1])
199
199
  client = server.scim.get_by_name(query["client_id"], :client)
200
200
  cburi, state = query["redirect_uri"], query["state"]
201
201
 
@@ -209,7 +209,7 @@ class StubUAAConn < Stub::Base
209
209
  end
210
210
  if request.method == "post"
211
211
  unless request.headers["content-type"] =~ %r{application/x-www-form-urlencoded} &&
212
- (creds = Util.decode_form_to_hash(request.body)) &&
212
+ (creds = Util.decode_form(request.body)) &&
213
213
  creds["source"] && creds["source"] == "credentials"
214
214
  return redir_err_f(cburi, state, "invalid_request")
215
215
  end
@@ -275,7 +275,7 @@ class StubUAAConn < Stub::Base
275
275
  reply.headers[:www_authenticate] = "basic"
276
276
  return reply.json(401, error: "invalid_client")
277
277
  end
278
- return if bad_params?(params = Util.decode_form_to_hash(request.body), ['grant_type'])
278
+ return if bad_params?(params = Util.decode_form(request.body), ['grant_type'])
279
279
  unless client[:authorized_grant_types].include?(params['grant_type'])
280
280
  return reply.json(400, error: "unauthorized_client")
281
281
  end
@@ -419,7 +419,7 @@ class StubUAAConn < Stub::Base
419
419
  route :get, %r{^/(Users|Groups)(\?|$)(.*)} do
420
420
  return unless valid_token("scim.read")
421
421
  rtype = match[1] == "Users"? :user : :group
422
- page_query(rtype, Util.decode_form_to_hash(match[3], :down), StubScim::VISIBLE_ATTRS[rtype])
422
+ page_query(rtype, Util.decode_form(match[3], :down), StubScim::VISIBLE_ATTRS[rtype])
423
423
  end
424
424
 
425
425
  route :get, %r{^/(Users|Groups)/([^/]+)$} do
@@ -449,7 +449,7 @@ class StubUAAConn < Stub::Base
449
449
  end
450
450
 
451
451
  route :get, %r{^/ids/Users(\?|$)(.*)} do
452
- page_query(:user, Util.decode_form_to_hash(match[2], :down), [:username, :id])
452
+ page_query(:user, Util.decode_form(match[2], :down), [:username, :id])
453
453
  end
454
454
 
455
455
  end
@@ -459,7 +459,9 @@ class StubUAA < Stub::Server
459
459
  attr_accessor :reply_badly
460
460
  attr_reader :scim, :auto_groups
461
461
 
462
- def initialize(boot_client = "admin", boot_secret = "adminsecret", logger = Util.default_logger)
462
+ def initialize(options = {})
463
+ client = options[:boot_client] || "admin"
464
+ secret = options[:boot_secret] || "adminsecret"
463
465
  @scim = StubScim.new
464
466
  @auto_groups = ["password.write", "openid"]
465
467
  .each_with_object([]) { |g, o| o << @scim.add(:group, 'displayname' => g) }
@@ -467,16 +469,17 @@ class StubUAA < Stub::Server
467
469
  .each { |g| @scim.add(:group, 'displayname' => g) }
468
470
  gids = ["clients.write", "clients.read", "clients.secret", "uaa.admin"]
469
471
  .each_with_object([]) { |s, o| o << @scim.add(:group, 'displayname' => s) }
470
- @scim.add(:client, 'client_id' => boot_client, 'client_secret' => boot_secret,
472
+ @scim.add(:client, 'client_id' => client, 'client_secret' => secret,
471
473
  'authorized_grant_types' => ["client_credentials"], 'authorities' => gids,
472
474
  'access_token_validity' => 60 * 60 * 24 * 7)
473
475
  @scim.add(:client, 'client_id' => "vmc", 'authorized_grant_types' => ["implicit"],
474
476
  'scope' => [@scim.id("openid", :group), @scim.id("password.write", :group)],
475
477
  'access_token_validity' => 5 * 60 )
476
478
  info = { commit_id: "not implemented",
477
- app: {name: "Stub UAA", version: CLI_VERSION, description: "User Account and Authentication Service, test server"},
479
+ app: {name: "Stub UAA", version: CLI_VERSION,
480
+ description: "User Account and Authentication Service, test server"},
478
481
  prompts: {username: ["text", "Username"], password: ["password","Password"]} }
479
- super(StubUAAConn, logger, info)
482
+ super(StubUAAConn, options.merge(info: info, logger: options[:logger] || Util.default_logger))
480
483
  end
481
484
 
482
485
  end
@@ -23,7 +23,7 @@ describe GroupCli do
23
23
  before :all do
24
24
  #Util.default_logger(:trace)
25
25
  Cli.configure("", nil, StringIO.new, true)
26
- setup_target(authorities: "clients.read,scim.read,scim.write")
26
+ setup_target(authorities: "clients.read,scim.read,scim.write,uaa.admin")
27
27
  Cli.run("token client get #{@test_client} -s #{@test_secret}").should be
28
28
  @test_user, @test_pwd = "sam_#{Time.now.to_i}", "correcthorsebatterystaple"
29
29
  @test_group = "JaNiToRs_#{Time.now.to_i}"
@@ -36,7 +36,8 @@ describe Http do
36
36
  include SpecHelper
37
37
 
38
38
  before :all do
39
- @stub_http = Stub::Server.new(StubHttp, Util.default_logger(:info)).run_on_thread
39
+ #Util.default_logger(:trace)
40
+ @stub_http = Stub::Server.new(StubHttp, logger: Util.default_logger).run_on_thread
40
41
  end
41
42
 
42
43
  after :all do @stub_http.stop if @stub_http end
@@ -147,7 +148,7 @@ describe Http do
147
148
  raise BadTarget, "unable to resolve address" if /unable.*server.*address/.match result[1]
148
149
  raise HTTPException, result[1]
149
150
  end
150
- [result[0], result[1], Util.hash_keys!(result[2], :todash)]
151
+ [result[0], result[1], Util.hash_keys!(result[2], :dash)]
151
152
  end
152
153
  end
153
154
  it_should_behave_like "http client"
@@ -51,14 +51,14 @@ module SpecHelper
51
51
 
52
52
  def setup_target(opts = {})
53
53
  opts = { authorities: "clients.read,scim.read,scim.write,uaa.resource",
54
- grant_types: "client_credentials,password",
54
+ grant_types: "client_credentials,password",
55
55
  scope: "openid,password.write"}.update(opts)
56
56
  @admin_client = ENV["UAA_CLIENT_ID"] || "admin"
57
57
  @admin_secret = ENV["UAA_CLIENT_SECRET"] || "adminsecret"
58
58
  if ENV["UAA_CLIENT_TARGET"]
59
59
  @target, @stub_uaa = ENV["UAA_CLIENT_TARGET"], nil
60
60
  else
61
- @stub_uaa = StubUAA.new(@admin_client, @admin_secret).run_on_thread
61
+ @stub_uaa = StubUAA.new(boot_client: @admin_client, boot_secret: @admin_secret).run_on_thread
62
62
  @target = @stub_uaa.url
63
63
  end
64
64
  Cli.run("target #{@target}").should be
@@ -67,7 +67,7 @@ module SpecHelper
67
67
  test_client = "test_client_#{Time.now.to_i}"
68
68
  @test_secret = "+=tEsTsEcRet~!@"
69
69
  Cli.run("client add #{test_client} -s #{@test_secret} " +
70
- "--authorities #{opts[:authorities]} --scope #{opts[:scope]} " +
70
+ "--authorities #{opts[:authorities]} --scope #{opts[:scope]} " +
71
71
  "--authorized_grant_types #{opts[:grant_types]}").should be
72
72
  opts.each { |k, a| Util.arglist(a).each {|v| Cli.output.string.should include(v) }}
73
73
  @test_client = test_client
@@ -28,7 +28,7 @@ describe TokenCli do
28
28
  Config.yaml.should include("access_token")
29
29
  @test_pwd = "TesTpwd$%^"
30
30
  @test_user = "tEst_UseR+-#{Time.now.to_i}"
31
- Cli.run("user add #{@test_user} -p #{@test_pwd} " +
31
+ Cli.run("user add #{@test_user} -p #{@test_pwd} " +
32
32
  "--emails sam@example.com,joNES@sample.com --given_name SamueL " +
33
33
  "--phones 801-555-1212 --family_name jonES").should be
34
34
  end
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.1
4
+ version: 1.3.3
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-09 00:00:00.000000000 Z
16
+ date: 2012-12-21 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: bundler
@@ -118,7 +118,10 @@ dependencies:
118
118
  requirements:
119
119
  - - ! '>='
120
120
  - !ruby/object:Gem::Version
121
- version: 1.3.1
121
+ version: 1.3.3
122
+ - - <=
123
+ - !ruby/object:Gem::Version
124
+ version: 1.3.3
122
125
  type: :runtime
123
126
  prerelease: false
124
127
  version_requirements: !ruby/object:Gem::Requirement
@@ -126,7 +129,10 @@ dependencies:
126
129
  requirements:
127
130
  - - ! '>='
128
131
  - !ruby/object:Gem::Version
129
- version: 1.3.1
132
+ version: 1.3.3
133
+ - - <=
134
+ - !ruby/object:Gem::Version
135
+ version: 1.3.3
130
136
  - !ruby/object:Gem::Dependency
131
137
  name: highline
132
138
  requirement: !ruby/object:Gem::Requirement
@@ -191,6 +197,22 @@ dependencies:
191
197
  - - ! '>='
192
198
  - !ruby/object:Gem::Version
193
199
  version: 1.0.0.beta.3
200
+ - !ruby/object:Gem::Dependency
201
+ name: json_pure
202
+ requirement: !ruby/object:Gem::Requirement
203
+ none: false
204
+ requirements:
205
+ - - ! '>='
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ type: :runtime
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ none: false
212
+ requirements:
213
+ - - ! '>='
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
194
216
  description: Client command line tools for interacting with the CloudFoundry User
195
217
  Account and Authorization (UAA) server. The UAA is an OAuth2 Authorization Server
196
218
  so it can be used by webapps and command line apps to obtain access tokens to act
@@ -212,7 +234,10 @@ extensions: []
212
234
  extra_rdoc_files: []
213
235
  files:
214
236
  - .gitignore
237
+ - .yardopts
215
238
  - Gemfile
239
+ - LICENSE.TXT
240
+ - NOTICE.TXT
216
241
  - README.md
217
242
  - Rakefile
218
243
  - bin/completion-helper
@@ -257,7 +282,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
257
282
  version: '0'
258
283
  segments:
259
284
  - 0
260
- hash: 3930876394037723232
285
+ hash: 2333184341593208411
261
286
  required_rubygems_version: !ruby/object:Gem::Requirement
262
287
  none: false
263
288
  requirements:
@@ -266,10 +291,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
291
  version: '0'
267
292
  segments:
268
293
  - 0
269
- hash: 3930876394037723232
294
+ hash: 2333184341593208411
270
295
  requirements: []
271
296
  rubyforge_project: cf-uaac
272
- rubygems_version: 1.8.21
297
+ rubygems_version: 1.8.24
273
298
  signing_key:
274
299
  specification_version: 3
275
300
  summary: Command line interface for CloudFoundry UAA