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,61 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Artifactory
4
- describe Resource::Backup 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
- <backups>
16
- <backup>
17
- <key>backup-daily</key>
18
- </backup>
19
- </backups>
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 backup settings" 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.key).to eq("backup-daily")
34
- end
35
- end
36
-
37
- describe ".find" do
38
- doc = <<-XML
39
- <config>
40
- <backups>
41
- <backup>
42
- <key>backup-weekly</key>
43
- </backup>
44
- </backups>
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 backup setting" do
56
- expect(described_class.find("backup-weekly")).to be_a(described_class)
57
- expect(described_class.find("backup-weekly").key).to eq("backup-weekly")
58
- end
59
- end
60
- end
61
- end
@@ -1,180 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Artifactory
4
- describe Resource::Base do
5
- let(:client) { double }
6
- let(:endpoint_host) { "http://33.33.33.11" }
7
- let(:endpoint) { "#{endpoint_host}/" }
8
-
9
- before do
10
- allow(Artifactory).to receive(:client).and_return(client)
11
- end
12
-
13
- describe ".attribute" do
14
- before { described_class.attribute(:bacon) }
15
-
16
- it "defines an accessor method" do
17
- expect(subject).to respond_to(:bacon)
18
- end
19
-
20
- it "defines a setter method" do
21
- expect(subject).to respond_to(:bacon=)
22
- end
23
-
24
- it "defines a boolean method" do
25
- expect(subject).to respond_to(:bacon?)
26
- end
27
- end
28
-
29
- describe ".extract_client!" do
30
- context "when the :client key is present" do
31
- let(:client) { double }
32
- let(:options) { { client: client } }
33
-
34
- it "extracts the client" do
35
- result = described_class.extract_client!(options)
36
- expect(result).to be(client)
37
- end
38
-
39
- it "removes the key from the hash" do
40
- described_class.extract_client!(options)
41
- expect(options).to_not have_key(:client)
42
- end
43
- end
44
-
45
- context "when the :client key is not present" do
46
- let(:client) { double }
47
- before { allow(Artifactory).to receive(:client).and_return(client) }
48
-
49
- it "uses Artifactory.client" do
50
- expect(described_class.extract_client!({})).to be(client)
51
- end
52
- end
53
- end
54
-
55
- describe ".format_repos!" do
56
- context "when the :repos key is present" do
57
- it "joins an array" do
58
- options = { repos: %w{bacon bits} }
59
- described_class.format_repos!(options)
60
- expect(options[:repos]).to eq("bacon,bits")
61
- end
62
-
63
- it "accepts a single repository" do
64
- options = { repos: "bacon" }
65
- described_class.format_repos!(options)
66
- expect(options[:repos]).to eq("bacon")
67
- end
68
- end
69
-
70
- context "when the :repos key is not present" do
71
- it "does not modify the hash" do
72
- options = {}
73
- described_class.format_repos!(options)
74
- expect(options).to eq(options)
75
- end
76
- end
77
-
78
- context "when the :repos key is empty" do
79
- it "does not modify the hash" do
80
- options = { repos: [] }
81
- described_class.format_repos!(options)
82
- expect(options).to eq(options)
83
- end
84
- end
85
- end
86
-
87
- describe ".from_url" do
88
- let(:relative_path) { "/api/storage/omnibus-unstable-local/com/getchef/harmony/0.1.0+20151111083608.git.15.8736e1e/el/5/harmony-0.1.0+20151111083608.git.15.8736e1e-1.el5.x86_64.rpm" }
89
-
90
- context "when endpoint path part is not empty" do
91
- let(:endpoint) { "#{endpoint_host}/artifactory" }
92
- let(:full_url) { "#{endpoint}#{relative_path}" }
93
-
94
- it "uses the path minus the path part of the endpoint" do
95
- expect(client).to receive(:endpoint).and_return(endpoint)
96
- expect(described_class).to receive(:from_hash)
97
- expect(client).to receive(:get).with(relative_path)
98
- described_class.from_url(full_url)
99
- end
100
- end
101
-
102
- context "when endpoint has empty path part" do
103
- let(:endpoint) { "#{endpoint_host}/" }
104
- let(:full_url) { "#{endpoint}#{relative_path}" }
105
-
106
- it "only uses the path from absolute URLs" do
107
- expect(client).to receive(:endpoint).and_return(endpoint)
108
- expect(described_class).to receive(:from_hash)
109
- expect(client).to receive(:get).with(relative_path)
110
- described_class.from_url(full_url)
111
- end
112
- end
113
- end
114
-
115
- describe ".url_safe" do
116
- let(:string) { double(to_s: "string") }
117
-
118
- it "delegates to URI.escape" do
119
- expect(URI).to receive(:escape).once
120
- described_class.url_safe(string)
121
- end
122
-
123
- it "converts the value to a string" do
124
- expect(string).to receive(:to_s).once
125
- described_class.url_safe(string)
126
- end
127
- end
128
-
129
- describe "#client" do
130
- it "defines a :client method" do
131
- expect(subject).to respond_to(:client)
132
- end
133
-
134
- it "defaults to the Artifactory.client" do
135
- client = double
136
- allow(Artifactory).to receive(:client).and_return(client)
137
- allow(client).to receive(:endpoint).and_return(endpoint)
138
-
139
- expect(subject.client).to be(client)
140
- end
141
- end
142
-
143
- describe "#extract_client!" do
144
- it "delegates to the class method" do
145
- expect(described_class).to receive(:extract_client!).once
146
- subject.extract_client!({})
147
- end
148
- end
149
-
150
- describe "#format_repos!" do
151
- it "delegates to the class method" do
152
- expect(described_class).to receive(:format_repos!).once
153
- subject.format_repos!({})
154
- end
155
- end
156
-
157
- describe "#url_safe" do
158
- it "delegates to the class method" do
159
- expect(described_class).to receive(:url_safe).once
160
- subject.url_safe("string")
161
- end
162
- end
163
-
164
- describe "#to_s" do
165
- it "returns the name of the class" do
166
- expect(subject.to_s).to eq("#<Base>")
167
- end
168
- end
169
-
170
- describe "#inspect" do
171
- it "includes all the attributes" do
172
- allow(subject).to receive(:attributes) do
173
- { foo: "bar" }
174
- end
175
-
176
- expect(subject.inspect).to eq(%q{#<Base foo: "bar">})
177
- end
178
- end
179
- end
180
- end
@@ -1,118 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Artifactory
4
- describe Resource::BuildComponent 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
- subject.name = "wicket"
11
- end
12
-
13
- describe ".all" do
14
- let(:response) do
15
- {
16
- "uri" => "#{Artifactory.endpoint}/api/build",
17
- "builds" => [
18
- {
19
- "uri" => "/wicket",
20
- "lastStarted" => "2015-06-19T20:13:20.222Z",
21
- },
22
- {
23
- "uri" => "/jackrabbit",
24
- "lastStarted" => "2015-06-20T20:13:20.333Z",
25
- },
26
- ],
27
- }
28
- end
29
-
30
- before do
31
- allow(described_class).to receive(:from_hash).with(hash_including("uri" => "/wicket"), client: client).and_return("wicket")
32
- allow(described_class).to receive(:from_hash).with(hash_including("uri" => "/jackrabbit"), client: client).and_return("jackrabbit")
33
- end
34
-
35
- it "GETS /api/build" do
36
- expect(client).to receive(:get).with("/api/build").once
37
- described_class.all
38
- end
39
-
40
- context "when there are components with builds" do
41
- it "returns the components" do
42
- expect(described_class.all).to eq(%w{ wicket jackrabbit })
43
- end
44
- end
45
-
46
- context "when the system has no components with builds" do
47
- it "returns an empty array" do
48
- allow(client).to receive(:get).and_raise(Error::HTTPError.new("status" => 404))
49
- expect(described_class.all).to be_empty
50
- end
51
- end
52
- end
53
-
54
- describe ".find" do
55
- before do
56
- allow(described_class).to receive(:all).and_return([
57
- described_class.new(name: "wicket"),
58
- described_class.new(name: "jackrabbit"),
59
- ])
60
- end
61
-
62
- it "filters the full build component list by name" do
63
- expect(described_class.find("wicket")).to_not be_nil
64
- end
65
-
66
- context "when the build component does not exist" do
67
- it "returns nil" do
68
- expect(described_class.find("fricket")).to be_nil
69
- end
70
- end
71
- end
72
-
73
- describe ".from_hash" do
74
- let(:time) { Time.now.utc.round }
75
- let(:hash) do
76
- {
77
- "uri" => "/wicket",
78
- "lastStarted" => time.iso8601(3),
79
- }
80
- end
81
-
82
- it "creates a new instance" do
83
- instance = described_class.from_hash(hash)
84
- expect(instance.uri).to eq("/wicket")
85
- expect(instance.name).to eq("wicket")
86
- expect(instance.last_started).to eq(time)
87
- end
88
- end
89
-
90
- describe "#builds" do
91
-
92
- it "returns a build collection" do
93
- expect(subject.builds).to be_a(Collection::Build)
94
- end
95
- end
96
-
97
- describe "#delete" do
98
-
99
- it "sends DELETE to the client" do
100
- expect(client).to receive(:delete)
101
- subject.delete
102
- end
103
-
104
- it "adds the correct parameters to the request" do
105
- expect(client).to receive(:delete).with("/api/build/wicket?buildNumbers=51,52,55&artifacts=1&deleteAll=1", {})
106
- subject.delete(build_numbers: %w{ 51 52 55 }, artifacts: true, delete_all: true)
107
- end
108
- end
109
-
110
- describe "#rename" do
111
-
112
- it "sends POST to the client with the correct param" do
113
- expect(client).to receive(:post).with("/api/build/rename/wicket?to=fricket", {})
114
- subject.rename("fricket")
115
- end
116
- end
117
- end
118
- end
@@ -1,347 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Artifactory
4
- describe Resource::Build do
5
- let(:client) { double(:client) }
6
- let(:time) { Time.now.utc.round }
7
-
8
- before(:each) do
9
- allow(Artifactory).to receive(:client).and_return(client)
10
- allow(client).to receive(:get).and_return(response) if defined?(response)
11
-
12
- subject.name = "wicket"
13
- subject.number = "51"
14
- end
15
-
16
- describe ".all" do
17
- let(:response) do
18
- {
19
- "uri" => "#{Artifactory.endpoint}/api/build/wicket",
20
- "buildsNumbers" => [
21
- {
22
- "uri" => "/51",
23
- "started" => "2014-01-01 12:00:00",
24
- },
25
- {
26
- "uri" => "/52",
27
- "started" => "2015-01-05 12:00:00",
28
- },
29
- ],
30
- }
31
- end
32
-
33
- before do
34
- allow(described_class).to receive(:find).with("wicket", "51", client: client).and_return("51")
35
- allow(described_class).to receive(:find).with("wicket", "52", client: client).and_return("52")
36
- end
37
-
38
- it 'GETS /api/build/#{name}' do
39
- expect(client).to receive(:get).with("/api/build/wicket").once
40
- described_class.all("wicket")
41
- end
42
-
43
- context "when there are builds" do
44
- it "returns the builds" do
45
- expect(described_class.all("wicket")).to eq(%w{51 52})
46
- end
47
- end
48
-
49
- context "when the system has no builds" do
50
- it "returns an empty array" do
51
- allow(client).to receive(:get).and_raise(Error::HTTPError.new("status" => 404))
52
- expect(described_class.all("wicket")).to be_empty
53
- end
54
- end
55
- end
56
-
57
- describe ".find" do
58
- let(:response) { { "buildInfo" => {} } }
59
-
60
- it 'GETS /api/repositories/#{name}/#{number}' do
61
- expect(client).to receive(:get).with("/api/build/wicket/51").once
62
- described_class.find("wicket", 51)
63
- end
64
-
65
- context "when the build does not exist" do
66
- it "returns nil" do
67
- allow(client).to receive(:get).and_raise(Error::HTTPError.new("status" => 404))
68
- expect(described_class.find("wicket", "4445")).to be_nil
69
- end
70
- end
71
- end
72
-
73
- describe ".from_hash" do
74
- let(:hash) do
75
- {
76
- "properties" => {
77
- "buildInfo.env.JAVA_HOME" => "/usr/jdk/latest",
78
- },
79
- "version" => "1.0.1",
80
- "name" => "Maven2-3",
81
- "number" => "9",
82
- "type" => "MAVEN",
83
- "buildAgent" => {
84
- "name" => "Maven",
85
- "version" => "3.0.5",
86
- },
87
- "agent" => {
88
- "name" => "Jenkins",
89
- "version" => "1.565.2",
90
- },
91
- "started" => time.iso8601(3),
92
- "durationMillis" => 8926,
93
- "artifactoryPrincipal" => "admin",
94
- "url" => "http://localhost:8080/job/Maven2-3/9/",
95
- "vcsRevision" => "83049487ecc61bef3dce798838e7a9457e174a5a",
96
- "vcsUrl" => "https://github.com/aseftel/project-examples",
97
- "licenseControl" => {
98
- "runChecks" => false,
99
- "includePublishedArtifacts" => false,
100
- "autoDiscover" => true,
101
- "scopesList" => "",
102
- "licenseViolationsRecipientsList" => "",
103
- },
104
- "buildRetention" => {
105
- "count" => -1,
106
- "deleteBuildArtifacts" => true,
107
- "buildNumbersNotToBeDiscarded" => [],
108
- },
109
- "modules" => modules,
110
- "governance" => {
111
- "blackDuckProperties" => {
112
- "runChecks" => false,
113
- "includePublishedArtifacts" => false,
114
- "autoCreateMissingComponentRequests" => false,
115
- "autoDiscardStaleComponentRequests" => false,
116
- },
117
- },
118
- }
119
- end
120
- let(:modules) do
121
- [
122
- {
123
- "properties" => {
124
- "project.build.sourceEncoding" => "UTF-8",
125
- },
126
- "id" => "org.jfrog.test:multi:2.19-SNAPSHOT",
127
- "artifacts" => [
128
- {
129
- "type" => "pom",
130
- "sha1" => "045b66ebbf8504002b626f592d087612aca36582",
131
- "md5" => "c25542a353dab1089cd186465dc47a68",
132
- "name" => "multi-2.19-SNAPSHOT.pom",
133
- },
134
- ],
135
- },
136
- {
137
- "properties" => {
138
- "project.build.sourceEncoding" => "UTF-8",
139
- },
140
- "id" => "org.jfrog.test:multi1:2.19-SNAPSHOT",
141
- "artifacts" => [
142
- {
143
- "type" => "jar",
144
- "sha1" => "f4c5c9cb3091011ec2a895b3dedd7f10d847361c",
145
- "md5" => "d1fd850a3582efba41092c624e0b46b8",
146
- "name" => "multi1-2.19-SNAPSHOT.jar",
147
- },
148
- {
149
- "type" => "pom",
150
- "sha1" => "2ddbf9824676f548d637726d3bcbb494ba823090",
151
- "md5" => "a64aa7f305f63a85e63a0155ff0fb404",
152
- "name" => "multi1-2.19-SNAPSHOT.pom",
153
- },
154
- {
155
- "type" => "jar",
156
- "sha1" => "6fdd143a44cea3a2636660c5c266c95c27e50abc",
157
- "md5" => "12a1e438f4bef8c4b740fe848a1704a4",
158
- "id" => "org.slf4j:slf4j-simple:1.4.3",
159
- "scopes" => [ "compile" ],
160
- },
161
- {
162
- "type" => "jar",
163
- "sha1" => "496e91f7df8a0417e00cecdba840cdf0e5f2472c",
164
- "md5" => "76a412a37c9d18659d2dacccdb1c24ff",
165
- "id" => "org.jenkins-ci.lib:dry-run-lib:0.1",
166
- "scopes" => [ "compile" ],
167
- },
168
- ],
169
- },
170
- {
171
- "properties" => {
172
- "daversion" => "2.19-SNAPSHOT",
173
- "project.build.sourceEncoding" => "UTF-8",
174
- },
175
- "id" => "org.jfrog.test:multi2:2.19-SNAPSHOT",
176
- "artifacts" => [
177
- {
178
- "type" => "txt",
179
- "name" => "multi2-2.19-SNAPSHOT.txt",
180
- },
181
- {
182
- "type" => "java-source-jar",
183
- "sha1" => "49108b0c7db5fdb4efe3c29a5a9f54e806aecb62",
184
- "md5" => "0e2c5473cf2a9b694afb4a2e8da34b53",
185
- "name" => "multi2-2.19-SNAPSHOT-sources.jar" },
186
- {
187
- "type" => "jar",
188
- "sha1" => "476e89d290ae36dabb38ff22f75f264ae019d542",
189
- "md5" => "fa9b3df58ac040fffcff9310f261be80",
190
- "name" => "multi2-2.19-SNAPSHOT.jar",
191
- },
192
- {
193
- "type" => "pom",
194
- "sha1" => "b719b90364e5ae38cda358072f61f821bdae5d5d",
195
- "md5" => "8d5060005235d75907baca4490cf60bf",
196
- "name" => "multi2-2.19-SNAPSHOT.pom",
197
- },
198
- ],
199
- "dependencies" => [
200
- {
201
- "type" => "jar",
202
- "sha1" => "19d4e90b43059058f6e056f794f0ea4030d60b86",
203
- "md5" => "dcd95bcb84b09897b2b66d4684c040da",
204
- "id" => "xpp3:xpp3_min:1.1.4c",
205
- "scopes" => [ "provided" ],
206
- },
207
- {
208
- "type" => "jar",
209
- "sha1" => "e2d866af5518e81282838301b49a1bd2452619d3",
210
- "md5" => "e9e4b59c69305ba3698dd61c5dfc4fc8",
211
- "id" => "org.jvnet.hudson.plugins:perforce:1.3.7",
212
- "scopes" => [ "compile" ],
213
- },
214
- {
215
- "type" => "jar",
216
- "sha1" => "6fdd143a44cea3a2636660c5c266c95c27e50abc",
217
- "md5" => "12a1e438f4bef8c4b740fe848a1704a4",
218
- "id" => "org.slf4j:slf4j-simple:1.4.3",
219
- "scopes" => [ "compile" ],
220
- },
221
- {
222
- "type" => "jar",
223
- "sha1" => "496e91f7df8a0417e00cecdba840cdf0e5f2472c",
224
- "md5" => "76a412a37c9d18659d2dacccdb1c24ff",
225
- "id" => "org.jenkins-ci.lib:dry-run-lib:0.1",
226
- "scopes" => [ "compile" ],
227
- },
228
- ],
229
- },
230
- {
231
- "properties" => {
232
- "project.build.sourceEncoding" => "UTF-8",
233
- },
234
- "id" => "org.jfrog.test:multi3:2.19-SNAPSHOT",
235
- "artifacts" => [
236
- {
237
- "type" => "java-source-jar",
238
- "sha1" => "3cd104785167ac37ef999431f308ffef10810348",
239
- "md5" => "c683276f8dda97078ae8eb5e26bb3ee5",
240
- "name" => "multi3-2.19-SNAPSHOT-sources.jar",
241
- },
242
- {
243
- "type" => "war",
244
- "sha1" => "34aeebeb805b23922d9d05507404533518cf81e4",
245
- "md5" => "55af06a2175cfb23cc6dc3931475b57c",
246
- "name" => "multi3-2.19-SNAPSHOT.war",
247
- },
248
- {
249
- "type" => "jar",
250
- "sha1" => "496e91f7df8a0417e00cecdba840cdf0e5f2472c",
251
- "md5" => "76a412a37c9d18659d2dacccdb1c24ff",
252
- "id" => "org.jenkins-ci.lib:dry-run-lib:0.1",
253
- "scopes" => [ "compile" ],
254
- },
255
- {
256
- "type" => "jar",
257
- "sha1" => "7e9978fdb754bce5fcd5161133e7734ecb683036",
258
- "md5" => "7df83e09e41d742cc5fb20d16b80729c",
259
- "id" => "hsqldb:hsqldb:1.8.0.10",
260
- "scopes" => [ "runtime" ],
261
- },
262
- ],
263
- },
264
- ]
265
- end
266
-
267
- it "creates a new instance" do
268
- instance = described_class.from_hash(hash)
269
- expect(instance.properties).to eq("buildInfo.env.JAVA_HOME" => "/usr/jdk/latest")
270
- expect(instance.version).to eq("1.0.1")
271
- expect(instance.name).to eq("Maven2-3")
272
- expect(instance.number).to eq("9")
273
- expect(instance.type).to eq("MAVEN")
274
- expect(instance.build_agent).to eq(
275
- "name" => "Maven",
276
- "version" => "3.0.5"
277
- )
278
- expect(instance.agent).to eq(
279
- "name" => "Jenkins",
280
- "version" => "1.565.2"
281
- )
282
- expect(instance.started).to eq(time)
283
- expect(instance.duration_millis).to eq(8926)
284
- expect(instance.artifactory_principal).to eq("admin")
285
- expect(instance.url).to eq("http://localhost:8080/job/Maven2-3/9/")
286
- expect(instance.vcs_revision).to eq("83049487ecc61bef3dce798838e7a9457e174a5a")
287
- expect(instance.vcs_url).to eq("https://github.com/aseftel/project-examples")
288
- expect(instance.build_retention).to eq(
289
- "count" => -1,
290
- "deleteBuildArtifacts" => true,
291
- "buildNumbersNotToBeDiscarded" => []
292
- )
293
- expect(instance.modules).to eq(
294
- modules
295
- )
296
- expect(instance.governance).to eq(
297
- "blackDuckProperties" => {
298
- "runChecks" => false,
299
- "includePublishedArtifacts" => false,
300
- "autoCreateMissingComponentRequests" => false,
301
- "autoDiscardStaleComponentRequests" => false,
302
- }
303
- )
304
- end
305
- end
306
-
307
- describe "#diff" do
308
- it "sends GET to the client with the correct param" do
309
- expect(client).to receive(:get).with("/api/build/wicket/51?diff=53", {})
310
- subject.diff("53")
311
- end
312
- end
313
-
314
- describe "#promote" do
315
- let(:to_repo) { "omnibus-stable-local" }
316
- before do
317
- Artifactory.username = "doge"
318
- end
319
-
320
- it "sends POST to the client with promotion JSON" do
321
- expect(client).to receive(:post).with("/api/build/promote/wicket/51", /"targetRepo"\:"omnibus-stable-local"/, kind_of(Hash))
322
- subject.promote(to_repo)
323
- end
324
-
325
- it "Uses the configured Artifactory.username as the default value for `ciUser`" do
326
- expect(client).to receive(:post).with("/api/build/promote/wicket/51", /"ciUser"\:"doge"/, kind_of(Hash))
327
- subject.promote(to_repo)
328
- end
329
- end
330
-
331
- describe "#save" do
332
-
333
- it "PUTS the build JSON file to the server" do
334
- expect(client).to receive(:put).with("/api/build", kind_of(Tempfile), "Content-Type" => "application/json")
335
- subject.save
336
- end
337
-
338
- context "an invalid build type is provided" do
339
- before { subject.type = "PIRATE" }
340
-
341
- it "raises an InvalidBuildType error" do
342
- expect { subject.save }.to raise_error(Error::InvalidBuildType)
343
- end
344
- end
345
- end
346
- end
347
- end