artifactory 1.2.0 → 2.0.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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile +1 -1
  4. data/lib/artifactory.rb +13 -9
  5. data/lib/artifactory/client.rb +16 -3
  6. data/lib/artifactory/errors.rb +1 -2
  7. data/lib/artifactory/resources/artifact.rb +56 -27
  8. data/lib/artifactory/resources/backup.rb +104 -0
  9. data/lib/artifactory/resources/base.rb +47 -0
  10. data/lib/artifactory/resources/layout.rb +1 -50
  11. data/lib/artifactory/resources/ldap_setting.rb +105 -0
  12. data/lib/artifactory/resources/mail_server.rb +61 -0
  13. data/lib/artifactory/resources/repository.rb +11 -14
  14. data/lib/artifactory/resources/url_base.rb +74 -0
  15. data/lib/artifactory/util.rb +41 -0
  16. data/lib/artifactory/version.rb +1 -1
  17. data/spec/integration/resources/backup.rb +22 -0
  18. data/spec/integration/resources/build_spec.rb +1 -3
  19. data/spec/integration/resources/group_spec.rb +2 -2
  20. data/spec/integration/resources/ldap_setting_spec.rb +22 -0
  21. data/spec/integration/resources/mail_server_spec.rb +22 -0
  22. data/spec/integration/resources/repository_spec.rb +1 -1
  23. data/spec/integration/resources/system_spec.rb +1 -1
  24. data/spec/integration/resources/url_base_spec.rb +22 -0
  25. data/spec/integration/resources/user_spec.rb +2 -2
  26. data/spec/spec_helper.rb +0 -1
  27. data/spec/support/api_server/system_endpoints.rb +44 -1
  28. data/spec/unit/artifactory_spec.rb +3 -3
  29. data/spec/unit/client_spec.rb +1 -1
  30. data/spec/unit/resources/artifact_spec.rb +18 -36
  31. data/spec/unit/resources/backup_spec.rb +61 -0
  32. data/spec/unit/resources/base_spec.rb +3 -3
  33. data/spec/unit/resources/build_spec.rb +3 -3
  34. data/spec/unit/resources/group_spec.rb +6 -6
  35. data/spec/unit/resources/layout_spec.rb +4 -4
  36. data/spec/unit/resources/ldap_setting_spec.rb +65 -0
  37. data/spec/unit/resources/mail_server_spec.rb +57 -0
  38. data/spec/unit/resources/plugin_spec.rb +2 -2
  39. data/spec/unit/resources/repository_spec.rb +19 -27
  40. data/spec/unit/resources/system_spec.rb +6 -6
  41. data/spec/unit/resources/url_base_spec.rb +53 -0
  42. data/spec/unit/resources/user_spec.rb +8 -8
  43. metadata +23 -3
@@ -0,0 +1,65 @@
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
@@ -0,0 +1,57 @@
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
@@ -5,8 +5,8 @@ module Artifactory
5
5
  let(:client) { double(:client) }
6
6
 
7
7
  before(:each) do
8
- Artifactory.stub(:client).and_return(client)
9
- client.stub(:get).and_return(response) if defined?(response)
8
+ allow(Artifactory).to receive(:client).and_return(client)
9
+ allow(client).to receive(:get).and_return(response) if defined?(response)
10
10
  end
11
11
 
12
12
  describe '.all' do
@@ -5,8 +5,8 @@ module Artifactory
5
5
  let(:client) { double(:client) }
6
6
 
7
7
  before(:each) do
8
- Artifactory.stub(:client).and_return(client)
9
- client.stub(:get).and_return(response) if defined?(response)
8
+ allow(Artifactory).to receive(:client).and_return(client)
9
+ allow(client).to receive(:get).and_return(response) if defined?(response)
10
10
  end
11
11
 
12
12
  describe '.all' do
@@ -18,9 +18,9 @@ module Artifactory
18
18
  ]
19
19
  end
20
20
  before do
21
- described_class.stub(:find).with('a', client: client).and_return('a')
22
- described_class.stub(:find).with('b', client: client).and_return('b')
23
- described_class.stub(:find).with('c', client: client).and_return('c')
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
24
  end
25
25
 
26
26
  it 'gets /api/repositories' do
@@ -70,12 +70,12 @@ module Artifactory
70
70
 
71
71
  it 'creates a new instance' do
72
72
  instance = described_class.from_hash(hash)
73
- expect(instance.blacked_out).to be_false
73
+ expect(instance.blacked_out).to be_falsey
74
74
  expect(instance.description).to eq('Local repository for in-house libraries')
75
75
  expect(instance.checksum_policy).to eq('client-checksums')
76
76
  expect(instance.excludes_pattern).to eq('')
77
- expect(instance.handle_releases).to be_true
78
- expect(instance.handle_snapshots).to be_false
77
+ expect(instance.handle_releases).to be_truthy
78
+ expect(instance.handle_snapshots).to be_falsey
79
79
  expect(instance.includes_pattern).to eq('**/*')
80
80
  expect(instance.key).to eq('libs-release-local')
81
81
  expect(instance.maximum_unique_snapshots).to eq(0)
@@ -83,7 +83,7 @@ module Artifactory
83
83
  expect(instance.property_sets).to eq(['artifactory'])
84
84
  expect(instance.rclass).to eq('local')
85
85
  expect(instance.snapshot_version_behavior).to eq('unique')
86
- expect(instance.suppress_pom_checks).to be_false
86
+ expect(instance.suppress_pom_checks).to be_falsey
87
87
  end
88
88
  end
89
89
 
@@ -107,21 +107,11 @@ module Artifactory
107
107
  subject.key = 'libs-release-local'
108
108
  end
109
109
 
110
- context 'when the artifact is a File' do
111
- it 'PUTs the file to the server' do
112
- file = double(file)
113
- File.stub(:new).and_return(file)
114
- expect(client).to receive(:put).with('libs-release-local/remote/path', file, {})
115
-
116
- subject.upload(file, '/remote/path')
117
- end
118
- end
119
-
120
110
  context 'when the artifact is a file path' do
121
111
  it 'PUTs the file at the path to the server' do
122
- file = double(file)
112
+ file = double(File)
123
113
  path = '/fake/path'
124
- File.stub(:new).with('/fake/path').and_return(file)
114
+ allow(File).to receive(:new).with('/fake/path').and_return(file)
125
115
  expect(client).to receive(:put).with('libs-release-local/remote/path', file, {})
126
116
 
127
117
  subject.upload(path, '/remote/path')
@@ -130,11 +120,12 @@ module Artifactory
130
120
 
131
121
  context 'when matrix properties are given' do
132
122
  it 'converts the hash into matrix properties' do
133
- file = double(file)
134
- File.stub(:new).and_return(file)
123
+ file = double(File)
124
+ path = '/fake/path'
125
+ allow(File).to receive(:new).with('/fake/path').and_return(file)
135
126
  expect(client).to receive(:put).with('libs-release-local;branch=master;user=Seth%20Vargo/remote/path', file, {})
136
127
 
137
- subject.upload(file, '/remote/path',
128
+ subject.upload(path, '/remote/path',
138
129
  branch: 'master',
139
130
  user: 'Seth Vargo',
140
131
  )
@@ -144,11 +135,12 @@ module Artifactory
144
135
  context 'when custom headers are given' do
145
136
  it 'passes the headers to the client' do
146
137
  headers = { 'Content-Type' => 'text/plain' }
147
- file = double(file)
148
- File.stub(:new).and_return(file)
138
+ file = double(File)
139
+ path = '/fake/path'
140
+ allow(File).to receive(:new).with('/fake/path').and_return(file)
149
141
  expect(client).to receive(:put).with('libs-release-local/remote/path', file, headers)
150
142
 
151
- subject.upload(file, '/remote/path', {}, headers)
143
+ subject.upload(path, '/remote/path', {}, headers)
152
144
  end
153
145
  end
154
146
  end
@@ -5,8 +5,8 @@ module Artifactory
5
5
  let(:client) { double(:client) }
6
6
 
7
7
  before(:each) do
8
- Artifactory.stub(:client).and_return(client)
9
- client.stub(:get).and_return(response) if defined?(response)
8
+ allow(Artifactory).to receive(:client).and_return(client)
9
+ allow(client).to receive(:get).and_return(response) if defined?(response)
10
10
  end
11
11
 
12
12
  describe '.info' do
@@ -32,15 +32,15 @@ module Artifactory
32
32
 
33
33
  context 'when the system is ok' do
34
34
  it 'returns true' do
35
- expect(described_class.ping).to be_true
35
+ expect(described_class.ping).to be_truthy
36
36
  end
37
37
  end
38
38
 
39
39
  context 'when the system is not running' do
40
40
  it 'returns false' do
41
- client.stub(:get)
41
+ allow(client).to receive(:get)
42
42
  .and_raise(Error::ConnectionError.new(Artifactory.endpoint))
43
- expect(described_class.ping).to be_false
43
+ expect(described_class.ping).to be_falsey
44
44
  end
45
45
  end
46
46
  end
@@ -61,7 +61,7 @@ module Artifactory
61
61
  describe '.update_configuration' do
62
62
  let(:xml) { double(:xml) }
63
63
  let(:response) { double(body: '...') }
64
- before { client.stub(:post).and_return(response) }
64
+ before { allow(client).to receive(:post).and_return(response) }
65
65
 
66
66
  it 'posts /api/system/configuration' do
67
67
  headers = { 'Content-Type' => 'application/xml' }
@@ -0,0 +1,53 @@
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
@@ -5,8 +5,8 @@ module Artifactory
5
5
  let(:client) { double(:client) }
6
6
 
7
7
  before(:each) do
8
- Artifactory.stub(:client).and_return(client)
9
- client.stub(:get).and_return(response) if defined?(response)
8
+ allow(Artifactory).to receive(:client).and_return(client)
9
+ allow(client).to receive(:get).and_return(response) if defined?(response)
10
10
  end
11
11
 
12
12
  describe '.all' do
@@ -18,9 +18,9 @@ module Artifactory
18
18
  ]
19
19
  end
20
20
  before do
21
- described_class.stub(:from_url).with('a', client: client).and_return('a')
22
- described_class.stub(:from_url).with('b', client: client).and_return('b')
23
- described_class.stub(:from_url).with('c', client: client).and_return('c')
21
+ allow(described_class).to receive(:from_url).with('a', client: client).and_return('a')
22
+ allow(described_class).to receive(:from_url).with('b', client: client).and_return('b')
23
+ allow(described_class).to receive(:from_url).with('c', client: client).and_return('c')
24
24
  end
25
25
 
26
26
  it 'gets /api/security/users' do
@@ -67,14 +67,14 @@ module Artifactory
67
67
 
68
68
  it 'creates a new instance' do
69
69
  instance = described_class.from_hash(hash)
70
- expect(instance.admin).to be_false
70
+ expect(instance.admin).to be_falsey
71
71
  expect(instance.email).to eq('admin@example.com')
72
72
  expect(instance.groups).to eq(['admin'])
73
- expect(instance.internal_password_disabled).to be_true
73
+ expect(instance.internal_password_disabled).to be_truthy
74
74
  expect(instance.last_logged_in).to be_nil
75
75
  expect(instance.name).to eq('admin')
76
76
  expect(instance.password).to be_nil
77
- expect(instance.profile_updatable).to be_true
77
+ expect(instance.profile_updatable).to be_truthy
78
78
  expect(instance.realm).to eq('artifactory')
79
79
  end
80
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artifactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Vargo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-02 00:00:00.000000000 Z
11
+ date: 2014-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,22 +60,30 @@ files:
60
60
  - lib/artifactory/defaults.rb
61
61
  - lib/artifactory/errors.rb
62
62
  - lib/artifactory/resources/artifact.rb
63
+ - lib/artifactory/resources/backup.rb
63
64
  - lib/artifactory/resources/base.rb
64
65
  - lib/artifactory/resources/build.rb
65
66
  - lib/artifactory/resources/group.rb
66
67
  - lib/artifactory/resources/layout.rb
68
+ - lib/artifactory/resources/ldap_setting.rb
69
+ - lib/artifactory/resources/mail_server.rb
67
70
  - lib/artifactory/resources/plugin.rb
68
71
  - lib/artifactory/resources/repository.rb
69
72
  - lib/artifactory/resources/system.rb
73
+ - lib/artifactory/resources/url_base.rb
70
74
  - lib/artifactory/resources/user.rb
71
75
  - lib/artifactory/util.rb
72
76
  - lib/artifactory/version.rb
73
77
  - spec/integration/resources/artifact_spec.rb
78
+ - spec/integration/resources/backup.rb
74
79
  - spec/integration/resources/build_spec.rb
75
80
  - spec/integration/resources/group_spec.rb
76
81
  - spec/integration/resources/layout_spec.rb
82
+ - spec/integration/resources/ldap_setting_spec.rb
83
+ - spec/integration/resources/mail_server_spec.rb
77
84
  - spec/integration/resources/repository_spec.rb
78
85
  - spec/integration/resources/system_spec.rb
86
+ - spec/integration/resources/url_base_spec.rb
79
87
  - spec/integration/resources/user_spec.rb
80
88
  - spec/spec_helper.rb
81
89
  - spec/support/api_server.rb
@@ -89,13 +97,17 @@ files:
89
97
  - spec/unit/artifactory_spec.rb
90
98
  - spec/unit/client_spec.rb
91
99
  - spec/unit/resources/artifact_spec.rb
100
+ - spec/unit/resources/backup_spec.rb
92
101
  - spec/unit/resources/base_spec.rb
93
102
  - spec/unit/resources/build_spec.rb
94
103
  - spec/unit/resources/group_spec.rb
95
104
  - spec/unit/resources/layout_spec.rb
105
+ - spec/unit/resources/ldap_setting_spec.rb
106
+ - spec/unit/resources/mail_server_spec.rb
96
107
  - spec/unit/resources/plugin_spec.rb
97
108
  - spec/unit/resources/repository_spec.rb
98
109
  - spec/unit/resources/system_spec.rb
110
+ - spec/unit/resources/url_base_spec.rb
99
111
  - spec/unit/resources/user_spec.rb
100
112
  homepage: https://github.com/opscode/artifactory-client
101
113
  licenses:
@@ -117,18 +129,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
129
  version: '0'
118
130
  requirements: []
119
131
  rubyforge_project:
120
- rubygems_version: 2.2.2
132
+ rubygems_version: 2.3.0
121
133
  signing_key:
122
134
  specification_version: 4
123
135
  summary: Artifactory is a simple, lightweight Ruby client for interacting with the
124
136
  Artifactory and Artifactory Pro APIs.
125
137
  test_files:
126
138
  - spec/integration/resources/artifact_spec.rb
139
+ - spec/integration/resources/backup.rb
127
140
  - spec/integration/resources/build_spec.rb
128
141
  - spec/integration/resources/group_spec.rb
129
142
  - spec/integration/resources/layout_spec.rb
143
+ - spec/integration/resources/ldap_setting_spec.rb
144
+ - spec/integration/resources/mail_server_spec.rb
130
145
  - spec/integration/resources/repository_spec.rb
131
146
  - spec/integration/resources/system_spec.rb
147
+ - spec/integration/resources/url_base_spec.rb
132
148
  - spec/integration/resources/user_spec.rb
133
149
  - spec/spec_helper.rb
134
150
  - spec/support/api_server.rb
@@ -142,12 +158,16 @@ test_files:
142
158
  - spec/unit/artifactory_spec.rb
143
159
  - spec/unit/client_spec.rb
144
160
  - spec/unit/resources/artifact_spec.rb
161
+ - spec/unit/resources/backup_spec.rb
145
162
  - spec/unit/resources/base_spec.rb
146
163
  - spec/unit/resources/build_spec.rb
147
164
  - spec/unit/resources/group_spec.rb
148
165
  - spec/unit/resources/layout_spec.rb
166
+ - spec/unit/resources/ldap_setting_spec.rb
167
+ - spec/unit/resources/mail_server_spec.rb
149
168
  - spec/unit/resources/plugin_spec.rb
150
169
  - spec/unit/resources/repository_spec.rb
151
170
  - spec/unit/resources/system_spec.rb
171
+ - spec/unit/resources/url_base_spec.rb
152
172
  - spec/unit/resources/user_spec.rb
153
173
  has_rdoc: