conjur-cli 4.19.0 → 4.20.1

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
2
  SHA1:
3
- metadata.gz: 88cb451c93417c3943171c8948b0b8fca26e9faf
4
- data.tar.gz: fec1d704173532741c53bfe76b81dd71286fe8d7
3
+ metadata.gz: 54829e90e9f47497bd87c30bdaa35c6004a91d64
4
+ data.tar.gz: b468b645050ddf11e00e2c111e87fc32dd9d2945
5
5
  SHA512:
6
- metadata.gz: bdb26d0ec021d83bcdbcf176a6899584b0db21a010c841b3416ab58e3d105a3f89d3ce6591563d6d3869543cb5c58cb3716a0561277e35a72facfb02ecbac86e
7
- data.tar.gz: a99ecb30867ea4090bc660b6836dc7ff19a95ddc2517fe20aafb7502f25c8dc481d8640dc5f0d59f1033b3414ce7b21b2b2a6f49a211da37dc9e702e8872c318
6
+ metadata.gz: e6750225d94caf197718145f90077f86b3e50dde0c8d8ba49d7e63db7cdb3fa3adf72c72eef3615a722a64486e1ce72aa5669fb820c56be0065abc4adac30d78
7
+ data.tar.gz: d1758ad2e32ed4a5161435edd98100399c466c85bfcff273c735fef1ec67a0ec889d5156ac184e0f555666d886912714f09171799be5be887ecda4009a1ebde6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 4.20.1
2
+
3
+ * Improve the error reporting
4
+
5
+ # 4.20.0
6
+
7
+ * GID manipulation commands
8
+
1
9
  # 4.19.0
2
10
 
3
11
  * Add command `conjur role graph` for batch retrieval of role relationships
data/Rakefile CHANGED
@@ -16,6 +16,7 @@ task :jenkins => ['ci:setup:rspec', :spec, 'ci:setup:cucumber_report_cleanup'] d
16
16
  File.write('build_number', ENV['BUILD_NUMBER']) if ENV['BUILD_NUMBER']
17
17
  end
18
18
 
19
+ desc "Generate the update completions file"
19
20
  task :completions do
20
21
  # having 'lib' in the load path, which happens to be the case when running rake,
21
22
  # messes up GLIs commands_from
@@ -27,6 +27,8 @@
27
27
  :create: true
28
28
  :list: true
29
29
  :show: true
30
+ :update: true
31
+ :gidsearch: true
30
32
  :retire: true
31
33
  :members:
32
34
  :list: true
@@ -80,6 +82,7 @@
80
82
  :members: true
81
83
  :grant_to: true
82
84
  :revoke_from: true
85
+ :graph: true
83
86
  :script:
84
87
  :execute: true
85
88
  :secret:
data/conjur.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
 
18
18
 
19
19
  gem.add_dependency 'activesupport'
20
- gem.add_dependency 'conjur-api', '~> 4.12.0'
20
+ gem.add_dependency 'conjur-api', '~> 4.13.0'
21
21
  gem.add_dependency 'gli', '>=2.8.0'
22
22
  gem.add_dependency 'highline'
23
23
  gem.add_dependency 'netrc', '~> 0.10.2'
data/lib/conjur/cli.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (C) 2013 Conjur Inc
2
+ # Copyright (C) 2013-2015 Conjur Inc.
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
5
  # this software and associated documentation files (the "Software"), to deal in
@@ -121,19 +121,20 @@ module Conjur
121
121
 
122
122
  on_error do |exception|
123
123
  require 'rest-client'
124
- if exception.is_a?(RestClient::Exception)
125
- begin
126
- body = JSON.parse(exception.response.body)
127
- $stderr.puts body['error']
128
- rescue
129
- $stderr.puts exception.response.body if exception.response
124
+ require 'patches/conjur/error'
125
+
126
+ run_default_handler = true
127
+ if exception.is_a?(RestClient::Exception) && exception.response
128
+ err = Conjur::Error.create exception.response.body
129
+ if err
130
+ $stderr.puts "error: " + err.message
131
+ run_default_handler = false # suppress default error message
132
+ else
133
+ $stderr.puts exception.response.body
130
134
  end
131
135
  end
132
- require 'conjur/log'
133
- if Conjur.log
134
- Conjur.log << "error: #{exception}\n#{exception.backtrace.join("\n") rescue 'NO BACKTRACE?'}"
135
- end
136
- true
136
+
137
+ run_default_handler
137
138
  end
138
139
  end
139
140
  end
@@ -32,11 +32,16 @@ class Conjur::Command::Groups < Conjur::Command
32
32
  group.desc "Create a new group"
33
33
  group.arg_name "id"
34
34
  group.command :create do |c|
35
+ c.desc "GID number to be associated with the group (optional)"
36
+ c.flag [:gidnumber]
37
+
35
38
  acting_as_option(c)
36
39
 
37
40
  c.action do |global_options,options,args|
38
41
  id = require_arg(args, 'id')
39
42
 
43
+ options[:gidnumber] = Integer(options[:gidnumber]) if options[:gidnumber]
44
+
40
45
  group = api.create_group(id, options)
41
46
  display(group, options)
42
47
  end
@@ -60,6 +65,30 @@ class Conjur::Command::Groups < Conjur::Command
60
65
  end
61
66
  end
62
67
 
68
+ group.desc "Update group's attributes (eg. gidnumber)"
69
+ group.arg_name "id"
70
+ group.command :update do |c|
71
+ c.desc "GID number to be associated with the group"
72
+ c.flag [:gidnumber]
73
+ c.action do |global_options, options, args|
74
+ id = require_arg(args, 'id')
75
+
76
+ options[:gidnumber] = Integer(options[:gidnumber])
77
+ api.group(id).update(options)
78
+
79
+ puts "GID set"
80
+ end
81
+ end
82
+
83
+ group.desc "Find groups by GID"
84
+ group.arg_name "gid"
85
+ group.command :gidsearch do |c|
86
+ c.action do |global_options, options, args|
87
+ gidnumber = Integer require_arg args, 'gid'
88
+ display api.find_groups(gidnumber: gidnumber)
89
+ end
90
+ end
91
+
63
92
  group.desc "Decommission a group"
64
93
  group.arg_name "id"
65
94
  group.command :retire do |c|
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (C) 2014 Conjur Inc
2
+ # Copyright (C) 2014-2015 Conjur Inc.
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
5
  # this software and associated documentation files (the "Software"), to deal in
@@ -19,6 +19,6 @@
19
19
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
20
  #
21
21
  module Conjur
22
- VERSION = "4.19.0"
22
+ VERSION = "4.20.1"
23
23
  ::Version=VERSION
24
24
  end
@@ -0,0 +1,96 @@
1
+ # Copyright (C) 2015 Conjur Inc
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ # this software and associated documentation files (the "Software"), to deal in
5
+ # the Software without restriction, including without limitation the rights to
6
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ # the Software, and to permit persons to whom the Software is furnished to do so,
8
+ # subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
+
20
+ # Conjur::Error is not in the API v4 because it breaks backwards compatibility.
21
+ # Try to load it, and if not there, patch it in.
22
+ begin
23
+ require 'conjur/error'
24
+ rescue LoadError
25
+ # old API version
26
+ module Conjur
27
+ # Error class lifted from v5 branch of conjur-api.
28
+
29
+ # The base Conjur error class. Rescue it to catch errors generated by the Conjur services.
30
+ class Error < RuntimeError
31
+ # Create a new instance based on structured error info.
32
+ # @param [String] body JSON error information
33
+ # @return [Error, nil] the exception instance or nil if +body+ doesn't
34
+ # contain valid error info
35
+ def self.create body
36
+ error = JSON.parse(body)['error']
37
+ kind = error['kind']
38
+ klass = const_defined?(kind) && const_get(kind) || self
39
+ klass.new error
40
+ rescue
41
+ nil
42
+ end
43
+
44
+ # @!attribute [r] message
45
+ # @return [String] human-readable error message, as returned by the Conjur service
46
+ # @see #details
47
+ def message
48
+ @error['message']
49
+ end
50
+
51
+ # @!attribute [r] details
52
+ # @return error details, as returned by the Conjur service
53
+ # @see #message
54
+ def details
55
+ @error['details']
56
+ end
57
+
58
+ # @!attribute [r] kind
59
+ # @return [String] error kind, as returned by the Conjur service
60
+ # @note Usually it will equal the class name.
61
+ def kind
62
+ @error['kind']
63
+ end
64
+
65
+ # Indicates that the looked up record does not exist.
66
+ class RecordNotFound < Error
67
+ # @!attribute [r] details
68
+ # @return [Hash<String, String>] error details:
69
+ # - +'kind'+ of the searched object
70
+ # - +'id'+ that is missing
71
+ end
72
+
73
+ # Indicates a missing argument for a method call.
74
+ class MissingArgument < Error
75
+ # @!attribute [r] details
76
+ # @return [String] name of the missing argument
77
+ end
78
+
79
+ # Indicates a name or identifier clash.
80
+ class UniqueConstraintViolation < Error
81
+ # @!attribute [r] details
82
+ # @return [Hash<String, String>] error details:
83
+ # - +'value'+ that caused the clash
84
+ # - +'field'+ in which the clash occurred
85
+ # - +'kind'+ of an object being manipulated
86
+ end
87
+
88
+ private
89
+
90
+ def initialize error
91
+ @error = error
92
+ super message
93
+ end
94
+ end
95
+ end
96
+ end
@@ -1,6 +1,33 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Conjur::Command::Groups, logged_in: true do
4
+ describe_command 'group create --gidnumber 12345 some-group' do
5
+ it "creates the group with a specified gidnumber" do
6
+ expect_any_instance_of(Conjur::API).to receive(:create_group).with('some-group', gidnumber: 12345).and_return "something"
7
+ expect { invoke }.to write "something"
8
+ end
9
+ end
10
+
11
+ describe_command 'group update --gidnumber 12345 some-group' do
12
+ it "updates the gid" do
13
+ expect_any_instance_of(Conjur::API).to \
14
+ receive(:group).with('some-group').and_return(group = double("group"))
15
+ expect(group).to receive(:update).with(gidnumber: 12_345)
16
+ expect { invoke }.to write "GID set"
17
+ end
18
+ end
19
+
20
+ context "lookup by GID" do
21
+ let(:search_result) { %w(g1 g2) }
22
+ describe_command "group gidsearch 12345" do
23
+ it "finds the groups" do
24
+ expect_any_instance_of(Conjur::API).to \
25
+ receive(:find_groups).with(gidnumber: 12_345).and_return search_result
26
+ expect { invoke }.to write(JSON.pretty_generate(search_result))
27
+ end
28
+ end
29
+ end
30
+
4
31
  describe_command "group:members:add group user:alice" do
5
32
  it "adds the role to the group" do
6
33
  expect(RestClient::Request).to receive(:execute).with(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conjur-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.19.0
4
+ version: 4.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafal Rzepecki
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-27 00:00:00.000000000 Z
12
+ date: 2015-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - ~>
33
33
  - !ruby/object:Gem::Version
34
- version: 4.12.0
34
+ version: 4.13.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ~>
40
40
  - !ruby/object:Gem::Version
41
- version: 4.12.0
41
+ version: 4.13.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: gli
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -318,6 +318,7 @@ files:
318
318
  - lib/conjur/dsl/runner.rb
319
319
  - lib/conjur/identifier_manipulation.rb
320
320
  - lib/conjur/version.rb
321
+ - lib/patches/conjur/error.rb
321
322
  - profile.rb
322
323
  - spec/authn_spec.rb
323
324
  - spec/command/assets_spec.rb