chef-api 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chef-api/version.rb +1 -1
  3. metadata +6 -70
  4. data/.gitignore +0 -21
  5. data/.travis.yml +0 -18
  6. data/CHANGELOG.md +0 -63
  7. data/Gemfile +0 -12
  8. data/README.md +0 -352
  9. data/Rakefile +0 -11
  10. data/chef-api.gemspec +0 -25
  11. data/spec/integration/resources/client_spec.rb +0 -62
  12. data/spec/integration/resources/environment_spec.rb +0 -8
  13. data/spec/integration/resources/node_spec.rb +0 -8
  14. data/spec/integration/resources/partial_search_spec.rb +0 -23
  15. data/spec/integration/resources/role_spec.rb +0 -8
  16. data/spec/integration/resources/search_spec.rb +0 -21
  17. data/spec/integration/resources/user_spec.rb +0 -8
  18. data/spec/spec_helper.rb +0 -32
  19. data/spec/support/chef_server.rb +0 -198
  20. data/spec/support/cookbook.tar.gz +0 -0
  21. data/spec/support/shared/chef_api_resource.rb +0 -91
  22. data/spec/support/user.pem +0 -27
  23. data/spec/unit/authentication_spec.rb +0 -70
  24. data/spec/unit/defaults_spec.rb +0 -60
  25. data/spec/unit/errors_spec.rb +0 -294
  26. data/spec/unit/resources/base_spec.rb +0 -49
  27. data/spec/unit/resources/client_spec.rb +0 -53
  28. data/spec/unit/resources/connection_spec.rb +0 -53
  29. data/templates/errors/abstract_method.erb +0 -5
  30. data/templates/errors/cannot_regenerate_key.erb +0 -1
  31. data/templates/errors/chef_api_error.erb +0 -1
  32. data/templates/errors/file_not_found.erb +0 -1
  33. data/templates/errors/http_bad_request.erb +0 -3
  34. data/templates/errors/http_forbidden_request.erb +0 -3
  35. data/templates/errors/http_gateway_timeout.erb +0 -3
  36. data/templates/errors/http_method_not_allowed.erb +0 -3
  37. data/templates/errors/http_not_acceptable.erb +0 -3
  38. data/templates/errors/http_not_found.erb +0 -3
  39. data/templates/errors/http_server_unavailable.erb +0 -1
  40. data/templates/errors/http_unauthorized_request.erb +0 -3
  41. data/templates/errors/insufficient_file_permissions.erb +0 -1
  42. data/templates/errors/invalid_resource.erb +0 -1
  43. data/templates/errors/invalid_validator.erb +0 -1
  44. data/templates/errors/missing_url_parameter.erb +0 -1
  45. data/templates/errors/not_a_directory.erb +0 -1
  46. data/templates/errors/resource_already_exists.erb +0 -1
  47. data/templates/errors/resource_not_found.erb +0 -1
  48. data/templates/errors/resource_not_mutable.erb +0 -1
  49. data/templates/errors/unknown_attribute.erb +0 -1
@@ -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-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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
@@ -1,5 +0,0 @@
1
- '<%= @method %>' is an abstract method. You must override this method in your subclass with the proper implementation and logic. For more information, please see the inline documentation for <%= @method %>. If you are not a developer, this is most likely a bug in the ChefAPI gem. Please file a bug report at:
2
-
3
- https://github.com/sethvargo/chef-api/issues/new
4
-
5
- and include the command(s) or code you ran to arrive at this error.
@@ -1 +0,0 @@
1
- You attempted to regenerate the private key for a Client or User that does not yet exist on the remote Chef Server. You can only regenerate the key for an object that is persisted. Try saving this record this object before regenerating the key.
@@ -1 +0,0 @@
1
- Oh no! Something really bad happened. I am not sure what actually happened because this is the catch-all error, but you should most definitely report an issue on GitHub at https://github.com/sethvargo/chef-api.
@@ -1 +0,0 @@
1
- I could not find a file at '<%= @path %>'. Please make sure you have typed the path correctly and that the resource exists at the given path.
@@ -1,3 +0,0 @@
1
- The Chef Server did not understand the request because it was malformed.
2
-
3
- <%= @message %>
@@ -1,3 +0,0 @@
1
- The Chef Server actively refused to fulfill the request.
2
-
3
- <%= @message %>
@@ -1,3 +0,0 @@
1
- The Chef Server did not respond in an adequate amount of time.
2
-
3
- <%= @message %>
@@ -1,3 +0,0 @@
1
- That HTTP method is not allowed on this URL.
2
-
3
- <%= @message %>
@@ -1,3 +0,0 @@
1
- The Chef Server identified this request as unacceptable. This usually means you have not specified the correct Accept or Content-Type headers on the request.
2
-
3
- <%= @message %>
@@ -1,3 +0,0 @@
1
- The requested URL does not exist on the Chef Server.
2
-
3
- <%= @message %>
@@ -1 +0,0 @@
1
- The Chef Server is currently unavailable or is not currently accepting client connections. Please ensure the server is accessible via ping or telnet on your local network. If this error persists, please contact your network administrator.
@@ -1,3 +0,0 @@
1
- The Chef Server requires authorization. Please ensure you have specified the correct client name and private key. If this error continues, please verify the given client has the proper permissions on the Chef Server.
2
-
3
- <%= @message %>
@@ -1 +0,0 @@
1
- I cannot read the file at '<%= @path %>' because the permissions on the file do not permit it. Please ensure the file has the correct permissions and that this Ruby process is running as a user with access to that path.
@@ -1 +0,0 @@
1
- There were errors saving your resource: <%= @errors %>
@@ -1 +0,0 @@
1
- '<%= @key %>' is not a valid validator. Please make sure it is spelled correctly and that the constant is properly defined. If you are using a custom validator, please ensure the validator extends ChefAPI::Validator::Base and is a subclass of ChefAPI::Validator.
@@ -1 +0,0 @@
1
- The required URL parameter '<%= @param %>' was not present. Please specify the parameter as an option, like Resource.new(id, <%= @param %>: 'value').
@@ -1 +0,0 @@
1
- The given path '<%= @path %>' is not a directory. Please make sure you have passed the path to a directory on disk.
@@ -1 +0,0 @@
1
- The <%= @type %> '<%= @id %>' already exists on the Chef Server. Each <%= @type %> must have a unique identifier and the Chef Server indicated this <%= @type %> already exists. If you are trying to update the <%= @type %>, consider using the 'update' method instead.
@@ -1 +0,0 @@
1
- There is no <%= @type %> with an id of '<%= @id %>' on the Chef Server. If you are updating the <%= @type %>, please make sure the <%= @type %> exists and has the correct Chef identifier (primary key).
@@ -1 +0,0 @@
1
- The <%= @type %> '<%= @id %>' is not mutable. It may be locked by the remote Chef Server, or the Chef Server may not permit modifying the resource.
@@ -1 +0,0 @@
1
- '<%= @attribute %>' is not a valid attribute!