chef-api 0.8.0 → 0.10.7
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.
- checksums.yaml +4 -4
- data/lib/chef-api.rb +19 -20
- data/lib/chef-api/aclable.rb +35 -0
- data/lib/chef-api/authentication.rb +23 -25
- data/lib/chef-api/configurable.rb +14 -14
- data/lib/chef-api/connection.rb +68 -67
- data/lib/chef-api/defaults.rb +25 -24
- data/lib/chef-api/error_collection.rb +1 -1
- data/lib/chef-api/errors.rb +3 -3
- data/lib/chef-api/log.rb +7 -0
- data/lib/chef-api/multipart.rb +17 -17
- data/lib/chef-api/resource.rb +17 -15
- data/lib/chef-api/resources/base.rb +22 -22
- data/lib/chef-api/resources/client.rb +5 -3
- data/lib/chef-api/resources/collection_proxy.rb +4 -3
- data/lib/chef-api/resources/cookbook.rb +2 -2
- data/lib/chef-api/resources/cookbook_version.rb +1 -1
- data/lib/chef-api/resources/data_bag.rb +4 -4
- data/lib/chef-api/resources/data_bag_item.rb +2 -3
- data/lib/chef-api/resources/environment.rb +1 -1
- data/lib/chef-api/resources/group.rb +15 -0
- data/lib/chef-api/resources/node.rb +11 -8
- data/lib/chef-api/resources/organization.rb +2 -2
- data/lib/chef-api/resources/partial_search.rb +4 -4
- data/lib/chef-api/resources/principal.rb +1 -1
- data/lib/chef-api/resources/role.rb +2 -1
- data/lib/chef-api/resources/search.rb +6 -6
- data/lib/chef-api/resources/user.rb +3 -3
- data/lib/chef-api/util.rb +8 -8
- data/lib/chef-api/validator.rb +3 -3
- data/lib/chef-api/validators/base.rb +3 -3
- data/lib/chef-api/validators/required.rb +1 -1
- data/lib/chef-api/validators/type.rb +1 -1
- data/lib/chef-api/version.rb +1 -1
- metadata +25 -58
- data/.gitignore +0 -21
- data/.travis.yml +0 -18
- data/CHANGELOG.md +0 -63
- data/Gemfile +0 -12
- data/README.md +0 -352
- data/Rakefile +0 -11
- data/chef-api.gemspec +0 -25
- data/spec/integration/resources/client_spec.rb +0 -62
- data/spec/integration/resources/environment_spec.rb +0 -8
- data/spec/integration/resources/node_spec.rb +0 -8
- data/spec/integration/resources/partial_search_spec.rb +0 -23
- data/spec/integration/resources/role_spec.rb +0 -8
- data/spec/integration/resources/search_spec.rb +0 -21
- data/spec/integration/resources/user_spec.rb +0 -8
- data/spec/spec_helper.rb +0 -32
- data/spec/support/chef_server.rb +0 -198
- data/spec/support/cookbook.tar.gz +0 -0
- data/spec/support/shared/chef_api_resource.rb +0 -91
- data/spec/support/user.pem +0 -27
- data/spec/unit/authentication_spec.rb +0 -70
- data/spec/unit/defaults_spec.rb +0 -60
- data/spec/unit/errors_spec.rb +0 -294
- data/spec/unit/resources/base_spec.rb +0 -49
- data/spec/unit/resources/client_spec.rb +0 -53
- data/spec/unit/resources/connection_spec.rb +0 -53
| @@ -1,49 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module ChefAPI
         | 
| 4 | 
            -
              describe Resource::Base do
         | 
| 5 | 
            -
                before do
         | 
| 6 | 
            -
                  # Unset all instance variables (which are actually cached on the parent
         | 
| 7 | 
            -
                  # class) to prevent caching.
         | 
| 8 | 
            -
                  described_class.instance_variables.each do |instance_variable|
         | 
| 9 | 
            -
                    described_class.send(:remove_instance_variable, instance_variable)
         | 
| 10 | 
            -
                  end
         | 
| 11 | 
            -
                end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                describe '.schema' do
         | 
| 14 | 
            -
                  it 'sets the schema for the class' do
         | 
| 15 | 
            -
                    block = Proc.new {}
         | 
| 16 | 
            -
                    described_class.schema(&block)
         | 
| 17 | 
            -
                    expect(described_class.schema).to be_a(Schema)
         | 
| 18 | 
            -
                  end
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                describe '.collection_path' do
         | 
| 22 | 
            -
                  it 'raises an exception if the collection name is not set' do
         | 
| 23 | 
            -
                    expect {
         | 
| 24 | 
            -
                      described_class.collection_path
         | 
| 25 | 
            -
                    }.to raise_error(ArgumentError, 'collection_path not set for Class')
         | 
| 26 | 
            -
                  end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                  it 'sets the collection name' do
         | 
| 29 | 
            -
                    described_class.collection_path('bacons')
         | 
| 30 | 
            -
                    expect(described_class.collection_path).to eq('bacons')
         | 
| 31 | 
            -
                  end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                  it 'converts the symbol to a string' do
         | 
| 34 | 
            -
                    described_class.collection_path(:bacons)
         | 
| 35 | 
            -
                    expect(described_class.collection_path).to eq('bacons')
         | 
| 36 | 
            -
                  end
         | 
| 37 | 
            -
                end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
                describe '.build' do
         | 
| 40 | 
            -
                  it 'creates a new instance' do
         | 
| 41 | 
            -
                    allow(described_class).to receive(:new)
         | 
| 42 | 
            -
                    allow(described_class).to receive(:schema).and_return(double(attributes: {}))
         | 
| 43 | 
            -
             | 
| 44 | 
            -
                    expect(described_class).to receive(:new).with({foo: 'bar'}, {})
         | 
| 45 | 
            -
                    described_class.build(foo: 'bar')
         | 
| 46 | 
            -
                  end
         | 
| 47 | 
            -
                end
         | 
| 48 | 
            -
              end
         | 
| 49 | 
            -
            end
         | 
| @@ -1,53 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module ChefAPI
         | 
| 4 | 
            -
              describe Resource::Client do
         | 
| 5 | 
            -
                describe '.initialize' do
         | 
| 6 | 
            -
                  it 'converts an x509 certificate to a public key' do
         | 
| 7 | 
            -
                    certificate = <<-EOH.gsub(/^ {10}/, '')
         | 
| 8 | 
            -
                      -----BEGIN CERTIFICATE-----
         | 
| 9 | 
            -
                      MIIDOjCCAqOgAwIBAgIEkT9umDANBgkqhkiG9w0BAQUFADCBnjELMAkGA1UEBhMC
         | 
| 10 | 
            -
                      VVMxEzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxFjAUBgNV
         | 
| 11 | 
            -
                      BAoMDU9wc2NvZGUsIEluYy4xHDAaBgNVBAsME0NlcnRpZmljYXRlIFNlcnZpY2Ux
         | 
| 12 | 
            -
                      MjAwBgNVBAMMKW9wc2NvZGUuY29tL2VtYWlsQWRkcmVzcz1hdXRoQG9wc2NvZGUu
         | 
| 13 | 
            -
                      Y29tMCAXDTEzMDYwNzE3NDcxNloYDzIxMDIwNzIyMTc0NzE2WjCBnTEQMA4GA1UE
         | 
| 14 | 
            -
                      BxMHU2VhdHRsZTETMBEGA1UECBMKV2FzaGluZ3RvbjELMAkGA1UEBhMCVVMxHDAa
         | 
| 15 | 
            -
                      BgNVBAsTE0NlcnRpZmljYXRlIFNlcnZpY2UxFjAUBgNVBAoTDU9wc2NvZGUsIElu
         | 
| 16 | 
            -
                      Yy4xMTAvBgNVBAMUKFVSSTpodHRwOi8vb3BzY29kZS5jb20vR1VJRFMvY2xpZW50
         | 
| 17 | 
            -
                      X2d1aWQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCko42znqDzryvE
         | 
| 18 | 
            -
                      aB1DBHLFpjLZ7aWrTJQJJUvQhMFTE/1nisa+1bw8MvOYnGDSp2j6V7XJsJgZFsAW
         | 
| 19 | 
            -
                      7w5TTBHrYRAz0Boi+uaQ3idqfGI5na/dRt2MqFnwJYqvm7z+LeeYbGlXFNnhUInt
         | 
| 20 | 
            -
                      OjZD6AtrvuTGAEVdyIznsOMsLun/KWy9zG0+C+6vCnxGga+Z+xZ56JrBvWoWeIjG
         | 
| 21 | 
            -
                      kO0J6E3uqyzAC8FwN6xnyaHNlvODE+40MuioVJ52oLikTwaVe3T+vSJQoCu1lz7c
         | 
| 22 | 
            -
                      AbdszAhDW2p+GVvBBjAXLNi/w27heDQKBQOS+6tHJAX3WeFj0xgE5Bryae67E0q8
         | 
| 23 | 
            -
                      hM4WPL6PAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAWlBQBu8kzhSA4TuHJNyngRAJ
         | 
| 24 | 
            -
                      WXHus2brJZHaaZYMbzZMq+lklMbdw8NZBay+qVqN/latgQ7fjY9RSSdhCTeSITyw
         | 
| 25 | 
            -
                      gn8s3zeFS7C6nwrzYNAQXTRJZoSgn32hgZoD1H0LjW5vcoqiYZOHvX3EOySboS09
         | 
| 26 | 
            -
                      bAELUrq85D+uVns9C5A=
         | 
| 27 | 
            -
                      -----END CERTIFICATE-----
         | 
| 28 | 
            -
                    EOH
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                    instance = described_class.new(certificate: certificate)
         | 
| 31 | 
            -
                    expect(instance.public_key).to eq <<-EOH.gsub(/^ {10}/, '')
         | 
| 32 | 
            -
                      -----BEGIN PUBLIC KEY-----
         | 
| 33 | 
            -
                      MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApKONs56g868rxGgdQwRy
         | 
| 34 | 
            -
                      xaYy2e2lq0yUCSVL0ITBUxP9Z4rGvtW8PDLzmJxg0qdo+le1ybCYGRbAFu8OU0wR
         | 
| 35 | 
            -
                      62EQM9AaIvrmkN4nanxiOZ2v3UbdjKhZ8CWKr5u8/i3nmGxpVxTZ4VCJ7To2Q+gL
         | 
| 36 | 
            -
                      a77kxgBFXciM57DjLC7p/ylsvcxtPgvurwp8RoGvmfsWeeiawb1qFniIxpDtCehN
         | 
| 37 | 
            -
                      7qsswAvBcDesZ8mhzZbzgxPuNDLoqFSedqC4pE8GlXt0/r0iUKArtZc+3AG3bMwI
         | 
| 38 | 
            -
                      Q1tqfhlbwQYwFyzYv8Nu4Xg0CgUDkvurRyQF91nhY9MYBOQa8mnuuxNKvITOFjy+
         | 
| 39 | 
            -
                      jwIDAQAB
         | 
| 40 | 
            -
                      -----END PUBLIC KEY-----
         | 
| 41 | 
            -
                    EOH
         | 
| 42 | 
            -
                  end
         | 
| 43 | 
            -
                end
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                describe '#regenerate_keys' do
         | 
| 46 | 
            -
                  it 'raises an error if the client is not persisted to the server' do
         | 
| 47 | 
            -
                    expect {
         | 
| 48 | 
            -
                      described_class.new.regenerate_keys
         | 
| 49 | 
            -
                    }.to raise_error(Error::CannotRegenerateKey)
         | 
| 50 | 
            -
                  end
         | 
| 51 | 
            -
                end
         | 
| 52 | 
            -
              end
         | 
| 53 | 
            -
            end
         | 
| @@ -1,53 +0,0 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module ChefAPI
         | 
| 4 | 
            -
              describe Connection do
         | 
| 5 | 
            -
                shared_examples 'a proxy for' do |resource, klass|
         | 
| 6 | 
            -
                  context "##{resource}" do
         | 
| 7 | 
            -
                    it 'sets Thread.current to self' do
         | 
| 8 | 
            -
                      subject.send(resource)
         | 
| 9 | 
            -
                      expect(Thread.current['chefapi.connection']).to be(subject)
         | 
| 10 | 
            -
                    end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                    it "returns an instance of #{klass}" do
         | 
| 13 | 
            -
                      # Fuck you Ruby 1.9.3
         | 
| 14 | 
            -
                      expected = klass.split('::').inject(ChefAPI) { |c, i| c.const_get(i) }
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                      expect(subject.send(resource)).to be(expected)
         | 
| 17 | 
            -
                    end
         | 
| 18 | 
            -
                  end
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                it_behaves_like 'a proxy for', :clients,        'Resource::Client'
         | 
| 22 | 
            -
                it_behaves_like 'a proxy for', :data_bags,      'Resource::DataBag'
         | 
| 23 | 
            -
                it_behaves_like 'a proxy for', :environments,   'Resource::Environment'
         | 
| 24 | 
            -
                it_behaves_like 'a proxy for', :nodes,          'Resource::Node'
         | 
| 25 | 
            -
                it_behaves_like 'a proxy for', :partial_search, 'Resource::PartialSearch'
         | 
| 26 | 
            -
                it_behaves_like 'a proxy for', :principals,     'Resource::Principal'
         | 
| 27 | 
            -
                it_behaves_like 'a proxy for', :roles,          'Resource::Role'
         | 
| 28 | 
            -
                it_behaves_like 'a proxy for', :search,         'Resource::Search'
         | 
| 29 | 
            -
                it_behaves_like 'a proxy for', :users,          'Resource::User'
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                context '#initialize' do
         | 
| 32 | 
            -
                  context 'when options are given' do
         | 
| 33 | 
            -
                    let(:endpoint) { 'http://endpoint.gov' }
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                    it 'sets the option' do
         | 
| 36 | 
            -
                      instance = described_class.new(endpoint: endpoint)
         | 
| 37 | 
            -
                      expect(instance.endpoint).to eq(endpoint)
         | 
| 38 | 
            -
                    end
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                    it 'uses the default options' do
         | 
| 41 | 
            -
                      instance = described_class.new
         | 
| 42 | 
            -
                      expect(instance.endpoint).to eq(ChefAPI.endpoint)
         | 
| 43 | 
            -
                    end
         | 
| 44 | 
            -
                  end
         | 
| 45 | 
            -
             | 
| 46 | 
            -
                  context 'when a block is given' do
         | 
| 47 | 
            -
                    it 'yields self' do
         | 
| 48 | 
            -
                      expect { |b| described_class.new(&b) }.to yield_with_args(described_class)
         | 
| 49 | 
            -
                    end
         | 
| 50 | 
            -
                  end
         | 
| 51 | 
            -
                end
         | 
| 52 | 
            -
              end
         | 
| 53 | 
            -
            end
         |