Skip to content

Commit

Permalink
Merge pull request #50 from chef/ssd/organization-force-associate
Browse files Browse the repository at this point in the history
Use correct user-association endpoint for Chef 12
  • Loading branch information
tyler-ball committed Aug 20, 2015
2 parents 1f5c738 + 3e5c0db commit a5df7c0
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ matrix:
allow_failures:
- env: CHEF_VERSION=master
- env: CHEF_VERSION=12.4.1
- env: CHEF_VERSION=12.2.1
- env: CHEF_VERSION=12.1.2

script:
- bundle install --jobs=3 --retry=3
Expand Down
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
source "https://rubygems.org"
gemspec

# TODO when chef-zero > 4.2.3 is released then just depend on that
gem 'chef-zero', github: 'chef/chef-zero'
gem 'chef', '= 12.3.0'

if RUBY_VERSION.to_f < 2.0
gem 'openssl_pkcs8'
end
3 changes: 3 additions & 0 deletions chef-client-version.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ source "https://rubygems.org"

chef_version = ENV['CHEF_VERSION']

# TODO when chef-zero > 4.2.3 is released then just depend on that
gem 'chef-zero', github: 'chef/chef-zero'

if chef_version == 'master'
puts "Testing chef/chef master"
gem 'chef', github: 'chef/chef'
Expand Down
2 changes: 1 addition & 1 deletion lib/chef/provider/chef_organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def whyrun_supported?
new_resource.members.each do |user|
if !existing_members.include?(user)
converge_by "Add #{user} to organization #{new_resource.name}" do
rest.post("#{rest.root_url}/organizations/#{new_resource.name}/users/#{user}", {})
rest.post("#{rest.root_url}/organizations/#{new_resource.name}/users/", { 'username' => user })
end
end
end
Expand Down
9 changes: 5 additions & 4 deletions lib/chef/resource/chef_organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ def invites_specified?
!!@invites
end

# A list of users who must be members of the org. This will use the new Chef 12
# POST /organizations/ORG/users/NAME endpoint to add them directly to the org.
# If you do not have permission to perform this operation, and the users are not
# a part of the org, the resource update will fail.
# A list of users who must be members of the org. This will use the
# new Chef 12 POST /organizations/ORG/users endpoint to add them
# directly to the org. If you do not have permission to perform
# this operation, and the users are not a part of the org, the
# resource update will fail.
def members(*users)
if users.size == 0
@members || []
Expand Down
12 changes: 6 additions & 6 deletions spec/integration/chef_mirror_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@
}.to have_updated('chef_mirror[]', :upload)
expect { get('nodes/x') }.not_to raise_error
expect { get('roles/x') }.not_to raise_error
expect { get('nodes/y') }.to raise_error
expect { get('roles/y') }.to raise_error
expect { get('nodes/y') }.to raise_error /404/
expect { get('roles/y') }.to raise_error /404/
end

it "Upload with chef_repo_path(:chef_repo_path) with multiple paths uploads everything" do
Expand Down Expand Up @@ -192,8 +192,8 @@
end
}.to have_updated('chef_mirror[]', :upload)
expect { get('nodes/x') }.not_to raise_error
expect { get('roles/x') }.to raise_error
expect { get('nodes/y') }.to raise_error
expect { get('roles/x') }.to raise_error /404/
expect { get('nodes/y') }.to raise_error /404/
expect { get('roles/y') }.not_to raise_error
end

Expand All @@ -209,8 +209,8 @@
end
}.to have_updated('chef_mirror[]', :upload)
expect { get('nodes/x') }.not_to raise_error
expect { get('roles/x') }.to raise_error
expect { get('nodes/y') }.to raise_error
expect { get('roles/x') }.to raise_error /404/
expect { get('nodes/y') }.to raise_error /404/
expect { get('roles/y') }.not_to raise_error
end

Expand Down
2 changes: 1 addition & 1 deletion spec/integration/private_key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
converge {
private_key "#{repo_path}/blah"
}
}.to raise_error
}.to raise_error /missing pass phrase?/
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/integration/rspec/converge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@
content 'test'
end
}.to be_up_to_date
}.to raise_error
}.to raise_error RSpec::Expectations::ExpectationNotMetError
end

it "expect_recipe { }.to be_updated fails" do
expect {
expect_recipe { }.to be_updated
}.to raise_error
}.to raise_error RSpec::Expectations::ExpectationNotMetError
end

it "expect_recipe { }.to be_up_to_date succeeds" do
Expand Down Expand Up @@ -157,7 +157,7 @@
it "expect_converge { raise 'oh no' }.to raise_error passes" do
expect_converge {
raise 'oh no'
}.to raise_error
}.to raise_error('oh no')
end
end

Expand Down

0 comments on commit a5df7c0

Please sign in to comment.