cf-uaac 4.0.0 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cb3a16efbbbd2a3b0bff7ebab805279ace288798
4
- data.tar.gz: 7a64f69585ad57c783213e13be0689caa03352dd
2
+ SHA256:
3
+ metadata.gz: 5166dc3408b2860dd74b3beae7c699a4da045d871f194f379949e8458d207cc5
4
+ data.tar.gz: 0b4fc22bae413905c699f81590b482b5d74b1d6f480f428a02b839f34e60cd90
5
5
  SHA512:
6
- metadata.gz: 6d0e17c6c6e7e1e75c595c7c40bd486941b05ad977437c6468e06647b43170befcb0b9f02b8e44918d37875a39cb65b42fc4782b7905f920b3fdd3d2249c44fa
7
- data.tar.gz: e20e97f7510f41dd00fe7a79e1e231e20a19d9cdb6b20dc56788cecd0d5e6c26cf752e70415e9179a2e888e089786af630877bb8376fdd3769b5cfc6c54f7337
6
+ metadata.gz: b380a1b762644585a61a9218ff83edc4dd50b39e35b3dd15b8deb856edd0b741d82e714c61b5d3f88eb0eaecb650c206ca987c4fc48e95df98f03a703706ad6c
7
+ data.tar.gz: 9d1c5a109a13dcc8642bb4b522d3ef7ee712f84341a98fd3f0f5c50eaf9beabd1bb74fd97eb9000c8a2f5b5d2e3a1ab13338d34c7cfcfa0961e9df80a6ac1c4a
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "11:00"
8
+ open-pull-requests-limit: 10
9
+ allow:
10
+ - dependency-type: direct
11
+ - dependency-type: indirect
@@ -0,0 +1,26 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ ruby-version: ['2.5', '2.7', '3.0', '3.1']
17
+
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25
+ - name: Run tests
26
+ run: bundle exec rake cov
data/bin/uaac CHANGED
@@ -15,4 +15,6 @@
15
15
 
16
16
  $:.unshift File.expand_path File.join __FILE__, '..', '..', 'lib'
17
17
  require 'uaac_cli'
18
- exit CF::UAA::Cli.configure("#{ENV['HOME']}/.uaac.yml").run ? 0 : 1
18
+ home = ENV['UAAC_HOME']
19
+ home = ENV['HOME'] if home.nil? || home.empty?
20
+ exit CF::UAA::Cli.configure("#{home}/.uaac.yml").run ? 0 : 1
data/cf-uaac.gemspec CHANGED
@@ -24,8 +24,6 @@ Gem::Specification.new do |s|
24
24
  s.summary = %q{Command line interface for CloudFoundry UAA}
25
25
  s.description = %q{Client command line tools for interacting with the CloudFoundry User Account and Authorization (UAA) server. The UAA is an OAuth2 Authorization Server so it can be used by webapps and command line apps to obtain access tokens to act on behalf of users. The tokens can then be used to access protected resources in a Resource Server. This library can be used by clients (as a convenient wrapper for mainstream oauth gems) or by resource servers.}
26
26
 
27
- s.rubyforge_project = 'cf-uaac'
28
-
29
27
  s.license = 'Apache-2.0'
30
28
  s.files = `git ls-files`.split("\n")
31
29
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -33,17 +31,17 @@ Gem::Specification.new do |s|
33
31
  s.require_paths = ['lib']
34
32
 
35
33
  # dependencies
36
- s.add_runtime_dependency 'cf-uaa-lib', '~> 3.11'
37
- s.add_development_dependency 'bundler', '~> 1.14'
38
- s.add_development_dependency 'rake', '~> 10.3', '>= 10.3.1'
39
- s.add_development_dependency 'rspec', '~> 2.14', '>= 2.14.1'
40
- s.add_development_dependency 'simplecov', '~> 0.8.2'
34
+ s.add_runtime_dependency 'cf-uaa-lib', '~> 3.14', '> 3.14.3'
35
+ s.add_development_dependency 'rake', '>= 10.3.1', '~> 13.0'
36
+ s.add_development_dependency 'rspec', '>= 2.14.1', '~> 3.9'
37
+ s.add_development_dependency 'simplecov', '~> 0.21.2'
41
38
  s.add_development_dependency 'simplecov-rcov', '~> 0.2.3'
42
- s.add_development_dependency 'ci_reporter', '~> 1.9', '>= 1.9.2'
43
- s.add_runtime_dependency 'highline', '~> 1.6', '>= 1.6.21'
39
+ s.add_development_dependency 'ci_reporter', '>= 1.9.2', '~> 2.0'
40
+ s.add_development_dependency 'ci_reporter_rspec', '~> 1.0'
41
+ s.add_runtime_dependency 'highline', '~> 2.0'
44
42
  s.add_runtime_dependency 'eventmachine', '~> 1.0', '>= 1.0.3'
45
43
  s.add_runtime_dependency 'launchy', '~> 2.4', '>= 2.4.2'
46
44
  s.add_runtime_dependency 'em-http-request', '~> 1.1', '>= 1.1.2'
47
- s.add_runtime_dependency 'json_pure', '~> 1.8', '>= 1.8.1'
48
- s.add_runtime_dependency 'rack', '~> 1.5', '>= 1.5.2'
45
+ s.add_runtime_dependency 'json_pure', '>= 1.8.1', '< 3.0'
46
+ s.add_runtime_dependency 'rack', '>= 1.5.2', '< 3.0'
49
47
  end
@@ -88,11 +88,10 @@ class CommonCli < Topic
88
88
  def scim_common_list(type, filter)
89
89
  pp scim_request { |sr|
90
90
  query = { attributes: opts[:attrs], filter: filter }
91
- info = nil
92
- if type == :user
93
- info = sr.query(type, query.merge!(startIndex: opts[:start], count: opts[:count]))
91
+ info = if type == :user
92
+ sr.query(type, query.merge!(startIndex: opts[:start], count: opts[:count]))
94
93
  else
95
- info = opts[:start] || opts[:count] ?
94
+ opts[:start] || opts[:count] ?
96
95
  sr.query(type, query.merge!(startIndex: opts[:start], count: opts[:count])):
97
96
  sr.all_pages(type, query)
98
97
  end
@@ -109,21 +108,24 @@ class CommonCli < Topic
109
108
  info = scim.all_pages(type, query)
110
109
  raise BadResponse unless info.is_a?(Array)
111
110
  raise NotFound if info.length == 0
112
- if info.length >= 2
111
+ chosen_info = if info.length >= 2
112
+ say 'Select an origin:'
113
113
  info.each_with_index do |i, idx|
114
+ say "#{idx + 1}. #{i['origin']}"
114
115
  end
115
116
 
116
117
  choice = @highline.ask("Select user: ").to_i
117
118
  if choice > info.length || choice <= 0
118
- raise ArgumentError 'bad input, klugscheisser'
119
+ raise ArgumentError.new('bad input')
119
120
  end
120
- info = info[choice - 1]
121
+ info[choice - 1]
121
122
  else
122
- info = info[0]
123
+ info[0]
123
124
  end
124
125
 
126
+
125
127
  # when getting whole object, handle case of UAA < 1.3 which did not return meta attr from query
126
- attrs || !info["id"] || info["meta"] ? info : scim.get(type, info["id"])
128
+ attrs || !chosen_info["id"] || chosen_info["meta"] ? chosen_info : scim.get(type, chosen_info["id"])
127
129
  end
128
130
 
129
131
  def scim_get_object(scim, type, name, attrs = nil)
@@ -46,14 +46,14 @@ class Config
46
46
  exit 1
47
47
  end
48
48
  else # file doesn't exist, make sure we can write it now
49
- File.open(@config_file, 'w') { |f| f.write("--- {}\n\n") }
49
+ self.write_file(@config_file, "--- {}\n\n")
50
50
  end
51
51
  Util.hash_keys!(@config, :sym)
52
52
  @context = current_subhash(@config[@target][:contexts]) if @target = current_subhash(@config)
53
53
  end
54
54
 
55
55
  def self.save
56
- File.open(@config_file, 'w') { |f| YAML.dump(Util.hash_keys(@config, :str), f) } if @config_file
56
+ self.write_file(@config_file, YAML.dump(Util.hash_keys(@config, :str))) if @config_file
57
57
  true
58
58
  end
59
59
 
@@ -134,6 +134,11 @@ class Config
134
134
  # methods below here are not intended to be part of the public interface
135
135
  private
136
136
 
137
+ def self.write_file(filename, content)
138
+ File.open(filename, 'w') { |f| f.write content }
139
+ File.chmod(0600, filename)
140
+ end
141
+
137
142
  def self.current_subhash(hash)
138
143
  return unless hash
139
144
  key = nil
data/lib/uaa/cli/token.rb CHANGED
@@ -88,7 +88,7 @@ class TokenCli < CommonCli
88
88
 
89
89
  def issuer_request(client_id, secret = nil)
90
90
  update_target_info
91
- yield TokenIssuer.new(Config.target.to_s, client_id, secret,
91
+ yield TokenIssuer.new(Config.target.to_s, CGI.escape(client_id), CGI.escape(secret),
92
92
  { token_target: Config.target_value(:token_endpoint),
93
93
  skip_ssl_validation: Config.target_value(:skip_ssl_validation),
94
94
  ssl_ca_file: Config.target_value(:ca_cert) })
@@ -14,6 +14,7 @@
14
14
  # Cloud Foundry namespace
15
15
  module CF
16
16
  module UAA
17
- CLI_VERSION = '4.0.0'
17
+ version_path = File.join( File.dirname(__FILE__), '../../../version.txt' )
18
+ CLI_VERSION = File.read(version_path)
18
19
  end
19
20
  end
data/lib/uaa/stub/uaa.rb CHANGED
@@ -15,6 +15,7 @@ require 'uaa'
15
15
  require 'uaa/stub/server'
16
16
  require 'uaa/stub/scim'
17
17
  require 'uaa/cli/version'
18
+ require 'cgi'
18
19
  require 'pp'
19
20
 
20
21
  module CF::UAA
@@ -168,6 +169,7 @@ class StubUAAConn < Stub::Base
168
169
  ah = basic_auth_header.split(' ')
169
170
  return unless ah[0] =~ /^basic$/i
170
171
  ah = Base64::strict_decode64(ah[1]).split(':')
172
+ ah = ah.map { |item| CGI::unescape(item) }
171
173
  client = server.scim.get_by_name(ah[0], :client)
172
174
  client if client && client[:client_secret] == ah[1]
173
175
  end
@@ -58,8 +58,8 @@ describe ClientCli do
58
58
  end
59
59
 
60
60
  it 'does not wrap the output of the access token in the terminal' do
61
- @output.stub(:tty?) { true }
62
- HighLine::SystemExtensions.stub(:terminal_size) { [80] }
61
+ allow(@output).to receive(:tty?).and_return(true)
62
+ allow(HighLine::Terminal).to receive(:terminal_size).and_return([80, 40])
63
63
  Cli.run('context').should be
64
64
  Cli.output.string.should match /access_token: \S+?\s+token_type/m
65
65
  end
data/spec/spec_helper.rb CHANGED
@@ -26,6 +26,12 @@ require 'rspec'
26
26
  require 'eventmachine'
27
27
  require 'uaa/stub/uaa'
28
28
 
29
+ RSpec.configure do |config|
30
+ config.expect_with :rspec do |expectations|
31
+ expectations.syntax = [:expect, :should]
32
+ end
33
+ end
34
+
29
35
  module CF::UAA
30
36
 
31
37
  module SpecHelper
data/spec/user_spec.rb CHANGED
@@ -69,7 +69,7 @@ describe UserCli do
69
69
  Cli.input = StringIO.new("password") # selecting first origin through stdin
70
70
  Cli.run("user add #{user_with_origin} " +
71
71
  '--emails sam@example.com --given_name SamueL ' +
72
- "--phones 801-555-1212 --family_name jonES --origin uaa").should be
72
+ "--phones 801-555-1212 --family_name jonES --origin uaa")
73
73
 
74
74
  expect(Cli.output.string).to match 'Password:'
75
75
  Cli.run("user delete #{user_with_origin}")
@@ -80,7 +80,7 @@ describe UserCli do
80
80
  Cli.input = StringIO.new("password") # selecting first origin through stdin
81
81
  Cli.run("user add #{user_with_origin} " +
82
82
  '--emails sam@example.com --given_name SamueL ' +
83
- "--phones 801-555-1212 --family_name jonES").should be
83
+ "--phones 801-555-1212 --family_name jonES")
84
84
 
85
85
  expect(Cli.output.string).to match 'Password:'
86
86
  Cli.run("user delete #{user_with_origin}")
data/version.txt ADDED
@@ -0,0 +1 @@
1
+ 4.4.0
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: 4.0.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Syer
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2017-08-24 00:00:00.000000000 Z
15
+ date: 2022-01-14 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: cf-uaa-lib
@@ -20,82 +20,74 @@ dependencies:
20
20
  requirements:
21
21
  - - "~>"
22
22
  - !ruby/object:Gem::Version
23
- version: '3.11'
23
+ version: '3.14'
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.14.3
24
27
  type: :runtime
25
28
  prerelease: false
26
29
  version_requirements: !ruby/object:Gem::Requirement
27
30
  requirements:
28
31
  - - "~>"
29
32
  - !ruby/object:Gem::Version
30
- version: '3.11'
31
- - !ruby/object:Gem::Dependency
32
- name: bundler
33
- requirement: !ruby/object:Gem::Requirement
34
- requirements:
35
- - - "~>"
33
+ version: '3.14'
34
+ - - ">"
36
35
  - !ruby/object:Gem::Version
37
- version: '1.14'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- requirements:
42
- - - "~>"
43
- - !ruby/object:Gem::Version
44
- version: '1.14'
36
+ version: 3.14.3
45
37
  - !ruby/object:Gem::Dependency
46
38
  name: rake
47
39
  requirement: !ruby/object:Gem::Requirement
48
40
  requirements:
49
- - - "~>"
50
- - !ruby/object:Gem::Version
51
- version: '10.3'
52
41
  - - ">="
53
42
  - !ruby/object:Gem::Version
54
43
  version: 10.3.1
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '13.0'
55
47
  type: :development
56
48
  prerelease: false
57
49
  version_requirements: !ruby/object:Gem::Requirement
58
50
  requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '10.3'
62
51
  - - ">="
63
52
  - !ruby/object:Gem::Version
64
53
  version: 10.3.1
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '13.0'
65
57
  - !ruby/object:Gem::Dependency
66
58
  name: rspec
67
59
  requirement: !ruby/object:Gem::Requirement
68
60
  requirements:
69
- - - "~>"
70
- - !ruby/object:Gem::Version
71
- version: '2.14'
72
61
  - - ">="
73
62
  - !ruby/object:Gem::Version
74
63
  version: 2.14.1
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '3.9'
75
67
  type: :development
76
68
  prerelease: false
77
69
  version_requirements: !ruby/object:Gem::Requirement
78
70
  requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '2.14'
82
71
  - - ">="
83
72
  - !ruby/object:Gem::Version
84
73
  version: 2.14.1
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '3.9'
85
77
  - !ruby/object:Gem::Dependency
86
78
  name: simplecov
87
79
  requirement: !ruby/object:Gem::Requirement
88
80
  requirements:
89
81
  - - "~>"
90
82
  - !ruby/object:Gem::Version
91
- version: 0.8.2
83
+ version: 0.21.2
92
84
  type: :development
93
85
  prerelease: false
94
86
  version_requirements: !ruby/object:Gem::Requirement
95
87
  requirements:
96
88
  - - "~>"
97
89
  - !ruby/object:Gem::Version
98
- version: 0.8.2
90
+ version: 0.21.2
99
91
  - !ruby/object:Gem::Dependency
100
92
  name: simplecov-rcov
101
93
  requirement: !ruby/object:Gem::Requirement
@@ -114,42 +106,50 @@ dependencies:
114
106
  name: ci_reporter
115
107
  requirement: !ruby/object:Gem::Requirement
116
108
  requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: 1.9.2
117
112
  - - "~>"
118
113
  - !ruby/object:Gem::Version
119
- version: '1.9'
114
+ version: '2.0'
115
+ type: :development
116
+ prerelease: false
117
+ version_requirements: !ruby/object:Gem::Requirement
118
+ requirements:
120
119
  - - ">="
121
120
  - !ruby/object:Gem::Version
122
121
  version: 1.9.2
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: ci_reporter_rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.0'
123
132
  type: :development
124
133
  prerelease: false
125
134
  version_requirements: !ruby/object:Gem::Requirement
126
135
  requirements:
127
136
  - - "~>"
128
137
  - !ruby/object:Gem::Version
129
- version: '1.9'
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: 1.9.2
138
+ version: '1.0'
133
139
  - !ruby/object:Gem::Dependency
134
140
  name: highline
135
141
  requirement: !ruby/object:Gem::Requirement
136
142
  requirements:
137
143
  - - "~>"
138
144
  - !ruby/object:Gem::Version
139
- version: '1.6'
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- version: 1.6.21
145
+ version: '2.0'
143
146
  type: :runtime
144
147
  prerelease: false
145
148
  version_requirements: !ruby/object:Gem::Requirement
146
149
  requirements:
147
150
  - - "~>"
148
151
  - !ruby/object:Gem::Version
149
- version: '1.6'
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: 1.6.21
152
+ version: '2.0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: eventmachine
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -214,42 +214,42 @@ dependencies:
214
214
  name: json_pure
215
215
  requirement: !ruby/object:Gem::Requirement
216
216
  requirements:
217
- - - "~>"
218
- - !ruby/object:Gem::Version
219
- version: '1.8'
220
217
  - - ">="
221
218
  - !ruby/object:Gem::Version
222
219
  version: 1.8.1
220
+ - - "<"
221
+ - !ruby/object:Gem::Version
222
+ version: '3.0'
223
223
  type: :runtime
224
224
  prerelease: false
225
225
  version_requirements: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - "~>"
228
- - !ruby/object:Gem::Version
229
- version: '1.8'
230
227
  - - ">="
231
228
  - !ruby/object:Gem::Version
232
229
  version: 1.8.1
230
+ - - "<"
231
+ - !ruby/object:Gem::Version
232
+ version: '3.0'
233
233
  - !ruby/object:Gem::Dependency
234
234
  name: rack
235
235
  requirement: !ruby/object:Gem::Requirement
236
236
  requirements:
237
- - - "~>"
238
- - !ruby/object:Gem::Version
239
- version: '1.5'
240
237
  - - ">="
241
238
  - !ruby/object:Gem::Version
242
239
  version: 1.5.2
240
+ - - "<"
241
+ - !ruby/object:Gem::Version
242
+ version: '3.0'
243
243
  type: :runtime
244
244
  prerelease: false
245
245
  version_requirements: !ruby/object:Gem::Requirement
246
246
  requirements:
247
- - - "~>"
248
- - !ruby/object:Gem::Version
249
- version: '1.5'
250
247
  - - ">="
251
248
  - !ruby/object:Gem::Version
252
249
  version: 1.5.2
250
+ - - "<"
251
+ - !ruby/object:Gem::Version
252
+ version: '3.0'
253
253
  description: Client command line tools for interacting with the CloudFoundry User
254
254
  Account and Authorization (UAA) server. The UAA is an OAuth2 Authorization Server
255
255
  so it can be used by webapps and command line apps to obtain access tokens to act
@@ -270,8 +270,9 @@ executables:
270
270
  extensions: []
271
271
  extra_rdoc_files: []
272
272
  files:
273
+ - ".github/dependabot.yml"
274
+ - ".github/workflows/ruby.yml"
273
275
  - ".gitignore"
274
- - ".travis.yml"
275
276
  - ".yardopts"
276
277
  - Gemfile
277
278
  - LICENSE
@@ -311,6 +312,7 @@ files:
311
312
  - spec/ssl_integration_spec.rb
312
313
  - spec/token_spec.rb
313
314
  - spec/user_spec.rb
315
+ - version.txt
314
316
  homepage: https://github.com/cloudfoundry/cf-uaac
315
317
  licenses:
316
318
  - Apache-2.0
@@ -330,20 +332,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
330
332
  - !ruby/object:Gem::Version
331
333
  version: '0'
332
334
  requirements: []
333
- rubyforge_project: cf-uaac
334
- rubygems_version: 2.6.11
335
+ rubygems_version: 3.1.6
335
336
  signing_key:
336
337
  specification_version: 4
337
338
  summary: Command line interface for CloudFoundry UAA
338
- test_files:
339
- - spec/client_reg_spec.rb
340
- - spec/common_spec.rb
341
- - spec/curl_spec.rb
342
- - spec/group_spec.rb
343
- - spec/http_spec.rb
344
- - spec/info_spec.rb
345
- - spec/setup_helper.rb
346
- - spec/spec_helper.rb
347
- - spec/ssl_integration_spec.rb
348
- - spec/token_spec.rb
349
- - spec/user_spec.rb
339
+ test_files: []
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- language: ruby
2
-
3
- before_install:
4
- - gem update
5
- - gem install bundler
6
-
7
- rvm:
8
- - 2.2.7
9
- - 2.3.4
10
- - 2.4.1