artifactory 2.5.2 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/CHANGELOG.md +6 -0
- data/Gemfile +9 -13
- data/README.md +10 -1
- data/Rakefile +16 -7
- data/appveyor.yml +4 -2
- data/artifactory.gemspec +14 -14
- data/lib/artifactory.rb +26 -26
- data/lib/artifactory/client.rb +25 -23
- data/lib/artifactory/configurable.rb +1 -0
- data/lib/artifactory/defaults.rb +24 -15
- data/lib/artifactory/errors.rb +2 -2
- data/lib/artifactory/resources/artifact.rb +34 -33
- data/lib/artifactory/resources/backup.rb +5 -5
- data/lib/artifactory/resources/base.rb +7 -7
- data/lib/artifactory/resources/build.rb +15 -15
- data/lib/artifactory/resources/build_component.rb +4 -4
- data/lib/artifactory/resources/group.rb +4 -4
- data/lib/artifactory/resources/layout.rb +3 -3
- data/lib/artifactory/resources/ldap_setting.rb +7 -6
- data/lib/artifactory/resources/mail_server.rb +3 -3
- data/lib/artifactory/resources/permission_target.rb +20 -20
- data/lib/artifactory/resources/plugin.rb +1 -1
- data/lib/artifactory/resources/repository.rb +20 -20
- data/lib/artifactory/resources/system.rb +6 -6
- data/lib/artifactory/resources/url_base.rb +4 -3
- data/lib/artifactory/resources/user.rb +4 -4
- data/lib/artifactory/util.rb +10 -10
- data/lib/artifactory/version.rb +1 -1
- data/spec/integration/resources/artifact_spec.rb +31 -31
- data/spec/integration/resources/backup.rb +7 -7
- data/spec/integration/resources/build_component_spec.rb +18 -18
- data/spec/integration/resources/build_spec.rb +15 -15
- data/spec/integration/resources/group_spec.rb +16 -16
- data/spec/integration/resources/layout_spec.rb +7 -7
- data/spec/integration/resources/ldap_setting_spec.rb +7 -7
- data/spec/integration/resources/mail_server_spec.rb +7 -7
- data/spec/integration/resources/permission_target_spec.rb +35 -35
- data/spec/integration/resources/repository_spec.rb +14 -14
- data/spec/integration/resources/system_spec.rb +20 -21
- data/spec/integration/resources/url_base_spec.rb +7 -7
- data/spec/integration/resources/user_spec.rb +16 -16
- data/spec/spec_helper.rb +11 -11
- data/spec/support/api_server.rb +13 -13
- data/spec/support/api_server/artifact_endpoints.rb +94 -94
- data/spec/support/api_server/build_component_endpoints.rb +18 -18
- data/spec/support/api_server/build_endpoints.rb +76 -76
- data/spec/support/api_server/group_endpoints.rb +24 -24
- data/spec/support/api_server/permission_target_endpoints.rb +24 -24
- data/spec/support/api_server/repository_endpoints.rb +82 -82
- data/spec/support/api_server/status_endpoints.rb +5 -5
- data/spec/support/api_server/system_endpoints.rb +17 -18
- data/spec/support/api_server/user_endpoints.rb +30 -30
- data/spec/unit/artifactory_spec.rb +17 -17
- data/spec/unit/client_spec.rb +43 -43
- data/spec/unit/resources/artifact_spec.rb +256 -256
- data/spec/unit/resources/backup_spec.rb +8 -8
- data/spec/unit/resources/base_spec.rb +51 -51
- data/spec/unit/resources/build_component_spec.rb +45 -45
- data/spec/unit/resources/build_spec.rb +98 -98
- data/spec/unit/resources/defaults_spec.rb +4 -4
- data/spec/unit/resources/group_spec.rb +36 -36
- data/spec/unit/resources/layout_spec.rb +8 -8
- data/spec/unit/resources/ldap_setting_spec.rb +8 -8
- data/spec/unit/resources/mail_server_spec.rb +8 -8
- data/spec/unit/resources/permission_target_spec.rb +79 -79
- data/spec/unit/resources/plugin_spec.rb +7 -7
- data/spec/unit/resources/repository_spec.rb +98 -98
- data/spec/unit/resources/system_spec.rb +30 -30
- data/spec/unit/resources/url_base_spec.rb +8 -8
- data/spec/unit/resources/user_spec.rb +40 -40
- metadata +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
module Artifactory
|
|
4
4
|
describe Resource::Backup 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
|
|
12
|
+
describe ".all" do
|
|
13
13
|
doc = <<-XML
|
|
14
14
|
<config>
|
|
15
15
|
<backups>
|
|
@@ -27,14 +27,14 @@ module Artifactory
|
|
|
27
27
|
allow(Resource::System).to receive(:configuration).and_return(xml)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
it
|
|
30
|
+
it "returns the backup settings" 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.key).to eq(
|
|
33
|
+
expect(described_class.all.first.key).to eq("backup-daily")
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
describe
|
|
37
|
+
describe ".find" do
|
|
38
38
|
doc = <<-XML
|
|
39
39
|
<config>
|
|
40
40
|
<backups>
|
|
@@ -52,9 +52,9 @@ module Artifactory
|
|
|
52
52
|
allow(Resource::System).to receive(:configuration).and_return(xml)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
it
|
|
56
|
-
expect(described_class.find(
|
|
57
|
-
expect(described_class.find(
|
|
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
58
|
end
|
|
59
59
|
end
|
|
60
60
|
end
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
module Artifactory
|
|
4
4
|
describe Resource::Base do
|
|
5
5
|
let(:client) { double }
|
|
6
|
-
let(:endpoint_host) {
|
|
6
|
+
let(:endpoint_host) { "http://33.33.33.11" }
|
|
7
7
|
let(:endpoint) { "#{endpoint_host}/" }
|
|
8
8
|
|
|
9
9
|
before do
|
|
10
10
|
allow(Artifactory).to receive(:client).and_return(client)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
describe
|
|
13
|
+
describe ".attribute" do
|
|
14
14
|
before { described_class.attribute(:bacon) }
|
|
15
15
|
|
|
16
|
-
it
|
|
16
|
+
it "defines an accessor method" do
|
|
17
17
|
expect(subject).to respond_to(:bacon)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
it
|
|
20
|
+
it "defines a setter method" do
|
|
21
21
|
expect(subject).to respond_to(:bacon=)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
it
|
|
24
|
+
it "defines a boolean method" do
|
|
25
25
|
expect(subject).to respond_to(:bacon?)
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
describe
|
|
30
|
-
context
|
|
29
|
+
describe ".extract_client!" do
|
|
30
|
+
context "when the :client key is present" do
|
|
31
31
|
let(:client) { double }
|
|
32
32
|
let(:options) { { client: client } }
|
|
33
33
|
|
|
34
|
-
it
|
|
34
|
+
it "extracts the client" do
|
|
35
35
|
result = described_class.extract_client!(options)
|
|
36
36
|
expect(result).to be(client)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
it
|
|
39
|
+
it "removes the key from the hash" do
|
|
40
40
|
described_class.extract_client!(options)
|
|
41
41
|
expect(options).to_not have_key(:client)
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
context
|
|
45
|
+
context "when the :client key is not present" do
|
|
46
46
|
let(:client) { double }
|
|
47
47
|
before { allow(Artifactory).to receive(:client).and_return(client) }
|
|
48
48
|
|
|
49
|
-
it
|
|
49
|
+
it "uses Artifactory.client" do
|
|
50
50
|
expect(described_class.extract_client!({})).to be(client)
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
describe
|
|
56
|
-
context
|
|
57
|
-
it
|
|
58
|
-
options = { repos:
|
|
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
59
|
described_class.format_repos!(options)
|
|
60
|
-
expect(options[:repos]).to eq(
|
|
60
|
+
expect(options[:repos]).to eq("bacon,bits")
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
it
|
|
64
|
-
options = { repos:
|
|
63
|
+
it "accepts a single repository" do
|
|
64
|
+
options = { repos: "bacon" }
|
|
65
65
|
described_class.format_repos!(options)
|
|
66
|
-
expect(options[:repos]).to eq(
|
|
66
|
+
expect(options[:repos]).to eq("bacon")
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
context
|
|
71
|
-
it
|
|
70
|
+
context "when the :repos key is not present" do
|
|
71
|
+
it "does not modify the hash" do
|
|
72
72
|
options = {}
|
|
73
73
|
described_class.format_repos!(options)
|
|
74
74
|
expect(options).to eq(options)
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
context
|
|
79
|
-
it
|
|
78
|
+
context "when the :repos key is empty" do
|
|
79
|
+
it "does not modify the hash" do
|
|
80
80
|
options = { repos: [] }
|
|
81
81
|
described_class.format_repos!(options)
|
|
82
82
|
expect(options).to eq(options)
|
|
@@ -84,14 +84,14 @@ module Artifactory
|
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
describe
|
|
88
|
-
let(:relative_path) {
|
|
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
89
|
|
|
90
|
-
context
|
|
90
|
+
context "when endpoint path part is not empty" do
|
|
91
91
|
let(:endpoint) { "#{endpoint_host}/artifactory" }
|
|
92
92
|
let(:full_url) { "#{endpoint}#{relative_path}" }
|
|
93
93
|
|
|
94
|
-
it
|
|
94
|
+
it "uses the path minus the path part of the endpoint" do
|
|
95
95
|
expect(client).to receive(:endpoint).and_return(endpoint)
|
|
96
96
|
expect(described_class).to receive(:from_hash)
|
|
97
97
|
expect(client).to receive(:get).with(relative_path)
|
|
@@ -99,11 +99,11 @@ module Artifactory
|
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
-
context
|
|
102
|
+
context "when endpoint has empty path part" do
|
|
103
103
|
let(:endpoint) { "#{endpoint_host}/" }
|
|
104
104
|
let(:full_url) { "#{endpoint}#{relative_path}" }
|
|
105
105
|
|
|
106
|
-
it
|
|
106
|
+
it "only uses the path from absolute URLs" do
|
|
107
107
|
expect(client).to receive(:endpoint).and_return(endpoint)
|
|
108
108
|
expect(described_class).to receive(:from_hash)
|
|
109
109
|
expect(client).to receive(:get).with(relative_path)
|
|
@@ -112,26 +112,26 @@ module Artifactory
|
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
-
describe
|
|
116
|
-
let(:string) { double(to_s:
|
|
115
|
+
describe ".url_safe" do
|
|
116
|
+
let(:string) { double(to_s: "string") }
|
|
117
117
|
|
|
118
|
-
it
|
|
118
|
+
it "delegates to URI.escape" do
|
|
119
119
|
expect(URI).to receive(:escape).once
|
|
120
120
|
described_class.url_safe(string)
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
-
it
|
|
123
|
+
it "converts the value to a string" do
|
|
124
124
|
expect(string).to receive(:to_s).once
|
|
125
125
|
described_class.url_safe(string)
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
-
describe
|
|
130
|
-
it
|
|
129
|
+
describe "#client" do
|
|
130
|
+
it "defines a :client method" do
|
|
131
131
|
expect(subject).to respond_to(:client)
|
|
132
132
|
end
|
|
133
133
|
|
|
134
|
-
it
|
|
134
|
+
it "defaults to the Artifactory.client" do
|
|
135
135
|
client = double
|
|
136
136
|
allow(Artifactory).to receive(:client).and_return(client)
|
|
137
137
|
allow(client).to receive(:endpoint).and_return(endpoint)
|
|
@@ -140,40 +140,40 @@ module Artifactory
|
|
|
140
140
|
end
|
|
141
141
|
end
|
|
142
142
|
|
|
143
|
-
describe
|
|
144
|
-
it
|
|
143
|
+
describe "#extract_client!" do
|
|
144
|
+
it "delegates to the class method" do
|
|
145
145
|
expect(described_class).to receive(:extract_client!).once
|
|
146
146
|
subject.extract_client!({})
|
|
147
147
|
end
|
|
148
148
|
end
|
|
149
149
|
|
|
150
|
-
describe
|
|
151
|
-
it
|
|
150
|
+
describe "#format_repos!" do
|
|
151
|
+
it "delegates to the class method" do
|
|
152
152
|
expect(described_class).to receive(:format_repos!).once
|
|
153
153
|
subject.format_repos!({})
|
|
154
154
|
end
|
|
155
155
|
end
|
|
156
156
|
|
|
157
|
-
describe
|
|
158
|
-
it
|
|
157
|
+
describe "#url_safe" do
|
|
158
|
+
it "delegates to the class method" do
|
|
159
159
|
expect(described_class).to receive(:url_safe).once
|
|
160
|
-
subject.url_safe(
|
|
160
|
+
subject.url_safe("string")
|
|
161
161
|
end
|
|
162
162
|
end
|
|
163
163
|
|
|
164
|
-
describe
|
|
165
|
-
it
|
|
166
|
-
expect(subject.to_s).to eq(
|
|
164
|
+
describe "#to_s" do
|
|
165
|
+
it "returns the name of the class" do
|
|
166
|
+
expect(subject.to_s).to eq("#<Base>")
|
|
167
167
|
end
|
|
168
168
|
end
|
|
169
169
|
|
|
170
|
-
describe
|
|
171
|
-
it
|
|
170
|
+
describe "#inspect" do
|
|
171
|
+
it "includes all the attributes" do
|
|
172
172
|
allow(subject).to receive(:attributes) do
|
|
173
|
-
{ foo:
|
|
173
|
+
{ foo: "bar" }
|
|
174
174
|
end
|
|
175
175
|
|
|
176
|
-
expect(subject.inspect).to eq(%q
|
|
176
|
+
expect(subject.inspect).to eq(%q{#<Base foo: "bar">})
|
|
177
177
|
end
|
|
178
178
|
end
|
|
179
179
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
module Artifactory
|
|
4
4
|
describe Resource::BuildComponent do
|
|
@@ -7,111 +7,111 @@ module Artifactory
|
|
|
7
7
|
before(:each) do
|
|
8
8
|
allow(Artifactory).to receive(:client).and_return(client)
|
|
9
9
|
allow(client).to receive(:get).and_return(response) if defined?(response)
|
|
10
|
-
subject.name =
|
|
10
|
+
subject.name = "wicket"
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
describe
|
|
13
|
+
describe ".all" do
|
|
14
14
|
let(:response) do
|
|
15
15
|
{
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
"uri" => "#{Artifactory.endpoint}/api/build",
|
|
17
|
+
"builds" => [
|
|
18
18
|
{
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
"uri" => "/wicket",
|
|
20
|
+
"lastStarted" => "2015-06-19T20:13:20.222Z",
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
"uri" => "/jackrabbit",
|
|
24
|
+
"lastStarted" => "2015-06-20T20:13:20.333Z",
|
|
25
25
|
},
|
|
26
|
-
]
|
|
26
|
+
],
|
|
27
27
|
}
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
before do
|
|
31
|
-
allow(described_class).to receive(:from_hash).with(hash_including(
|
|
32
|
-
allow(described_class).to receive(:from_hash).with(hash_including(
|
|
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
33
|
end
|
|
34
34
|
|
|
35
|
-
it
|
|
36
|
-
expect(client).to receive(:get).with(
|
|
35
|
+
it "GETS /api/build" do
|
|
36
|
+
expect(client).to receive(:get).with("/api/build").once
|
|
37
37
|
described_class.all
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
context
|
|
41
|
-
it
|
|
42
|
-
expect(described_class.all).to eq(%w
|
|
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
43
|
end
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
context
|
|
47
|
-
it
|
|
48
|
-
allow(client).to receive(:get).and_raise(Error::HTTPError.new(
|
|
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
49
|
expect(described_class.all).to be_empty
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
describe
|
|
54
|
+
describe ".find" do
|
|
55
55
|
before do
|
|
56
56
|
allow(described_class).to receive(:all).and_return([
|
|
57
|
-
described_class.new(name:
|
|
58
|
-
described_class.new(name:
|
|
57
|
+
described_class.new(name: "wicket"),
|
|
58
|
+
described_class.new(name: "jackrabbit"),
|
|
59
59
|
])
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
it
|
|
63
|
-
expect(described_class.find(
|
|
62
|
+
it "filters the full build component list by name" do
|
|
63
|
+
expect(described_class.find("wicket")).to_not be_nil
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
context
|
|
67
|
-
it
|
|
68
|
-
expect(described_class.find(
|
|
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
69
|
end
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
describe
|
|
73
|
+
describe ".from_hash" do
|
|
74
74
|
let(:time) { Time.now.utc.round }
|
|
75
75
|
let(:hash) do
|
|
76
76
|
{
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
"uri" => "/wicket",
|
|
78
|
+
"lastStarted" => time.iso8601(3),
|
|
79
79
|
}
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
it
|
|
82
|
+
it "creates a new instance" do
|
|
83
83
|
instance = described_class.from_hash(hash)
|
|
84
|
-
expect(instance.uri).to eq(
|
|
85
|
-
expect(instance.name).to eq(
|
|
84
|
+
expect(instance.uri).to eq("/wicket")
|
|
85
|
+
expect(instance.name).to eq("wicket")
|
|
86
86
|
expect(instance.last_started).to eq(time)
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
describe
|
|
90
|
+
describe "#builds" do
|
|
91
91
|
|
|
92
|
-
it
|
|
92
|
+
it "returns a build collection" do
|
|
93
93
|
expect(subject.builds).to be_a(Collection::Build)
|
|
94
94
|
end
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
-
describe
|
|
97
|
+
describe "#delete" do
|
|
98
98
|
|
|
99
|
-
it
|
|
99
|
+
it "sends DELETE to the client" do
|
|
100
100
|
expect(client).to receive(:delete)
|
|
101
101
|
subject.delete
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
-
it
|
|
105
|
-
expect(client).to receive(:delete).with(
|
|
106
|
-
subject.delete(build_numbers: %w
|
|
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
107
|
end
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
describe
|
|
110
|
+
describe "#rename" do
|
|
111
111
|
|
|
112
|
-
it
|
|
113
|
-
expect(client).to receive(:post).with(
|
|
114
|
-
subject.rename(
|
|
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
115
|
end
|
|
116
116
|
end
|
|
117
117
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
module Artifactory
|
|
4
4
|
describe Resource::Build do
|
|
@@ -9,68 +9,68 @@ module Artifactory
|
|
|
9
9
|
allow(Artifactory).to receive(:client).and_return(client)
|
|
10
10
|
allow(client).to receive(:get).and_return(response) if defined?(response)
|
|
11
11
|
|
|
12
|
-
subject.name =
|
|
13
|
-
subject.number =
|
|
12
|
+
subject.name = "wicket"
|
|
13
|
+
subject.number = "51"
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
describe
|
|
16
|
+
describe ".all" do
|
|
17
17
|
let(:response) do
|
|
18
18
|
{
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
"uri" => "#{Artifactory.endpoint}/api/build/wicket",
|
|
20
|
+
"buildsNumbers" => [
|
|
21
21
|
{
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
"uri" => "/51",
|
|
23
|
+
"started" => "2014-01-01 12:00:00",
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
"uri" => "/52",
|
|
27
|
+
"started" => "2015-01-05 12:00:00",
|
|
28
28
|
},
|
|
29
|
-
]
|
|
29
|
+
],
|
|
30
30
|
}
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
before do
|
|
34
|
-
allow(described_class).to receive(:find).with(
|
|
35
|
-
allow(described_class).to receive(:find).with(
|
|
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
36
|
end
|
|
37
37
|
|
|
38
38
|
it 'GETS /api/build/#{name}' do
|
|
39
|
-
expect(client).to receive(:get).with(
|
|
40
|
-
described_class.all(
|
|
39
|
+
expect(client).to receive(:get).with("/api/build/wicket").once
|
|
40
|
+
described_class.all("wicket")
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
context
|
|
44
|
-
it
|
|
45
|
-
expect(described_class.all(
|
|
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
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
context
|
|
50
|
-
it
|
|
51
|
-
allow(client).to receive(:get).and_raise(Error::HTTPError.new(
|
|
52
|
-
expect(described_class.all(
|
|
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
53
|
end
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
describe
|
|
58
|
-
let(:response) { {
|
|
57
|
+
describe ".find" do
|
|
58
|
+
let(:response) { { "buildInfo" => {} } }
|
|
59
59
|
|
|
60
60
|
it 'GETS /api/repositories/#{name}/#{number}' do
|
|
61
61
|
expect(client).to receive(:get).with("/api/build/wicket/51").once
|
|
62
|
-
described_class.find(
|
|
62
|
+
described_class.find("wicket", 51)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
context
|
|
66
|
-
it
|
|
67
|
-
allow(client).to receive(:get).and_raise(Error::HTTPError.new(
|
|
68
|
-
expect(described_class.find(
|
|
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
69
|
end
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
describe
|
|
73
|
+
describe ".from_hash" do
|
|
74
74
|
let(:hash) do
|
|
75
75
|
{
|
|
76
76
|
"properties" => {
|
|
@@ -82,11 +82,11 @@ module Artifactory
|
|
|
82
82
|
"type" => "MAVEN",
|
|
83
83
|
"buildAgent" => {
|
|
84
84
|
"name" => "Maven",
|
|
85
|
-
"version" => "3.0.5"
|
|
85
|
+
"version" => "3.0.5",
|
|
86
86
|
},
|
|
87
87
|
"agent" => {
|
|
88
88
|
"name" => "Jenkins",
|
|
89
|
-
"version" => "1.565.2"
|
|
89
|
+
"version" => "1.565.2",
|
|
90
90
|
},
|
|
91
91
|
"started" => time.iso8601(3),
|
|
92
92
|
"durationMillis" => 8926,
|
|
@@ -99,12 +99,12 @@ module Artifactory
|
|
|
99
99
|
"includePublishedArtifacts" => false,
|
|
100
100
|
"autoDiscover" => true,
|
|
101
101
|
"scopesList" => "",
|
|
102
|
-
"licenseViolationsRecipientsList" => ""
|
|
102
|
+
"licenseViolationsRecipientsList" => "",
|
|
103
103
|
},
|
|
104
104
|
"buildRetention" => {
|
|
105
105
|
"count" => -1,
|
|
106
106
|
"deleteBuildArtifacts" => true,
|
|
107
|
-
"buildNumbersNotToBeDiscarded" => []
|
|
107
|
+
"buildNumbersNotToBeDiscarded" => [],
|
|
108
108
|
},
|
|
109
109
|
"modules" => modules,
|
|
110
110
|
"governance" => {
|
|
@@ -112,16 +112,16 @@ module Artifactory
|
|
|
112
112
|
"runChecks" => false,
|
|
113
113
|
"includePublishedArtifacts" => false,
|
|
114
114
|
"autoCreateMissingComponentRequests" => false,
|
|
115
|
-
"autoDiscardStaleComponentRequests" => false
|
|
116
|
-
}
|
|
117
|
-
}
|
|
115
|
+
"autoDiscardStaleComponentRequests" => false,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
118
|
}
|
|
119
119
|
end
|
|
120
120
|
let(:modules) do
|
|
121
121
|
[
|
|
122
122
|
{
|
|
123
123
|
"properties" => {
|
|
124
|
-
"project.build.sourceEncoding" => "UTF-8"
|
|
124
|
+
"project.build.sourceEncoding" => "UTF-8",
|
|
125
125
|
},
|
|
126
126
|
"id" => "org.jfrog.test:multi:2.19-SNAPSHOT",
|
|
127
127
|
"artifacts" => [
|
|
@@ -129,107 +129,107 @@ module Artifactory
|
|
|
129
129
|
"type" => "pom",
|
|
130
130
|
"sha1" => "045b66ebbf8504002b626f592d087612aca36582",
|
|
131
131
|
"md5" => "c25542a353dab1089cd186465dc47a68",
|
|
132
|
-
"name" => "multi-2.19-SNAPSHOT.pom"
|
|
133
|
-
}
|
|
134
|
-
]
|
|
132
|
+
"name" => "multi-2.19-SNAPSHOT.pom",
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
135
|
},
|
|
136
136
|
{
|
|
137
137
|
"properties" => {
|
|
138
|
-
"project.build.sourceEncoding" => "UTF-8"
|
|
138
|
+
"project.build.sourceEncoding" => "UTF-8",
|
|
139
139
|
},
|
|
140
140
|
"id" => "org.jfrog.test:multi1:2.19-SNAPSHOT",
|
|
141
|
-
"artifacts"=> [
|
|
141
|
+
"artifacts" => [
|
|
142
142
|
{
|
|
143
143
|
"type" => "jar",
|
|
144
144
|
"sha1" => "f4c5c9cb3091011ec2a895b3dedd7f10d847361c",
|
|
145
145
|
"md5" => "d1fd850a3582efba41092c624e0b46b8",
|
|
146
|
-
"name" => "multi1-2.19-SNAPSHOT.jar"
|
|
146
|
+
"name" => "multi1-2.19-SNAPSHOT.jar",
|
|
147
147
|
},
|
|
148
148
|
{
|
|
149
149
|
"type" => "pom",
|
|
150
150
|
"sha1" => "2ddbf9824676f548d637726d3bcbb494ba823090",
|
|
151
151
|
"md5" => "a64aa7f305f63a85e63a0155ff0fb404",
|
|
152
|
-
"name" => "multi1-2.19-SNAPSHOT.pom"
|
|
152
|
+
"name" => "multi1-2.19-SNAPSHOT.pom",
|
|
153
153
|
},
|
|
154
154
|
{
|
|
155
155
|
"type" => "jar",
|
|
156
156
|
"sha1" => "6fdd143a44cea3a2636660c5c266c95c27e50abc",
|
|
157
157
|
"md5" => "12a1e438f4bef8c4b740fe848a1704a4",
|
|
158
158
|
"id" => "org.slf4j:slf4j-simple:1.4.3",
|
|
159
|
-
"scopes" => [ "compile" ]
|
|
159
|
+
"scopes" => [ "compile" ],
|
|
160
160
|
},
|
|
161
161
|
{
|
|
162
162
|
"type" => "jar",
|
|
163
163
|
"sha1" => "496e91f7df8a0417e00cecdba840cdf0e5f2472c",
|
|
164
164
|
"md5" => "76a412a37c9d18659d2dacccdb1c24ff",
|
|
165
165
|
"id" => "org.jenkins-ci.lib:dry-run-lib:0.1",
|
|
166
|
-
"scopes" => [ "compile" ]
|
|
167
|
-
}
|
|
168
|
-
]
|
|
166
|
+
"scopes" => [ "compile" ],
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
169
|
},
|
|
170
170
|
{
|
|
171
171
|
"properties" => {
|
|
172
172
|
"daversion" => "2.19-SNAPSHOT",
|
|
173
|
-
"project.build.sourceEncoding"=>"UTF-8"
|
|
173
|
+
"project.build.sourceEncoding" => "UTF-8",
|
|
174
174
|
},
|
|
175
175
|
"id" => "org.jfrog.test:multi2:2.19-SNAPSHOT",
|
|
176
176
|
"artifacts" => [
|
|
177
177
|
{
|
|
178
178
|
"type" => "txt",
|
|
179
|
-
"name" => "multi2-2.19-SNAPSHOT.txt"
|
|
179
|
+
"name" => "multi2-2.19-SNAPSHOT.txt",
|
|
180
180
|
},
|
|
181
181
|
{
|
|
182
182
|
"type" => "java-source-jar",
|
|
183
183
|
"sha1" => "49108b0c7db5fdb4efe3c29a5a9f54e806aecb62",
|
|
184
184
|
"md5" => "0e2c5473cf2a9b694afb4a2e8da34b53",
|
|
185
|
-
"name" => "multi2-2.19-SNAPSHOT-sources.jar"},
|
|
185
|
+
"name" => "multi2-2.19-SNAPSHOT-sources.jar" },
|
|
186
186
|
{
|
|
187
187
|
"type" => "jar",
|
|
188
188
|
"sha1" => "476e89d290ae36dabb38ff22f75f264ae019d542",
|
|
189
189
|
"md5" => "fa9b3df58ac040fffcff9310f261be80",
|
|
190
|
-
"name" => "multi2-2.19-SNAPSHOT.jar"
|
|
190
|
+
"name" => "multi2-2.19-SNAPSHOT.jar",
|
|
191
191
|
},
|
|
192
192
|
{
|
|
193
193
|
"type" => "pom",
|
|
194
194
|
"sha1" => "b719b90364e5ae38cda358072f61f821bdae5d5d",
|
|
195
195
|
"md5" => "8d5060005235d75907baca4490cf60bf",
|
|
196
|
-
"name" => "multi2-2.19-SNAPSHOT.pom"
|
|
197
|
-
}
|
|
196
|
+
"name" => "multi2-2.19-SNAPSHOT.pom",
|
|
197
|
+
},
|
|
198
198
|
],
|
|
199
|
-
"dependencies"=> [
|
|
199
|
+
"dependencies" => [
|
|
200
200
|
{
|
|
201
201
|
"type" => "jar",
|
|
202
202
|
"sha1" => "19d4e90b43059058f6e056f794f0ea4030d60b86",
|
|
203
203
|
"md5" => "dcd95bcb84b09897b2b66d4684c040da",
|
|
204
204
|
"id" => "xpp3:xpp3_min:1.1.4c",
|
|
205
|
-
"scopes" => [ "provided" ]
|
|
205
|
+
"scopes" => [ "provided" ],
|
|
206
206
|
},
|
|
207
207
|
{
|
|
208
208
|
"type" => "jar",
|
|
209
209
|
"sha1" => "e2d866af5518e81282838301b49a1bd2452619d3",
|
|
210
210
|
"md5" => "e9e4b59c69305ba3698dd61c5dfc4fc8",
|
|
211
211
|
"id" => "org.jvnet.hudson.plugins:perforce:1.3.7",
|
|
212
|
-
"scopes" => [ "compile" ]
|
|
212
|
+
"scopes" => [ "compile" ],
|
|
213
213
|
},
|
|
214
214
|
{
|
|
215
215
|
"type" => "jar",
|
|
216
216
|
"sha1" => "6fdd143a44cea3a2636660c5c266c95c27e50abc",
|
|
217
217
|
"md5" => "12a1e438f4bef8c4b740fe848a1704a4",
|
|
218
218
|
"id" => "org.slf4j:slf4j-simple:1.4.3",
|
|
219
|
-
"scopes" => [ "compile" ]
|
|
219
|
+
"scopes" => [ "compile" ],
|
|
220
220
|
},
|
|
221
221
|
{
|
|
222
222
|
"type" => "jar",
|
|
223
223
|
"sha1" => "496e91f7df8a0417e00cecdba840cdf0e5f2472c",
|
|
224
224
|
"md5" => "76a412a37c9d18659d2dacccdb1c24ff",
|
|
225
225
|
"id" => "org.jenkins-ci.lib:dry-run-lib:0.1",
|
|
226
|
-
"scopes" => [ "compile" ]
|
|
227
|
-
}
|
|
228
|
-
]
|
|
226
|
+
"scopes" => [ "compile" ],
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
229
|
},
|
|
230
230
|
{
|
|
231
231
|
"properties" => {
|
|
232
|
-
"project.build.sourceEncoding" => "UTF-8"
|
|
232
|
+
"project.build.sourceEncoding" => "UTF-8",
|
|
233
233
|
},
|
|
234
234
|
"id" => "org.jfrog.test:multi3:2.19-SNAPSHOT",
|
|
235
235
|
"artifacts" => [
|
|
@@ -237,43 +237,43 @@ module Artifactory
|
|
|
237
237
|
"type" => "java-source-jar",
|
|
238
238
|
"sha1" => "3cd104785167ac37ef999431f308ffef10810348",
|
|
239
239
|
"md5" => "c683276f8dda97078ae8eb5e26bb3ee5",
|
|
240
|
-
"name" => "multi3-2.19-SNAPSHOT-sources.jar"
|
|
240
|
+
"name" => "multi3-2.19-SNAPSHOT-sources.jar",
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
243
|
"type" => "war",
|
|
244
244
|
"sha1" => "34aeebeb805b23922d9d05507404533518cf81e4",
|
|
245
245
|
"md5" => "55af06a2175cfb23cc6dc3931475b57c",
|
|
246
|
-
"name" => "multi3-2.19-SNAPSHOT.war"
|
|
246
|
+
"name" => "multi3-2.19-SNAPSHOT.war",
|
|
247
247
|
},
|
|
248
248
|
{
|
|
249
249
|
"type" => "jar",
|
|
250
250
|
"sha1" => "496e91f7df8a0417e00cecdba840cdf0e5f2472c",
|
|
251
251
|
"md5" => "76a412a37c9d18659d2dacccdb1c24ff",
|
|
252
252
|
"id" => "org.jenkins-ci.lib:dry-run-lib:0.1",
|
|
253
|
-
"scopes" => [ "compile" ]
|
|
253
|
+
"scopes" => [ "compile" ],
|
|
254
254
|
},
|
|
255
255
|
{
|
|
256
256
|
"type" => "jar",
|
|
257
257
|
"sha1" => "7e9978fdb754bce5fcd5161133e7734ecb683036",
|
|
258
258
|
"md5" => "7df83e09e41d742cc5fb20d16b80729c",
|
|
259
259
|
"id" => "hsqldb:hsqldb:1.8.0.10",
|
|
260
|
-
"scopes" => [ "runtime" ]
|
|
261
|
-
}
|
|
262
|
-
]
|
|
263
|
-
}
|
|
260
|
+
"scopes" => [ "runtime" ],
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
},
|
|
264
264
|
]
|
|
265
265
|
end
|
|
266
266
|
|
|
267
|
-
it
|
|
267
|
+
it "creates a new instance" do
|
|
268
268
|
instance = described_class.from_hash(hash)
|
|
269
269
|
expect(instance.properties).to eq("buildInfo.env.JAVA_HOME" => "/usr/jdk/latest")
|
|
270
|
-
expect(instance.version).to eq(
|
|
271
|
-
expect(instance.name).to eq(
|
|
272
|
-
expect(instance.number).to eq(
|
|
273
|
-
expect(instance.type).to eq(
|
|
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
274
|
expect(instance.build_agent).to eq(
|
|
275
275
|
"name" => "Maven",
|
|
276
|
-
"version" => "3.0.5"
|
|
276
|
+
"version" => "3.0.5"
|
|
277
277
|
)
|
|
278
278
|
expect(instance.agent).to eq(
|
|
279
279
|
"name" => "Jenkins",
|
|
@@ -281,10 +281,10 @@ module Artifactory
|
|
|
281
281
|
)
|
|
282
282
|
expect(instance.started).to eq(time)
|
|
283
283
|
expect(instance.duration_millis).to eq(8926)
|
|
284
|
-
expect(instance.artifactory_principal).to eq(
|
|
285
|
-
expect(instance.url).to eq(
|
|
286
|
-
expect(instance.vcs_revision).to eq(
|
|
287
|
-
expect(instance.vcs_url).to eq(
|
|
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
288
|
expect(instance.build_retention).to eq(
|
|
289
289
|
"count" => -1,
|
|
290
290
|
"deleteBuildArtifacts" => true,
|
|
@@ -298,47 +298,47 @@ module Artifactory
|
|
|
298
298
|
"runChecks" => false,
|
|
299
299
|
"includePublishedArtifacts" => false,
|
|
300
300
|
"autoCreateMissingComponentRequests" => false,
|
|
301
|
-
"autoDiscardStaleComponentRequests" => false
|
|
301
|
+
"autoDiscardStaleComponentRequests" => false,
|
|
302
302
|
}
|
|
303
303
|
)
|
|
304
304
|
end
|
|
305
305
|
end
|
|
306
306
|
|
|
307
|
-
describe
|
|
308
|
-
it
|
|
309
|
-
expect(client).to receive(:get).with(
|
|
310
|
-
subject.diff(
|
|
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
311
|
end
|
|
312
312
|
end
|
|
313
313
|
|
|
314
|
-
describe
|
|
315
|
-
let(:to_repo) {
|
|
314
|
+
describe "#promote" do
|
|
315
|
+
let(:to_repo) { "omnibus-stable-local" }
|
|
316
316
|
before do
|
|
317
|
-
Artifactory.username =
|
|
317
|
+
Artifactory.username = "doge"
|
|
318
318
|
end
|
|
319
319
|
|
|
320
|
-
it
|
|
321
|
-
expect(client).to receive(:post).with(
|
|
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
322
|
subject.promote(to_repo)
|
|
323
323
|
end
|
|
324
324
|
|
|
325
|
-
it
|
|
326
|
-
expect(client).to receive(:post).with(
|
|
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
327
|
subject.promote(to_repo)
|
|
328
328
|
end
|
|
329
329
|
end
|
|
330
330
|
|
|
331
|
-
describe
|
|
331
|
+
describe "#save" do
|
|
332
332
|
|
|
333
|
-
it
|
|
334
|
-
expect(client).to receive(:put).with(
|
|
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
335
|
subject.save
|
|
336
336
|
end
|
|
337
337
|
|
|
338
|
-
context
|
|
339
|
-
before { subject.type =
|
|
338
|
+
context "an invalid build type is provided" do
|
|
339
|
+
before { subject.type = "PIRATE" }
|
|
340
340
|
|
|
341
|
-
it
|
|
341
|
+
it "raises an InvalidBuildType error" do
|
|
342
342
|
expect { subject.save }.to raise_error(Error::InvalidBuildType)
|
|
343
343
|
end
|
|
344
344
|
end
|