artifactory 2.8.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +5 -5
  2. data/lib/artifactory.rb +1 -1
  3. data/lib/artifactory/client.rb +1 -1
  4. data/lib/artifactory/collections/artifact.rb +1 -1
  5. data/lib/artifactory/collections/base.rb +1 -1
  6. data/lib/artifactory/collections/build.rb +1 -1
  7. data/lib/artifactory/configurable.rb +1 -1
  8. data/lib/artifactory/defaults.rb +1 -1
  9. data/lib/artifactory/errors.rb +5 -5
  10. data/lib/artifactory/resources/artifact.rb +12 -12
  11. data/lib/artifactory/resources/backup.rb +1 -1
  12. data/lib/artifactory/resources/base.rb +2 -2
  13. data/lib/artifactory/resources/build.rb +2 -2
  14. data/lib/artifactory/resources/group.rb +1 -1
  15. data/lib/artifactory/resources/layout.rb +1 -1
  16. data/lib/artifactory/resources/ldap_setting.rb +1 -1
  17. data/lib/artifactory/resources/mail_server.rb +1 -1
  18. data/lib/artifactory/resources/permission_target.rb +15 -1
  19. data/lib/artifactory/resources/plugin.rb +1 -1
  20. data/lib/artifactory/resources/repository.rb +1 -1
  21. data/lib/artifactory/resources/system.rb +1 -1
  22. data/lib/artifactory/resources/url_base.rb +1 -1
  23. data/lib/artifactory/resources/user.rb +1 -1
  24. data/lib/artifactory/util.rb +2 -2
  25. data/lib/artifactory/version.rb +2 -2
  26. metadata +10 -130
  27. data/.gitignore +0 -27
  28. data/.travis.yml +0 -28
  29. data/CHANGELOG.md +0 -141
  30. data/Gemfile +0 -14
  31. data/README.md +0 -288
  32. data/Rakefile +0 -28
  33. data/appveyor.yml +0 -30
  34. data/artifactory.gemspec +0 -25
  35. data/spec/integration/resources/artifact_spec.rb +0 -99
  36. data/spec/integration/resources/backup.rb +0 -22
  37. data/spec/integration/resources/build_component_spec.rb +0 -64
  38. data/spec/integration/resources/build_spec.rb +0 -38
  39. data/spec/integration/resources/group_spec.rb +0 -45
  40. data/spec/integration/resources/layout_spec.rb +0 -22
  41. data/spec/integration/resources/ldap_setting_spec.rb +0 -22
  42. data/spec/integration/resources/mail_server_spec.rb +0 -22
  43. data/spec/integration/resources/permission_target_spec.rb +0 -75
  44. data/spec/integration/resources/repository_spec.rb +0 -40
  45. data/spec/integration/resources/system_spec.rb +0 -58
  46. data/spec/integration/resources/url_base_spec.rb +0 -22
  47. data/spec/integration/resources/user_spec.rb +0 -45
  48. data/spec/spec_helper.rb +0 -52
  49. data/spec/support/api_server.rb +0 -49
  50. data/spec/support/api_server/artifact_endpoints.rb +0 -186
  51. data/spec/support/api_server/build_component_endpoints.rb +0 -44
  52. data/spec/support/api_server/build_endpoints.rb +0 -240
  53. data/spec/support/api_server/group_endpoints.rb +0 -53
  54. data/spec/support/api_server/permission_target_endpoints.rb +0 -53
  55. data/spec/support/api_server/repository_endpoints.rb +0 -114
  56. data/spec/support/api_server/status_endpoints.rb +0 -11
  57. data/spec/support/api_server/system_endpoints.rb +0 -104
  58. data/spec/support/api_server/user_endpoints.rb +0 -59
  59. data/spec/unit/artifactory_spec.rb +0 -73
  60. data/spec/unit/client_spec.rb +0 -132
  61. data/spec/unit/resources/artifact_spec.rb +0 -608
  62. data/spec/unit/resources/backup_spec.rb +0 -61
  63. data/spec/unit/resources/base_spec.rb +0 -180
  64. data/spec/unit/resources/build_component_spec.rb +0 -118
  65. data/spec/unit/resources/build_spec.rb +0 -347
  66. data/spec/unit/resources/defaults_spec.rb +0 -27
  67. data/spec/unit/resources/group_spec.rb +0 -108
  68. data/spec/unit/resources/layout_spec.rb +0 -61
  69. data/spec/unit/resources/ldap_setting_spec.rb +0 -65
  70. data/spec/unit/resources/mail_server_spec.rb +0 -57
  71. data/spec/unit/resources/permission_target_spec.rb +0 -189
  72. data/spec/unit/resources/plugin_spec.rb +0 -25
  73. data/spec/unit/resources/repository_spec.rb +0 -217
  74. data/spec/unit/resources/system_spec.rb +0 -90
  75. data/spec/unit/resources/url_base_spec.rb +0 -53
  76. data/spec/unit/resources/user_spec.rb +0 -115
@@ -1,25 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Artifactory
4
- describe Resource::Plugin 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
- let(:response) { %w{a b c} }
14
-
15
- it "gets /api/plugins" do
16
- expect(client).to receive(:get).with("/api/plugins").once
17
- described_class.all
18
- end
19
-
20
- it "returns the plugins" do
21
- expect(described_class.all).to eq(%w{a b c})
22
- end
23
- end
24
- end
25
- end
@@ -1,217 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Artifactory
4
- describe Resource::Repository 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
- let(:response) do
14
- [
15
- { "key" => "a" },
16
- { "key" => "b" },
17
- { "key" => "c" },
18
- ]
19
- end
20
- before do
21
- allow(described_class).to receive(:find).with("a", client: client).and_return("a")
22
- allow(described_class).to receive(:find).with("b", client: client).and_return("b")
23
- allow(described_class).to receive(:find).with("c", client: client).and_return("c")
24
- end
25
-
26
- it "gets /api/repositories" do
27
- expect(client).to receive(:get).with("/api/repositories").once
28
- described_class.all
29
- end
30
-
31
- it "returns the repositories" do
32
- expect(described_class.all).to eq(%w{a b c})
33
- end
34
- end
35
-
36
- describe ".find" do
37
- let(:response) { {} }
38
-
39
- it 'gets /api/repositories/#{name}' do
40
- expect(client).to receive(:get).with("/api/repositories/libs-release-local").once
41
- described_class.find("libs-release-local")
42
- end
43
- end
44
-
45
- describe ".from_hash" do
46
- let(:hash) do
47
- {
48
- "key" => "libs-release-local",
49
- "description" => "Local repository for in-house libraries",
50
- "notes" => "",
51
- "includesPattern" => "**/*",
52
- "excludesPattern" => "",
53
- "enableNuGetSupport" => false,
54
- "enableGemsSupport" => false,
55
- "checksumPolicyType" => "server-generated-checksums",
56
- "handleReleases" => true,
57
- "handleSnapshots" => false,
58
- "maxUniqueSnapshots" => 10,
59
- "snapshotVersionBehavior" => "unique",
60
- "suppressPomConsistencyChecks" => true,
61
- "blackedOut" => false,
62
- "propertySets" => ["artifactory"],
63
- "archiveBrowsingEnabled" => false,
64
- "calculateYumMetadata" => false,
65
- "yumRootDepth" => 3,
66
- "rclass" => "local",
67
- "url" => "someurl",
68
- }
69
- end
70
-
71
- it "creates a new instance" do
72
- instance = described_class.from_hash(hash)
73
- expect(instance.blacked_out).to be_falsey
74
- expect(instance.description).to eq("Local repository for in-house libraries")
75
- expect(instance.checksum_policy_type).to eq("server-generated-checksums")
76
- expect(instance.excludes_pattern).to eq("")
77
- expect(instance.handle_releases).to be_truthy
78
- expect(instance.handle_snapshots).to be_falsey
79
- expect(instance.includes_pattern).to eq("**/*")
80
- expect(instance.key).to eq("libs-release-local")
81
- expect(instance.max_unique_snapshots).to eq(10)
82
- expect(instance.notes).to eq("")
83
- expect(instance.package_type).to eq("generic")
84
- expect(instance.property_sets).to eq(["artifactory"])
85
- expect(instance.rclass).to eq("local")
86
- expect(instance.repo_layout_ref).to eq("simple-default")
87
- expect(instance.snapshot_version_behavior).to eq("unique")
88
- expect(instance.suppress_pom_consistency_checks).to be_truthy
89
- expect(instance.url).to eq("someurl")
90
- expect(instance.yum_root_depth).to eq(3)
91
- expect(instance.calculate_yum_metadata).to eq(false)
92
- end
93
- end
94
-
95
- describe "#save" do
96
- let(:client) { double }
97
- before do
98
- subject.client = client
99
- subject.key = "libs-release-local"
100
- end
101
-
102
- context "when the repository is new" do
103
- before do
104
- allow(described_class).to receive(:find).with(subject.key, client: client).and_return(nil)
105
- end
106
-
107
- it "PUTS the file to the server" do
108
- expect(client).to receive(:put).with("/api/repositories/#{subject.key}", kind_of(String), kind_of(Hash))
109
- subject.save
110
- end
111
- end
112
-
113
- context "when the repository exists" do
114
- before do
115
- allow(described_class).to receive(:find).with(subject.key, client: client).and_return({ key: subject.key })
116
- end
117
-
118
- it "POSTS the file to the server" do
119
- expect(client).to receive(:post).with("/api/repositories/#{subject.key}", kind_of(String), kind_of(Hash))
120
- subject.save
121
- end
122
- end
123
- end
124
-
125
- describe "#upload" do
126
- let(:client) { double(put: {}) }
127
- let(:file) { double(File) }
128
- let(:path) { "/fake/path" }
129
- before do
130
- subject.client = client
131
- subject.key = "libs-release-local"
132
- allow(File).to receive(:new).with(/\A(\w:)?#{path}\z/).and_return(file)
133
- end
134
-
135
- context "when the artifact is a file path" do
136
- it "PUTs the file at the path to the server" do
137
- expect(client).to receive(:put).with("libs-release-local/remote/path", file, {})
138
-
139
- subject.upload(path, "/remote/path")
140
- end
141
- end
142
-
143
- context "when matrix properties are given" do
144
- it "converts the hash into matrix properties" do
145
- expect(client).to receive(:put).with("libs-release-local;branch=master;user=Seth+Vargo%2B1/remote/path", file, {})
146
-
147
- subject.upload(path, "/remote/path",
148
- branch: "master",
149
- user: "Seth Vargo+1"
150
- )
151
- end
152
-
153
- it "converts the hash into matrix properties" do
154
- expect(client).to receive(:put).with("libs-release-local;branch=master;user=Seth/remote/path", file, {})
155
-
156
- subject.upload(path, "/remote/path",
157
- branch: "master",
158
- user: "Seth"
159
- )
160
- end
161
-
162
- it 'converts spaces to "+" characters' do
163
- expect(client).to receive(:put).with("libs-release-local;user=Seth+Vargo/remote/path", file, {})
164
-
165
- subject.upload(path, "/remote/path",
166
- user: "Seth Vargo"
167
- )
168
- end
169
-
170
- it 'converts "+" to "%2B"' do
171
- expect(client).to receive(:put).with("libs-release-local;version=12.0.0-alpha.1%2B20140826080510.git.50.f5ff271/remote/path", file, {})
172
-
173
- subject.upload(path, "/remote/path",
174
- version: "12.0.0-alpha.1+20140826080510.git.50.f5ff271"
175
- )
176
- end
177
- end
178
-
179
- context "when custom headers are given" do
180
- it "passes the headers to the client" do
181
- headers = { "Content-Type" => "text/plain" }
182
- expect(client).to receive(:put).with("libs-release-local/remote/path", file, headers)
183
-
184
- subject.upload(path, "/remote/path", {}, headers)
185
- end
186
- end
187
- end
188
-
189
- describe "#artifacts" do
190
- before { subject.key = "libs-release-local" }
191
-
192
- it "returns an artifact collection" do
193
- expect(subject.artifacts).to be_a(Collection::Artifact)
194
- end
195
- end
196
-
197
- describe "#upload_with_checksum" do
198
- it "delecates to artifact" do
199
- artifact = double("Artifact")
200
- allow(Resource::Artifact).to receive(:new) { artifact }
201
- subject.key = "libs-release-local"
202
- expect(artifact).to receive(:upload_with_checksum).once
203
- subject.upload_with_checksum("/local/path", "/remote/path", "checksum", { properties: :foobar })
204
- end
205
- end
206
-
207
- describe "#upload_from_archive" do
208
- it "delecates to artifact" do
209
- artifact = double("Artifact")
210
- allow(Resource::Artifact).to receive(:new) { artifact }
211
- subject.key = "libs-release-local"
212
- expect(artifact).to receive(:upload_from_archive).once
213
- subject.upload_from_archive("/local/path", "/remote/path", { properties: :foobar })
214
- end
215
- end
216
- end
217
- end
@@ -1,90 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Artifactory
4
- describe Resource::System 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 ".info" do
13
- let(:response) { "This is the response..." }
14
-
15
- it "calls /api/system" do
16
- expect(client).to receive(:get).with("/api/system").once
17
- described_class.info
18
- end
19
-
20
- it "returns the plan-text body" do
21
- expect(described_class.info).to eq(response)
22
- end
23
- end
24
-
25
- describe ".ping" do
26
- let(:response) { "" }
27
-
28
- it "gets /api/system/ping" do
29
- expect(client).to receive(:get).with("/api/system/ping").once
30
- described_class.ping
31
- end
32
-
33
- context "when the system is ok" do
34
- it "returns true" do
35
- expect(described_class.ping).to be_truthy
36
- end
37
- end
38
-
39
- context "when the system is not running" do
40
- it "returns false" do
41
- allow(client).to receive(:get)
42
- .and_raise(Error::ConnectionError.new(Artifactory.endpoint))
43
- expect(described_class.ping).to be_falsey
44
- end
45
- end
46
- end
47
-
48
- describe ".configuration" do
49
- let(:response) { "<config></config>" }
50
-
51
- it "gets /api/system/configuration" do
52
- expect(client).to receive(:get).with("/api/system/configuration").once
53
- described_class.configuration
54
- end
55
-
56
- it "returns the xml" do
57
- expect(described_class.configuration).to be_a(REXML::Document)
58
- end
59
- end
60
-
61
- describe ".update_configuration" do
62
- let(:xml) { double(:xml) }
63
- let(:response) { double(body: "...") }
64
- before { allow(client).to receive(:post).and_return(response) }
65
-
66
- it "posts /api/system/configuration" do
67
- headers = { "Content-Type" => "application/xml" }
68
- expect(client).to receive(:post).with("/api/system/configuration", xml, headers).once
69
- described_class.update_configuration(xml)
70
- end
71
-
72
- it "returns the body of the response" do
73
- expect(described_class.update_configuration(xml)).to eq(response)
74
- end
75
- end
76
-
77
- describe ".version" do
78
- let(:response) { double(json: { "foo" => "bar" }) }
79
-
80
- it "gets /api/system/version" do
81
- expect(client).to receive(:get).with("/api/system/version").once
82
- described_class.version
83
- end
84
-
85
- it "returns the parsed JSON of the response" do
86
- expect(described_class.version).to eq(response)
87
- end
88
- end
89
- end
90
- end
@@ -1,53 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Artifactory
4
- describe Resource::URLBase 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
- <urlBase>http://33.33.33.20/artifactory</urlBase>
16
- </config>
17
- XML
18
- let(:xml) do
19
- REXML::Document.new(doc)
20
- end
21
-
22
- before do
23
- allow(Resource::System).to receive(:configuration).and_return(xml)
24
- end
25
-
26
- it "returns the url bases" do
27
- expect(described_class.all).to be_a(Array)
28
- expect(described_class.all.first).to be_a(described_class)
29
- expect(described_class.all.first.url_base).to eq("http://33.33.33.20/artifactory")
30
- end
31
- end
32
-
33
- describe ".find" do
34
- doc = <<-XML
35
- <config>
36
- <urlBase>http://proxyserver/artifactory</urlBase>
37
- </config>
38
- XML
39
- let(:xml) do
40
- REXML::Document.new(doc)
41
- end
42
-
43
- before do
44
- allow(Resource::System).to receive(:configuration).and_return(xml)
45
- end
46
-
47
- it "returns the found urlBase" do
48
- expect(described_class.find("http://proxyserver/artifactory")).to be_a(described_class)
49
- expect(described_class.find("http://proxyserver/artifactory").url_base).to eq("http://proxyserver/artifactory")
50
- end
51
- end
52
- end
53
- end
@@ -1,115 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Artifactory
4
- describe Resource::User 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/users" do
29
- expect(client).to receive(:get).with("/api/security/users").once
30
- described_class.all
31
- end
32
-
33
- it "returns the users" 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/users/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/users/readers")
54
- end
55
- end
56
-
57
- describe ".from_hash" do
58
- let(:hash) do
59
- {
60
- "admin" => false,
61
- "email" => "admin@example.com",
62
- "groups" => ["admin"],
63
- "internalPasswordDisabled" => true,
64
- "lastLoggedIn" => nil,
65
- "name" => "admin",
66
- "profileUpdatable" => true,
67
- "realm" => "artifactory",
68
- }
69
- end
70
-
71
- it "creates a new instance" do
72
- instance = described_class.from_hash(hash)
73
- expect(instance.admin).to be_falsey
74
- expect(instance.email).to eq("admin@example.com")
75
- expect(instance.groups).to eq(["admin"])
76
- expect(instance.internal_password_disabled).to be_truthy
77
- expect(instance.last_logged_in).to be_nil
78
- expect(instance.name).to eq("admin")
79
- expect(instance.password).to be_nil
80
- expect(instance.profile_updatable).to be_truthy
81
- expect(instance.realm).to eq("artifactory")
82
- end
83
- end
84
-
85
- describe "#save" do
86
- let(:client) { double }
87
- before do
88
- subject.client = client
89
- subject.name = "schisamo"
90
- end
91
-
92
- context "when the user is new" do
93
- before do
94
- allow(described_class).to receive(:find).with(subject.name, client: client).and_return(nil)
95
- end
96
-
97
- it "PUTS the user to the server" do
98
- expect(client).to receive(:put).with("/api/security/users/#{subject.name}", kind_of(String), kind_of(Hash))
99
- subject.save
100
- end
101
- end
102
-
103
- context "when the user exists" do
104
- before do
105
- allow(described_class).to receive(:find).with(subject.name, client: client).and_return({ name: subject.name })
106
- end
107
-
108
- it "POSTS the user to the server" do
109
- expect(client).to receive(:post).with("/api/security/users/#{subject.name}", kind_of(String), kind_of(Hash))
110
- subject.save
111
- end
112
- end
113
- end
114
- end
115
- end