chef_fixie 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,42 +18,46 @@
18
18
  # Author: Mark Anderson <mark@chef.io>
19
19
  #
20
20
 
21
- require_relative 'config'
22
- require_relative 'authz_objects'
23
- require_relative 'authz_mapper'
21
+ require_relative "config"
22
+ require_relative "authz_objects"
23
+ require_relative "authz_mapper"
24
24
 
25
25
  module ChefFixie
26
26
  module UtilityHelpers
27
27
  def self.orgs
28
28
  @orgs ||= ChefFixie::Sql::Orgs.new
29
29
  end
30
+
30
31
  def self.users
31
32
  @users ||= ChefFixie::Sql::Users.new
32
33
  end
34
+
33
35
  def self.assocs
34
36
  @assocs ||= ChefFixie::Sql::Associations.new
35
37
  end
38
+
36
39
  def self.invites
37
40
  invites ||= ChefFixie::Sql::Invites.new
38
41
  end
39
42
 
40
43
  def self.make_user(user)
41
44
  if user.is_a?(String)
42
- return users[user]
45
+ users[user]
43
46
  elsif user.is_a?(ChefFixie::Sql::User)
44
- return user
47
+ user
45
48
  else
46
49
  raise Exception "Expected a user, got a #{user.class}"
47
50
  end
48
- end
51
+ end
52
+
49
53
  def self.make_org(org)
50
54
  if org.is_a?(String)
51
- return orgs[org]
55
+ orgs[org]
52
56
  elsif org.is_a?(ChefFixie::Sql::Org)
53
- return org
57
+ org
54
58
  else
55
59
  raise Exception "Expected an org, got a #{org.class}"
56
60
  end
57
- end
61
+ end
58
62
  end
59
63
  end
@@ -1,3 +1,3 @@
1
1
  module ChefFixie
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -1,46 +1,45 @@
1
1
 
2
- require 'rspec'
2
+ require "rspec"
3
3
  require "spec_helper"
4
- require 'chef_fixie'
5
- require 'chef_fixie/config'
4
+ require "chef_fixie"
5
+ require "chef_fixie/config"
6
6
 
7
7
  RSpec.describe ChefFixie::Sql::Orgs, "ACL access" do
8
- let (:test_org_name) { "ponyville"}
8
+ let (:test_org_name) { "ponyville" }
9
9
  let (:orgs) { ChefFixie::Sql::Orgs.new }
10
10
  let (:users) { ChefFixie::Sql::Users.new }
11
11
  let (:test_org) { orgs[test_org_name] }
12
12
 
13
13
  # TODO this should use a freshly created object and purge it afterwords.
14
14
  # But we need to write the create object feature still
15
-
15
+
16
16
  context "Fetch acl for actor (client)" do
17
17
  let (:testclient) { test_org.clients.all.first }
18
- let (:testuser) { users['spitfire'] }
19
- let (:pivotal) { users['pivotal'] }
18
+ let (:testuser) { users["spitfire"] }
19
+ let (:pivotal) { users["pivotal"] }
20
20
  let (:client_container) { test_org.containers["clients"] }
21
-
21
+
22
22
  it "We can fetch the acl" do
23
23
  acl = testclient.acl
24
- expect(acl.keys).to include(* %w(create read update delete grant))
24
+ expect(acl.keys).to include(* %w{create read update delete grant})
25
25
  end
26
26
 
27
27
  it "we can add a user to an ace" do
28
- # This requires either a temp object or good cleanup
28
+ # This requires either a temp object or good cleanup
29
29
  # acl = testclient.acl
30
30
  # expect(acl["read"]["actors"].not_to include("wonderbolts")
31
-
31
+
32
32
  testclient.ace_add(:read, testuser)
33
33
 
34
34
  acl = testclient.acl
35
35
  expect(acl["read"]["actors"]).to include([:global, testuser.name])
36
36
  end
37
-
37
+
38
38
  it "we can add then delete a user from an ace" do
39
39
  testclient.ace_add(:read, testuser)
40
40
  acl = testclient.acl
41
41
  expect(acl["read"]["actors"]).to include([:global, testuser.name])
42
42
 
43
-
44
43
  testclient.ace_delete(:read, testuser)
45
44
 
46
45
  acl = testclient.acl
@@ -49,26 +48,26 @@ RSpec.describe ChefFixie::Sql::Orgs, "ACL access" do
49
48
 
50
49
  it "we can copy users from another acl" do
51
50
  testclient.ace_delete(:all, pivotal)
52
-
51
+
53
52
  testclient.acl_add_from_object(client_container)
54
53
 
55
54
  acl = testclient.acl
56
- %w(create read update delete grant).each do |action|
55
+ %w{create read update delete grant}.each do |action|
57
56
  expect(acl[action]["actors"]).to include([:global, pivotal.name])
58
57
  end
59
58
  end
60
-
59
+
61
60
  end
62
61
 
63
62
  context "ACE Membership" do
64
-
65
- let (:admingroup) { test_org.groups['admins'] }
66
- let (:testobject) { test_org.groups['admins'] }
67
- let (:notadmingroup) { test_org.groups['clients'] }
68
- let (:adminuser) { users['rainbowdash'] }
69
- let (:notadminuser) { users['mary'] }
70
- let (:pivotal) { users['pivotal'] }
71
-
63
+
64
+ let (:admingroup) { test_org.groups["admins"] }
65
+ let (:testobject) { test_org.groups["admins"] }
66
+ let (:notadmingroup) { test_org.groups["clients"] }
67
+ let (:adminuser) { users["rainbowdash"] }
68
+ let (:notadminuser) { users["mary"] }
69
+ let (:pivotal) { users["pivotal"] }
70
+
72
71
  it "Privileged users and groups are part of the read ACE" do
73
72
  expect(testobject.ace_member?(:read, admingroup)).to be true
74
73
  expect(testobject.ace_member?(:read, pivotal)).to be true
@@ -79,5 +78,4 @@ RSpec.describe ChefFixie::Sql::Orgs, "ACL access" do
79
78
  end
80
79
  end
81
80
 
82
-
83
81
  end
@@ -1,18 +1,17 @@
1
1
 
2
- require 'rspec'
2
+ require "rspec"
3
3
  require "spec_helper"
4
- require 'chef_fixie'
5
- require 'chef_fixie/config'
4
+ require "chef_fixie"
5
+ require "chef_fixie/config"
6
6
 
7
7
  RSpec.describe ChefFixie::Sql::Associations, "Associations tests" do
8
8
  let (:test_org_name) { "ponyville" }
9
9
  let (:orgs) { ChefFixie::Sql::Orgs.new }
10
- let (:test_org) { orgs[test_org_name]}
10
+ let (:test_org) { orgs[test_org_name] }
11
11
 
12
12
  let (:users) { ChefFixie::Sql::Users.new }
13
13
  let (:assocs) { ChefFixie::Sql::Associations.new }
14
14
 
15
-
16
15
  context "Basic functionality of association spec" do
17
16
  let ("test_user_name") { "fluttershy" }
18
17
  let ("test_user") { users[test_user_name] }
@@ -37,11 +36,9 @@ RSpec.describe ChefFixie::Sql::Associations, "Associations tests" do
37
36
  expect(assoc_item.org_id).to eq(test_org.id)
38
37
 
39
38
  # test user not in org
40
- expect(assocs.by_org_id_user_id(test_org.id, users['mary'].id)).to be_nil
39
+ expect(assocs.by_org_id_user_id(test_org.id, users["mary"].id)).to be_nil
41
40
  end
42
41
 
43
-
44
42
  end
45
43
 
46
-
47
44
  end
@@ -1,17 +1,17 @@
1
1
  # -*- indent-tabs-mode: nil; fill-column: 110 -*-
2
- require 'rspec'
2
+ require "rspec"
3
3
  require "spec_helper"
4
- require 'chef_fixie'
5
- require 'chef_fixie/config'
4
+ require "chef_fixie"
5
+ require "chef_fixie/config"
6
6
 
7
7
  RSpec.describe ChefFixie::CheckOrgAssociations, "Association checker" do
8
- let (:test_org_name) { "ponyville"}
8
+ let (:test_org_name) { "ponyville" }
9
9
  let (:orgs) { ChefFixie::Sql::Orgs.new }
10
10
  let (:test_org) { orgs[test_org_name] }
11
11
 
12
12
  let (:users) { ChefFixie::Sql::Users.new }
13
- let (:adminuser) { users['rainbowdash'] }
14
- let (:notorguser) { users['mary'] }
13
+ let (:adminuser) { users["rainbowdash"] }
14
+ let (:notorguser) { users["mary"] }
15
15
 
16
16
  # TODO this should use a freshly created object and purge it afterwords.
17
17
  # But we need to write the create object feature still
@@ -29,10 +29,10 @@ RSpec.describe ChefFixie::CheckOrgAssociations, "Association checker" do
29
29
  end
30
30
 
31
31
  after :each do
32
- usag = test_org.groups[adminuser.id]
32
+ usag = test_org.groups[adminuser.id]
33
33
 
34
34
  usag.group_add(adminuser)
35
- test_org.groups['users'].group_add(usag)
35
+ test_org.groups["users"].group_add(usag)
36
36
 
37
37
  adminuser.ace_add(:read, test_org.global_admins)
38
38
 
@@ -47,7 +47,7 @@ RSpec.describe ChefFixie::CheckOrgAssociations, "Association checker" do
47
47
 
48
48
  it "Detects user missing from usag" do
49
49
  # break it
50
- usag = test_org.groups[adminuser.id]
50
+ usag = test_org.groups[adminuser.id]
51
51
  usag.group_delete(adminuser)
52
52
 
53
53
  expect(ChefFixie::CheckOrgAssociations.check_association(test_org, adminuser)).to be :user_not_in_usag
@@ -55,8 +55,8 @@ RSpec.describe ChefFixie::CheckOrgAssociations, "Association checker" do
55
55
 
56
56
  it "Detects usag missing from users group" do
57
57
  # break it
58
- usag = test_org.groups[adminuser.id]
59
- test_org.groups['users'].group_delete(usag)
58
+ usag = test_org.groups[adminuser.id]
59
+ test_org.groups["users"].group_delete(usag)
60
60
 
61
61
  expect(ChefFixie::CheckOrgAssociations.check_association(test_org, adminuser)).to be :usag_not_in_users
62
62
  end
@@ -78,10 +78,10 @@ RSpec.describe ChefFixie::CheckOrgAssociations, "Association checker" do
78
78
  end
79
79
 
80
80
  after :each do
81
- usag = test_org.groups[adminuser.id]
81
+ usag = test_org.groups[adminuser.id]
82
82
 
83
83
  usag.group_add(adminuser)
84
- test_org.groups['users'].group_add(usag)
84
+ test_org.groups["users"].group_add(usag)
85
85
 
86
86
  adminuser.ace_add(:read, test_org.global_admins)
87
87
 
@@ -106,7 +106,7 @@ RSpec.describe ChefFixie::CheckOrgAssociations, "Association checker" do
106
106
  it "Fixes usag missing from users group" do
107
107
  # break it
108
108
  usag = test_org.groups[adminuser.id]
109
- test_org.groups['users'].group_delete(usag)
109
+ test_org.groups["users"].group_delete(usag)
110
110
 
111
111
  expect(ChefFixie::CheckOrgAssociations.fix_association(test_org, adminuser)).to be true
112
112
  expect(ChefFixie::CheckOrgAssociations.check_association(test_org, adminuser)).to be true
@@ -124,7 +124,6 @@ RSpec.describe ChefFixie::CheckOrgAssociations, "Association checker" do
124
124
 
125
125
  end
126
126
 
127
-
128
127
  # TODO Break the org and check it!
129
128
  context "Global org check" do
130
129
 
@@ -135,6 +134,4 @@ RSpec.describe ChefFixie::CheckOrgAssociations, "Association checker" do
135
134
 
136
135
  end
137
136
 
138
-
139
-
140
137
  end
@@ -1,11 +1,11 @@
1
1
  # -*- indent-tabs-mode: nil; fill-column: 110 -*-
2
- require 'rspec'
2
+ require "rspec"
3
3
  require "spec_helper"
4
- require 'chef_fixie'
5
- require 'chef_fixie/config'
4
+ require "chef_fixie"
5
+ require "chef_fixie/config"
6
6
 
7
7
  RSpec.describe ChefFixie::Sql::Groups, "Group access" do
8
- let (:test_org_name) { "ponyville"}
8
+ let (:test_org_name) { "ponyville" }
9
9
  let (:orgs) { ChefFixie::Sql::Orgs.new }
10
10
  let (:users) { ChefFixie::Sql::Users.new }
11
11
  let (:test_org) { orgs[test_org_name] }
@@ -14,9 +14,9 @@ RSpec.describe ChefFixie::Sql::Groups, "Group access" do
14
14
  # But we need to write the create object feature still
15
15
 
16
16
  context "Groups" do
17
- let (:testgroup) { test_org.groups['admins'] }
18
- let (:adminuser) { users['rainbowdash'] }
19
- let (:notadminuser) { users['mary'] }
17
+ let (:testgroup) { test_org.groups["admins"] }
18
+ let (:adminuser) { users["rainbowdash"] }
19
+ let (:notadminuser) { users["mary"] }
20
20
 
21
21
  it "Members are part of the group" do
22
22
  expect(testgroup.member?(adminuser)).to be true
@@ -25,10 +25,6 @@ RSpec.describe ChefFixie::Sql::Groups, "Group access" do
25
25
  expect(testgroup.member?(notadminuser)).to be false
26
26
  end
27
27
 
28
-
29
28
  end
30
29
 
31
-
32
-
33
-
34
30
  end
@@ -1,13 +1,13 @@
1
1
 
2
- require 'rspec'
2
+ require "rspec"
3
3
  require "spec_helper"
4
- require 'chef_fixie'
5
- require 'chef_fixie/config'
4
+ require "chef_fixie"
5
+ require "chef_fixie/config"
6
6
 
7
7
  RSpec.describe ChefFixie::Sql::Orgs, "Organizations access" do
8
8
  let (:test_org_name) { "ponyville" }
9
9
  let (:orgs) { ChefFixie::Sql::Orgs.new }
10
- let (:test_org) { orgs[test_org_name]}
10
+ let (:test_org) { orgs[test_org_name] }
11
11
 
12
12
  context "Basic functionality of org accessor" do
13
13
 
@@ -22,5 +22,4 @@ RSpec.describe ChefFixie::Sql::Orgs, "Organizations access" do
22
22
 
23
23
  end
24
24
 
25
-
26
25
  end
@@ -1,11 +1,11 @@
1
1
 
2
- require 'rspec'
2
+ require "rspec"
3
3
  require "spec_helper"
4
- require 'chef_fixie'
5
- require 'chef_fixie/config'
4
+ require "chef_fixie"
5
+ require "chef_fixie/config"
6
6
 
7
7
  RSpec.describe ChefFixie::Sql::Orgs, "Organizations access" do
8
- let (:test_org) { "ponyville"}
8
+ let (:test_org) { "ponyville" }
9
9
 
10
10
  context "Basic access to orgs" do
11
11
  let (:orgs) { ChefFixie::Sql::Orgs.new }
@@ -15,7 +15,7 @@ RSpec.describe ChefFixie::Sql::Orgs, "Organizations access" do
15
15
 
16
16
  it "We can list orgs" do
17
17
  # array matcher requires a splat. (I didn't know this )
18
- expect(orgs.list).to include( * %w(acme ponyville wonderbolts) )
18
+ expect(orgs.list).to include( * %w{acme ponyville wonderbolts} )
19
19
  end
20
20
  it "We can list orgs with a limit" do
21
21
  # array matcher requires a splat. (I didn't know this )
@@ -38,7 +38,7 @@ RSpec.describe ChefFixie::Sql::Orgs, "Organizations access" do
38
38
  end
39
39
 
40
40
  # TODO: Automatically extract this from the filter by field
41
- %w(name, id, full_name, authz_id).each do |accessor|
41
+ %w{name, id, full_name, authz_id}.each do |accessor|
42
42
  it "We can access an org by #{accessor}" do
43
43
  expect(orgs.by_name(test_org).all.count).to eq(1)
44
44
  expect(orgs.by_name(test_org).all.first.name).to eq(the_org.name)
@@ -47,7 +47,4 @@ RSpec.describe ChefFixie::Sql::Orgs, "Organizations access" do
47
47
 
48
48
  end
49
49
 
50
-
51
-
52
-
53
50
  end
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  # loaded once.
5
5
  #
6
6
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
- require 'chef_fixie/config'
7
+ require "chef_fixie/config"
8
8
 
9
9
  def load_from_config_example
10
10
  # load from config file
@@ -13,7 +13,7 @@ def load_from_config_example
13
13
  end
14
14
 
15
15
  def load_from_opscode
16
- ChefFixie::Config::instance.load_from_pc
16
+ ChefFixie::Config.instance.load_from_pc
17
17
  end
18
18
 
19
19
  RSpec.configure do |config|
@@ -24,7 +24,7 @@ RSpec.configure do |config|
24
24
  # order dependency and want to debug it, you can fix the order by providing
25
25
  # the seed, which is printed after each run.
26
26
  # --seed 1234
27
- config.order = 'random'
27
+ config.order = "random"
28
28
 
29
29
  # configure specs
30
30
 
@@ -35,7 +35,6 @@ RSpec.configure do |config|
35
35
  # Horrible shameful hack TODO FIXME
36
36
  # We can't include a lot of the SQL code until we configure things, because
37
37
  # we inherit from Model e.g.
38
- # class Users < Sequel::Model(:users)
39
- require 'chef_fixie'
38
+ # class Users < Sequel::Model(:users)
39
+ require "chef_fixie"
40
40
  end
41
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef_fixie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Anderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2021-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 11.12.2
19
+ version: '15.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 11.12.2
26
+ version: '15.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ffi-yajl
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -120,20 +120,6 @@ dependencies:
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
- - !ruby/object:Gem::Dependency
124
- name: bundler
125
- requirement: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - "~>"
128
- - !ruby/object:Gem::Version
129
- version: '1.3'
130
- type: :development
131
- prerelease: false
132
- version_requirements: !ruby/object:Gem::Requirement
133
- requirements:
134
- - - "~>"
135
- - !ruby/object:Gem::Version
136
- version: '1.3'
137
123
  - !ruby/object:Gem::Dependency
138
124
  name: rake
139
125
  requirement: !ruby/object:Gem::Requirement
@@ -216,8 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
202
  - !ruby/object:Gem::Version
217
203
  version: '0'
218
204
  requirements: []
219
- rubyforge_project:
220
- rubygems_version: 2.7.6
205
+ rubygems_version: 3.1.4
221
206
  signing_key:
222
207
  specification_version: 4
223
208
  summary: Low level manipulation tool for Chef Server 12 and later