artifactory 2.5.2 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -2
  3. data/CHANGELOG.md +6 -0
  4. data/Gemfile +9 -13
  5. data/README.md +10 -1
  6. data/Rakefile +16 -7
  7. data/appveyor.yml +4 -2
  8. data/artifactory.gemspec +14 -14
  9. data/lib/artifactory.rb +26 -26
  10. data/lib/artifactory/client.rb +25 -23
  11. data/lib/artifactory/configurable.rb +1 -0
  12. data/lib/artifactory/defaults.rb +24 -15
  13. data/lib/artifactory/errors.rb +2 -2
  14. data/lib/artifactory/resources/artifact.rb +34 -33
  15. data/lib/artifactory/resources/backup.rb +5 -5
  16. data/lib/artifactory/resources/base.rb +7 -7
  17. data/lib/artifactory/resources/build.rb +15 -15
  18. data/lib/artifactory/resources/build_component.rb +4 -4
  19. data/lib/artifactory/resources/group.rb +4 -4
  20. data/lib/artifactory/resources/layout.rb +3 -3
  21. data/lib/artifactory/resources/ldap_setting.rb +7 -6
  22. data/lib/artifactory/resources/mail_server.rb +3 -3
  23. data/lib/artifactory/resources/permission_target.rb +20 -20
  24. data/lib/artifactory/resources/plugin.rb +1 -1
  25. data/lib/artifactory/resources/repository.rb +20 -20
  26. data/lib/artifactory/resources/system.rb +6 -6
  27. data/lib/artifactory/resources/url_base.rb +4 -3
  28. data/lib/artifactory/resources/user.rb +4 -4
  29. data/lib/artifactory/util.rb +10 -10
  30. data/lib/artifactory/version.rb +1 -1
  31. data/spec/integration/resources/artifact_spec.rb +31 -31
  32. data/spec/integration/resources/backup.rb +7 -7
  33. data/spec/integration/resources/build_component_spec.rb +18 -18
  34. data/spec/integration/resources/build_spec.rb +15 -15
  35. data/spec/integration/resources/group_spec.rb +16 -16
  36. data/spec/integration/resources/layout_spec.rb +7 -7
  37. data/spec/integration/resources/ldap_setting_spec.rb +7 -7
  38. data/spec/integration/resources/mail_server_spec.rb +7 -7
  39. data/spec/integration/resources/permission_target_spec.rb +35 -35
  40. data/spec/integration/resources/repository_spec.rb +14 -14
  41. data/spec/integration/resources/system_spec.rb +20 -21
  42. data/spec/integration/resources/url_base_spec.rb +7 -7
  43. data/spec/integration/resources/user_spec.rb +16 -16
  44. data/spec/spec_helper.rb +11 -11
  45. data/spec/support/api_server.rb +13 -13
  46. data/spec/support/api_server/artifact_endpoints.rb +94 -94
  47. data/spec/support/api_server/build_component_endpoints.rb +18 -18
  48. data/spec/support/api_server/build_endpoints.rb +76 -76
  49. data/spec/support/api_server/group_endpoints.rb +24 -24
  50. data/spec/support/api_server/permission_target_endpoints.rb +24 -24
  51. data/spec/support/api_server/repository_endpoints.rb +82 -82
  52. data/spec/support/api_server/status_endpoints.rb +5 -5
  53. data/spec/support/api_server/system_endpoints.rb +17 -18
  54. data/spec/support/api_server/user_endpoints.rb +30 -30
  55. data/spec/unit/artifactory_spec.rb +17 -17
  56. data/spec/unit/client_spec.rb +43 -43
  57. data/spec/unit/resources/artifact_spec.rb +256 -256
  58. data/spec/unit/resources/backup_spec.rb +8 -8
  59. data/spec/unit/resources/base_spec.rb +51 -51
  60. data/spec/unit/resources/build_component_spec.rb +45 -45
  61. data/spec/unit/resources/build_spec.rb +98 -98
  62. data/spec/unit/resources/defaults_spec.rb +4 -4
  63. data/spec/unit/resources/group_spec.rb +36 -36
  64. data/spec/unit/resources/layout_spec.rb +8 -8
  65. data/spec/unit/resources/ldap_setting_spec.rb +8 -8
  66. data/spec/unit/resources/mail_server_spec.rb +8 -8
  67. data/spec/unit/resources/permission_target_spec.rb +79 -79
  68. data/spec/unit/resources/plugin_spec.rb +7 -7
  69. data/spec/unit/resources/repository_spec.rb +98 -98
  70. data/spec/unit/resources/system_spec.rb +30 -30
  71. data/spec/unit/resources/url_base_spec.rb +8 -8
  72. data/spec/unit/resources/user_spec.rb +40 -40
  73. metadata +3 -3
@@ -4,22 +4,22 @@ module Artifactory
4
4
  describe Defaults do
5
5
  describe "read_timeout" do
6
6
  before(:each) do
7
- ENV['ARTIFACTORY_READ_TIMEOUT'] = "60"
7
+ ENV["ARTIFACTORY_READ_TIMEOUT"] = "60"
8
8
  end
9
9
 
10
10
  after(:each) do
11
- ENV.delete('ARTIFACTORY_READ_TIMEOUT')
11
+ ENV.delete("ARTIFACTORY_READ_TIMEOUT")
12
12
  end
13
13
 
14
14
  it "returns Fixnums even when given strings" do
15
15
  expect(subject.read_timeout).to be_an_instance_of Fixnum
16
16
  end
17
17
 
18
- it 'returns a non-zero value' do
18
+ it "returns a non-zero value" do
19
19
  expect(subject.read_timeout).to be > 0
20
20
  end
21
21
 
22
- it 'does not return a nil value' do
22
+ it "does not return a nil value" do
23
23
  expect(subject.read_timeout).not_to be nil
24
24
  end
25
25
  end
@@ -1,9 +1,9 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Artifactory
4
4
  describe Resource::Group do
5
5
  let(:client) { double(:client) }
6
- let(:endpoint_host) { 'http://33.33.33.11' }
6
+ let(:endpoint_host) { "http://33.33.33.11" }
7
7
  let(:endpoint) { "#{endpoint_host}/" }
8
8
 
9
9
  before(:each) do
@@ -11,94 +11,94 @@ module Artifactory
11
11
  allow(client).to receive(:get).and_return(response) if defined?(response)
12
12
  end
13
13
 
14
- describe '.all' do
14
+ describe ".all" do
15
15
  let(:response) do
16
16
  [
17
- { 'uri' => 'a' },
18
- { 'uri' => 'b' },
19
- { 'uri' => 'c' },
17
+ { "uri" => "a" },
18
+ { "uri" => "b" },
19
+ { "uri" => "c" },
20
20
  ]
21
21
  end
22
22
  before do
23
- allow(described_class).to receive(:from_url).with('a', client: client).and_return('a')
24
- allow(described_class).to receive(:from_url).with('b', client: client).and_return('b')
25
- allow(described_class).to receive(:from_url).with('c', client: client).and_return('c')
23
+ allow(described_class).to receive(:from_url).with("a", client: client).and_return("a")
24
+ allow(described_class).to receive(:from_url).with("b", client: client).and_return("b")
25
+ allow(described_class).to receive(:from_url).with("c", client: client).and_return("c")
26
26
  end
27
27
 
28
- it 'gets /api/security/groups' do
29
- expect(client).to receive(:get).with('/api/security/groups').once
28
+ it "gets /api/security/groups" do
29
+ expect(client).to receive(:get).with("/api/security/groups").once
30
30
  described_class.all
31
31
  end
32
32
 
33
- it 'returns the groups' do
34
- expect(described_class.all).to eq(['a', 'b', 'c'])
33
+ it "returns the groups" do
34
+ expect(described_class.all).to eq(%w{a b c})
35
35
  end
36
36
  end
37
37
 
38
- describe '.find' do
38
+ describe ".find" do
39
39
  let(:response) { {} }
40
40
 
41
41
  it 'gets /api/repositories/#{name}' do
42
- expect(client).to receive(:get).with('/api/security/groups/readers').once
43
- described_class.find('readers')
42
+ expect(client).to receive(:get).with("/api/security/groups/readers").once
43
+ described_class.find("readers")
44
44
  end
45
45
  end
46
46
 
47
- describe '.from_url' do
47
+ describe ".from_url" do
48
48
  let(:response) { {} }
49
49
 
50
- it 'constructs a new instance from the result' do
50
+ it "constructs a new instance from the result" do
51
51
  expect(client).to receive(:endpoint).and_return(endpoint)
52
52
  expect(described_class).to receive(:from_hash).once
53
- described_class.from_url('/api/security/groups/readers')
53
+ described_class.from_url("/api/security/groups/readers")
54
54
  end
55
55
  end
56
56
 
57
- describe '.from_hash' do
57
+ describe ".from_hash" do
58
58
  let(:hash) do
59
59
  {
60
- 'name' => 'readers',
61
- 'description' => 'This list of read-only users',
62
- 'autoJoin' => true,
63
- 'realm' => 'artifactory',
64
- 'realmAttributes' => nil,
60
+ "name" => "readers",
61
+ "description" => "This list of read-only users",
62
+ "autoJoin" => true,
63
+ "realm" => "artifactory",
64
+ "realmAttributes" => nil,
65
65
  }
66
66
  end
67
67
 
68
- it 'creates a new instance' do
68
+ it "creates a new instance" do
69
69
  instance = described_class.from_hash(hash)
70
- expect(instance.name).to eq('readers')
71
- expect(instance.description).to eq('This list of read-only users')
70
+ expect(instance.name).to eq("readers")
71
+ expect(instance.description).to eq("This list of read-only users")
72
72
  expect(instance.auto_join).to be_truthy
73
- expect(instance.realm).to eq('artifactory')
73
+ expect(instance.realm).to eq("artifactory")
74
74
  expect(instance.realm_attributes).to be_nil
75
75
  end
76
76
  end
77
77
 
78
- describe '#save' do
78
+ describe "#save" do
79
79
  let(:client) { double }
80
80
  before do
81
81
  subject.client = client
82
- subject.name = 'deployers'
82
+ subject.name = "deployers"
83
83
  end
84
84
 
85
- context 'when the group is new' do
85
+ context "when the group is new" do
86
86
  before do
87
87
  allow(described_class).to receive(:find).with(subject.name, client: client).and_return(nil)
88
88
  end
89
89
 
90
- it 'PUTS the group to the server' do
90
+ it "PUTS the group to the server" do
91
91
  expect(client).to receive(:put).with("/api/security/groups/#{subject.name}", kind_of(String), kind_of(Hash))
92
92
  subject.save
93
93
  end
94
94
  end
95
95
 
96
- context 'when the group exists' do
96
+ context "when the group exists" do
97
97
  before do
98
- allow(described_class).to receive(:find).with(subject.name, client: client).and_return({name: subject.name})
98
+ allow(described_class).to receive(:find).with(subject.name, client: client).and_return({ name: subject.name })
99
99
  end
100
100
 
101
- it 'POSTS the group to the server' do
101
+ it "POSTS the group to the server" do
102
102
  expect(client).to receive(:post).with("/api/security/groups/#{subject.name}", kind_of(String), kind_of(Hash))
103
103
  subject.save
104
104
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Artifactory
4
4
  describe Resource::Layout do
@@ -9,7 +9,7 @@ module Artifactory
9
9
  allow(client).to receive(:get).and_return(response) if defined?(response)
10
10
  end
11
11
 
12
- describe '.all' do
12
+ describe ".all" do
13
13
  doc = <<-XML
14
14
  <config>
15
15
  <repoLayouts>
@@ -27,14 +27,14 @@ module Artifactory
27
27
  allow(Resource::System).to receive(:configuration).and_return(xml)
28
28
  end
29
29
 
30
- it 'returns the layouts' do
30
+ it "returns the layouts" do
31
31
  expect(described_class.all).to be_a(Array)
32
32
  expect(described_class.all.first).to be_a(described_class)
33
- expect(described_class.all.first.name).to eq('fake-layout')
33
+ expect(described_class.all.first.name).to eq("fake-layout")
34
34
  end
35
35
  end
36
36
 
37
- describe '.find' do
37
+ describe ".find" do
38
38
  doc = <<-XML
39
39
  <config>
40
40
  <repoLayouts>
@@ -52,9 +52,9 @@ module Artifactory
52
52
  allow(Resource::System).to receive(:configuration).and_return(xml)
53
53
  end
54
54
 
55
- it 'returns the found layout' do
56
- expect(described_class.find('found-layout')).to be_a(described_class)
57
- expect(described_class.find('found-layout').name).to eq('found-layout')
55
+ it "returns the found layout" do
56
+ expect(described_class.find("found-layout")).to be_a(described_class)
57
+ expect(described_class.find("found-layout").name).to eq("found-layout")
58
58
  end
59
59
  end
60
60
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Artifactory
4
4
  describe Resource::LDAPSetting do
@@ -9,7 +9,7 @@ module Artifactory
9
9
  allow(client).to receive(:get).and_return(response) if defined?(response)
10
10
  end
11
11
 
12
- describe '.all' do
12
+ describe ".all" do
13
13
  doc = <<-XML
14
14
  <config>
15
15
  <security>
@@ -29,14 +29,14 @@ module Artifactory
29
29
  allow(Resource::System).to receive(:configuration).and_return(xml)
30
30
  end
31
31
 
32
- it 'returns the ldap settings' do
32
+ it "returns the ldap settings" do
33
33
  expect(described_class.all).to be_a(Array)
34
34
  expect(described_class.all.first).to be_a(described_class)
35
- expect(described_class.all.first.key).to eq('example-ldap')
35
+ expect(described_class.all.first.key).to eq("example-ldap")
36
36
  end
37
37
  end
38
38
 
39
- describe '.find' do
39
+ describe ".find" do
40
40
  doc = <<-XML
41
41
  <config>
42
42
  <security>
@@ -56,9 +56,9 @@ module Artifactory
56
56
  allow(Resource::System).to receive(:configuration).and_return(xml)
57
57
  end
58
58
 
59
- it 'returns the found ldap setting' do
60
- expect(described_class.find('viridian-ldap')).to be_a(described_class)
61
- expect(described_class.find('viridian-ldap').key).to eq('viridian-ldap')
59
+ it "returns the found ldap setting" do
60
+ expect(described_class.find("viridian-ldap")).to be_a(described_class)
61
+ expect(described_class.find("viridian-ldap").key).to eq("viridian-ldap")
62
62
  end
63
63
  end
64
64
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Artifactory
4
4
  describe Resource::MailServer do
@@ -9,7 +9,7 @@ module Artifactory
9
9
  allow(client).to receive(:get).and_return(response) if defined?(response)
10
10
  end
11
11
 
12
- describe '.all' do
12
+ describe ".all" do
13
13
  doc = <<-XML
14
14
  <config>
15
15
  <mailServer>
@@ -25,14 +25,14 @@ module Artifactory
25
25
  allow(Resource::System).to receive(:configuration).and_return(xml)
26
26
  end
27
27
 
28
- it 'returns the mail server settings' do
28
+ it "returns the mail server settings" do
29
29
  expect(described_class.all).to be_a(Array)
30
30
  expect(described_class.all.first).to be_a(described_class)
31
- expect(described_class.all.first.host).to eq('smtp.gmail.com')
31
+ expect(described_class.all.first.host).to eq("smtp.gmail.com")
32
32
  end
33
33
  end
34
34
 
35
- describe '.find' do
35
+ describe ".find" do
36
36
  doc = <<-XML
37
37
  <config>
38
38
  <mailServer>
@@ -48,9 +48,9 @@ module Artifactory
48
48
  allow(Resource::System).to receive(:configuration).and_return(xml)
49
49
  end
50
50
 
51
- it 'returns the found mail server setting' do
52
- expect(described_class.find('mailserver.example.com')).to be_a(described_class)
53
- expect(described_class.find('mailserver.example.com').host).to eq('mailserver.example.com')
51
+ it "returns the found mail server setting" do
52
+ expect(described_class.find("mailserver.example.com")).to be_a(described_class)
53
+ expect(described_class.find("mailserver.example.com").host).to eq("mailserver.example.com")
54
54
  end
55
55
  end
56
56
  end
@@ -1,9 +1,9 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Artifactory
4
4
  describe Resource::PermissionTarget do
5
5
  let(:client) { double(:client) }
6
- let(:endpoint_host) { 'http://33.33.33.11' }
6
+ let(:endpoint_host) { "http://33.33.33.11" }
7
7
  let(:endpoint) { "#{endpoint_host}/" }
8
8
 
9
9
  before(:each) do
@@ -11,178 +11,178 @@ module Artifactory
11
11
  allow(client).to receive(:get).and_return(response) if defined?(response)
12
12
  end
13
13
 
14
- describe '.all' do
14
+ describe ".all" do
15
15
  let(:response) do
16
16
  [
17
- { 'uri' => 'a' },
18
- { 'uri' => 'b' },
19
- { 'uri' => 'c' },
17
+ { "uri" => "a" },
18
+ { "uri" => "b" },
19
+ { "uri" => "c" },
20
20
  ]
21
21
  end
22
22
  before do
23
- allow(described_class).to receive(:from_url).with('a', client: client).and_return('a')
24
- allow(described_class).to receive(:from_url).with('b', client: client).and_return('b')
25
- allow(described_class).to receive(:from_url).with('c', client: client).and_return('c')
23
+ allow(described_class).to receive(:from_url).with("a", client: client).and_return("a")
24
+ allow(described_class).to receive(:from_url).with("b", client: client).and_return("b")
25
+ allow(described_class).to receive(:from_url).with("c", client: client).and_return("c")
26
26
  end
27
27
 
28
- it 'gets /api/security/permissions' do
29
- expect(client).to receive(:get).with('/api/security/permissions').once
28
+ it "gets /api/security/permissions" do
29
+ expect(client).to receive(:get).with("/api/security/permissions").once
30
30
  described_class.all
31
31
  end
32
32
 
33
- it 'returns the permissions' do
34
- expect(described_class.all).to eq(['a', 'b', 'c'])
33
+ it "returns the permissions" do
34
+ expect(described_class.all).to eq(%w{a b c})
35
35
  end
36
36
  end
37
37
 
38
- describe '.find' do
38
+ describe ".find" do
39
39
  let(:response) { {} }
40
40
 
41
41
  it 'gets /api/security/permissions/#{name}' do
42
- expect(client).to receive(:get).with('/api/security/permissions/Any%20Remote').once
43
- described_class.find('Any Remote')
42
+ expect(client).to receive(:get).with("/api/security/permissions/Any%20Remote").once
43
+ described_class.find("Any Remote")
44
44
  end
45
45
  end
46
46
 
47
- describe '.from_url' do
47
+ describe ".from_url" do
48
48
  let(:response) { {} }
49
49
 
50
- it 'constructs a new instance from the result' do
50
+ it "constructs a new instance from the result" do
51
51
  expect(client).to receive(:endpoint).and_return(endpoint)
52
52
  expect(described_class).to receive(:from_hash).once
53
- described_class.from_url('/api/security/permissions/AnyRemote')
53
+ described_class.from_url("/api/security/permissions/AnyRemote")
54
54
  end
55
55
  end
56
56
 
57
- describe '.from_hash' do
57
+ describe ".from_hash" do
58
58
  let(:hash) do
59
59
  {
60
- 'name' => 'Test Remote',
61
- 'includes_pattern' => '**',
62
- 'excludes_pattern' => '',
63
- 'repositories' => ['ANY REMOTE'],
64
- 'principals' => { 'users' => { 'anonymous' => ['w', 'r'] }, 'groups' => {} }
60
+ "name" => "Test Remote",
61
+ "includes_pattern" => "**",
62
+ "excludes_pattern" => "",
63
+ "repositories" => ["ANY REMOTE"],
64
+ "principals" => { "users" => { "anonymous" => %w{w r} }, "groups" => {} },
65
65
  }
66
66
  end
67
67
 
68
- it 'creates a new instance' do
68
+ it "creates a new instance" do
69
69
  instance = described_class.from_hash(hash)
70
- expect(instance.name).to eq('Test Remote')
71
- expect(instance.includes_pattern).to eq('**')
72
- expect(instance.excludes_pattern).to eq('')
73
- expect(instance.repositories).to eq(['ANY REMOTE'])
74
- expect(instance.principals).to eq({ 'users' => { 'anonymous' => ['deploy', 'read'] }, 'groups' => {} })
70
+ expect(instance.name).to eq("Test Remote")
71
+ expect(instance.includes_pattern).to eq("**")
72
+ expect(instance.excludes_pattern).to eq("")
73
+ expect(instance.repositories).to eq(["ANY REMOTE"])
74
+ expect(instance.principals).to eq({ "users" => { "anonymous" => %w{deploy read} }, "groups" => {} })
75
75
  end
76
76
  end
77
77
 
78
78
  describe Artifactory::Resource::PermissionTarget::Principal do
79
- context 'principal object' do
80
- users = { 'anonymous_users' => ['admin', 'deploy', 'read'] }
81
- groups = { 'anonymous_groups' => ['delete', 'read'] }
79
+ context "principal object" do
80
+ users = { "anonymous_users" => %w{admin deploy read} }
81
+ groups = { "anonymous_groups" => %w{delete read} }
82
82
  instance = described_class.new(users, groups)
83
83
 
84
- it 'has unabbreviated users' do
85
- expect(instance.users).to eq( { 'anonymous_users' => ['admin', 'deploy', 'read'] } )
84
+ it "has unabbreviated users" do
85
+ expect(instance.users).to eq( { "anonymous_users" => %w{admin deploy read} } )
86
86
  end
87
87
 
88
- it 'has unabbreviated groups' do
89
- expect(instance.groups).to eq( { 'anonymous_groups' => ['delete', 'read'] } )
88
+ it "has unabbreviated groups" do
89
+ expect(instance.groups).to eq( { "anonymous_groups" => %w{delete read} } )
90
90
  end
91
91
 
92
- it 'abbreviates' do
93
- expect(instance.to_abbreviated).to eq( { 'users' => { 'anonymous_users' => ['m', 'r', 'w'] }, 'groups' => { 'anonymous_groups' => ['d', 'r'] } } )
92
+ it "abbreviates" do
93
+ expect(instance.to_abbreviated).to eq( { "users" => { "anonymous_users" => %w{m r w} }, "groups" => { "anonymous_groups" => %w{d r} } } )
94
94
  end
95
95
  end
96
96
  end
97
97
 
98
- describe '#save' do
98
+ describe "#save" do
99
99
  let(:client) { double }
100
100
  before do
101
101
  subject.client = client
102
- subject.name = 'TestRemote'
102
+ subject.name = "TestRemote"
103
103
  subject.includes_pattern = nil
104
- subject.excludes_pattern = ''
105
- subject.repositories = ['ANY']
104
+ subject.excludes_pattern = ""
105
+ subject.repositories = ["ANY"]
106
106
  subject.principals = {
107
- 'users' => {
108
- 'anonymous_users' => ['read']
107
+ "users" => {
108
+ "anonymous_users" => ["read"],
109
+ },
110
+ "groups" => {
111
+ "anonymous_readers" => ["read"],
109
112
  },
110
- 'groups' => {
111
- 'anonymous_readers' => ['read']
112
- }
113
113
  }
114
114
  allow(described_class).to receive(:find).with(subject.name, client: client).and_return(nil)
115
115
  end
116
116
 
117
- it 'PUTS the permission target to the server' do
117
+ it "PUTS the permission target to the server" do
118
118
  expect(client).to receive(:put).with("/api/security/permissions/TestRemote",
119
119
  "{\"name\":\"TestRemote\",\"includesPattern\":\"**\",\"excludesPattern\":\"\",\"repositories\":[\"ANY\"],\"principals\":{\"users\":{\"anonymous_users\":[\"r\"]},\"groups\":{\"anonymous_readers\":[\"r\"]}}}",
120
- { "Content-Type" => "application/vnd.org.jfrog.artifactory.security.PermissionTarget+json"})
120
+ { "Content-Type" => "application/vnd.org.jfrog.artifactory.security.PermissionTarget+json" })
121
121
  subject.save
122
122
  end
123
123
  end
124
124
 
125
- describe '#delete' do
125
+ describe "#delete" do
126
126
  let(:client) { double }
127
127
 
128
- it 'sends DELETE to the client' do
128
+ it "sends DELETE to the client" do
129
129
  subject.client = client
130
- subject.name = 'My Permissions'
130
+ subject.name = "My Permissions"
131
131
 
132
- expect(client).to receive(:delete).with('/api/security/permissions/My%20Permissions')
132
+ expect(client).to receive(:delete).with("/api/security/permissions/My%20Permissions")
133
133
  subject.delete
134
134
  end
135
135
  end
136
136
 
137
- describe 'getters' do
137
+ describe "getters" do
138
138
  let(:client) { double }
139
139
  before do
140
140
  subject.client = client
141
- subject.name = 'TestGetters'
141
+ subject.name = "TestGetters"
142
142
  subject.principals = {
143
- 'users' => {
144
- 'anonymous' => ['read']
143
+ "users" => {
144
+ "anonymous" => ["read"],
145
+ },
146
+ "groups" => {
147
+ "readers" => ["read"],
145
148
  },
146
- 'groups' => {
147
- 'readers' => ['read']
148
- }
149
149
  }
150
150
  allow(described_class).to receive(:find).with(subject.name, client: client).and_return(nil)
151
151
  end
152
152
 
153
- it '#users returns the users hash' do
154
- expect(subject.users).to eq({ 'anonymous' => ['read'] })
153
+ it "#users returns the users hash" do
154
+ expect(subject.users).to eq({ "anonymous" => ["read"] })
155
155
  end
156
156
 
157
- it '#groups returns the groups hash' do
158
- expect(subject.groups).to eq({ 'readers' => ['read'] })
157
+ it "#groups returns the groups hash" do
158
+ expect(subject.groups).to eq({ "readers" => ["read"] })
159
159
  end
160
160
  end
161
161
 
162
- describe 'setters' do
162
+ describe "setters" do
163
163
  let(:client) { double }
164
164
  before do
165
165
  subject.client = client
166
- subject.name = 'TestSetters'
166
+ subject.name = "TestSetters"
167
167
  subject.principals = {
168
- 'users' => {
169
- 'anonymous' => ['read']
168
+ "users" => {
169
+ "anonymous" => ["read"],
170
+ },
171
+ "groups" => {
172
+ "readers" => ["read"],
170
173
  },
171
- 'groups' => {
172
- 'readers' => ['read']
173
- }
174
174
  }
175
175
  allow(described_class).to receive(:find).with(subject.name, client: client).and_return(nil)
176
176
  end
177
177
 
178
- it '#users= sets the users hash' do
179
- subject.users = { 'spiders' => [ 'read', 'admin'] }
180
- expect(subject.users).to eq({ 'spiders' => ['admin', 'read'] })
178
+ it "#users= sets the users hash" do
179
+ subject.users = { "spiders" => %w{read admin} }
180
+ expect(subject.users).to eq({ "spiders" => %w{admin read} })
181
181
  end
182
182
 
183
- it '#groups= sets the groups hash' do
184
- subject.groups = { 'beatles' => [ 'deploy', 'delete'] }
185
- expect(subject.groups).to eq({ 'beatles' => ['delete', 'deploy'] })
183
+ it "#groups= sets the groups hash" do
184
+ subject.groups = { "beatles" => %w{deploy delete} }
185
+ expect(subject.groups).to eq({ "beatles" => %w{delete deploy} })
186
186
  end
187
187
  end
188
188
  end