conjur-api 2.1.1 → 2.1.2
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/lib/conjur-api/version.rb +1 -1
- data/lib/conjur/acts_as_role.rb +5 -1
- data/lib/conjur/api/groups.rb +8 -0
- data/lib/conjur/base.rb +1 -0
- data/lib/conjur/group.rb +0 -4
- data/lib/conjur/host.rb +0 -4
- data/lib/conjur/role.rb +5 -0
- data/lib/conjur/user.rb +0 -4
- data/spec/lib/api_spec.rb +1 -1
- data/spec/lib/user_spec.rb +7 -2
- metadata +4 -4
    
        data/lib/conjur-api/version.rb
    CHANGED
    
    
    
        data/lib/conjur/acts_as_role.rb
    CHANGED
    
    | @@ -1,8 +1,12 @@ | |
| 1 1 | 
             
            module Conjur
         | 
| 2 2 | 
             
              module ActsAsRole
         | 
| 3 | 
            +
                def roleid
         | 
| 4 | 
            +
                  self.attributes['roleid'] or raise "roleid attribute not found"
         | 
| 5 | 
            +
                end
         | 
| 6 | 
            +
                
         | 
| 3 7 | 
             
                def role
         | 
| 4 8 | 
             
                  require 'conjur/role'
         | 
| 5 | 
            -
                  Conjur::Role.new( | 
| 9 | 
            +
                  Conjur::Role.new(Conjur::Authz::API.host, self.options)[Conjur::API.parse_role_id(self.roleid).join('/')]
         | 
| 6 10 | 
             
                end
         | 
| 7 11 | 
             
              end
         | 
| 8 12 | 
             
            end
         | 
    
        data/lib/conjur/api/groups.rb
    CHANGED
    
    | @@ -2,6 +2,14 @@ require 'conjur/group' | |
| 2 2 |  | 
| 3 3 | 
             
            module Conjur
         | 
| 4 4 | 
             
              class API
         | 
| 5 | 
            +
                def groups
         | 
| 6 | 
            +
                  JSON.parse(RestClient::Resource.new(Conjur::Core::API.host, credentials)['groups'].get).collect do |json|
         | 
| 7 | 
            +
                    # TODO: remove this hack
         | 
| 8 | 
            +
                    json = JSON.parse json['json']
         | 
| 9 | 
            +
                    group(json['id'])
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 5 13 | 
             
                def create_group(id, options = {})
         | 
| 6 14 | 
             
                  standard_create Conjur::Core::API.host, :group, id, options
         | 
| 7 15 | 
             
                end
         | 
    
        data/lib/conjur/base.rb
    CHANGED
    
    | @@ -20,6 +20,7 @@ module Conjur | |
| 20 20 | 
             
                  # Parse a role id into [ account, 'roles', kind, id ]
         | 
| 21 21 | 
             
                  def parse_role_id(id)
         | 
| 22 22 | 
             
                    paths = path_escape(id).split(':')
         | 
| 23 | 
            +
                    raise "Expecting account:kind:id in role #{id}" unless paths.size >= 3
         | 
| 23 24 | 
             
                    [ paths[0], 'roles', paths[1], paths[2..-1].join(':') ]
         | 
| 24 25 | 
             
                  end
         | 
| 25 26 |  | 
    
        data/lib/conjur/group.rb
    CHANGED
    
    
    
        data/lib/conjur/host.rb
    CHANGED
    
    
    
        data/lib/conjur/role.rb
    CHANGED
    
    | @@ -9,6 +9,10 @@ module Conjur | |
| 9 9 |  | 
| 10 10 | 
             
                alias id identifier
         | 
| 11 11 |  | 
| 12 | 
            +
                def roleid
         | 
| 13 | 
            +
                  [ account, kind, identifier ].join(':')
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
                
         | 
| 12 16 | 
             
                def create(options = {})
         | 
| 13 17 | 
             
                  log do |logger|
         | 
| 14 18 | 
             
                    logger << "Creating role #{kind}:#{identifier}"
         | 
| @@ -21,6 +25,7 @@ module Conjur | |
| 21 25 |  | 
| 22 26 | 
             
                def all(options = {})
         | 
| 23 27 | 
             
                  JSON.parse(self["?all"].get(options)).collect do |id|
         | 
| 28 | 
            +
                    id = [ id['account'], id['id'] ].join(':')
         | 
| 24 29 | 
             
                    Role.new(Conjur::Authz::API.host, self.options)[Conjur::API.parse_role_id(id).join('/')]
         | 
| 25 30 | 
             
                  end
         | 
| 26 31 | 
             
                end
         | 
    
        data/lib/conjur/user.rb
    CHANGED
    
    
    
        data/spec/lib/api_spec.rb
    CHANGED
    
    
    
        data/spec/lib/user_spec.rb
    CHANGED
    
    | @@ -12,10 +12,12 @@ describe Conjur::User do | |
| 12 12 | 
             
                  subject { user }
         | 
| 13 13 | 
             
                  its(:id) { should == login }
         | 
| 14 14 | 
             
                  its(:login) { should == login }
         | 
| 15 | 
            -
                  its(:roleid) { should == ["user", login].join(':') }
         | 
| 16 15 | 
             
                  its(:resource_id) { should == login }
         | 
| 17 16 | 
             
                  its(:resource_kind) { should == "user" }
         | 
| 18 17 | 
             
                  its(:options) { should == credentials }
         | 
| 18 | 
            +
                  specify {
         | 
| 19 | 
            +
                    lambda { user.roleid }.should raise_error
         | 
| 20 | 
            +
                  }
         | 
| 19 21 | 
             
                end
         | 
| 20 22 | 
             
                before {
         | 
| 21 23 | 
             
                  Conjur.stub(:account).and_return 'ci'
         | 
| @@ -28,8 +30,11 @@ describe Conjur::User do | |
| 28 30 | 
             
                  user.resource
         | 
| 29 31 | 
             
                end
         | 
| 30 32 | 
             
                it "connects to a Role" do
         | 
| 33 | 
            +
                  user.stub(:roleid).and_return "ci:user:the-login"
         | 
| 34 | 
            +
                  
         | 
| 31 35 | 
             
                  require 'conjur/role'
         | 
| 32 | 
            -
                  Conjur::Role.should_receive(:new).with( | 
| 36 | 
            +
                  Conjur::Role.should_receive(:new).with(Conjur::Authz::API.host, credentials).and_return role = double(:role)
         | 
| 37 | 
            +
                  role.should_receive(:[]).with("ci/roles/user/the-login")
         | 
| 33 38 |  | 
| 34 39 | 
             
                  user.role
         | 
| 35 40 | 
             
                end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: conjur-api
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.1. | 
| 4 | 
            +
              version: 2.1.2
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -10,7 +10,7 @@ authors: | |
| 10 10 | 
             
            autorequire: 
         | 
| 11 11 | 
             
            bindir: bin
         | 
| 12 12 | 
             
            cert_chain: []
         | 
| 13 | 
            -
            date: 2013- | 
| 13 | 
            +
            date: 2013-04-12 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              name: rest-client
         | 
| @@ -204,7 +204,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 204 204 | 
             
                  version: '0'
         | 
| 205 205 | 
             
                  segments:
         | 
| 206 206 | 
             
                  - 0
         | 
| 207 | 
            -
                  hash:  | 
| 207 | 
            +
                  hash: -423708281748873360
         | 
| 208 208 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 209 209 | 
             
              none: false
         | 
| 210 210 | 
             
              requirements:
         | 
| @@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 213 213 | 
             
                  version: '0'
         | 
| 214 214 | 
             
                  segments:
         | 
| 215 215 | 
             
                  - 0
         | 
| 216 | 
            -
                  hash:  | 
| 216 | 
            +
                  hash: -423708281748873360
         | 
| 217 217 | 
             
            requirements: []
         | 
| 218 218 | 
             
            rubyforge_project: 
         | 
| 219 219 | 
             
            rubygems_version: 1.8.24
         |