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