artifactory 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +11 -7
  3. data/CHANGELOG.md +18 -0
  4. data/README.md +25 -4
  5. data/Rakefile +5 -2
  6. data/artifactory.gemspec +0 -3
  7. data/lib/artifactory.rb +2 -4
  8. data/lib/artifactory/client.rb +210 -85
  9. data/lib/artifactory/configurable.rb +6 -1
  10. data/lib/artifactory/defaults.rb +52 -3
  11. data/lib/artifactory/errors.rb +21 -14
  12. data/lib/artifactory/resources/artifact.rb +132 -58
  13. data/lib/artifactory/resources/base.rb +120 -6
  14. data/lib/artifactory/resources/build.rb +2 -1
  15. data/lib/artifactory/resources/group.rb +5 -72
  16. data/lib/artifactory/resources/layout.rb +106 -0
  17. data/lib/artifactory/resources/repository.rb +62 -114
  18. data/lib/artifactory/resources/system.rb +5 -1
  19. data/lib/artifactory/resources/user.rb +5 -79
  20. data/lib/artifactory/util.rb +8 -2
  21. data/lib/artifactory/version.rb +1 -1
  22. data/spec/integration/resources/layout_spec.rb +22 -0
  23. data/spec/integration/resources/repository_spec.rb +7 -0
  24. data/spec/integration/resources/system_spec.rb +4 -4
  25. data/spec/support/api_server/repository_endpoints.rb +5 -0
  26. data/spec/support/api_server/system_endpoints.rb +18 -0
  27. data/spec/unit/client_spec.rb +17 -98
  28. data/spec/unit/resources/artifact_spec.rb +99 -13
  29. data/spec/unit/resources/build_spec.rb +1 -1
  30. data/spec/unit/resources/group_spec.rb +1 -1
  31. data/spec/unit/resources/layout_spec.rb +61 -0
  32. data/spec/unit/resources/repository_spec.rb +31 -47
  33. data/spec/unit/resources/system_spec.rb +4 -2
  34. data/spec/unit/resources/user_spec.rb +1 -1
  35. metadata +16 -40
  36. data/locales/en.yml +0 -27
@@ -25,7 +25,7 @@ module Artifactory
25
25
 
26
26
  context 'when the system has no builds' do
27
27
  it 'returns an empty array' do
28
- client.stub(:get).and_raise(Error::NotFound)
28
+ client.stub(:get).and_raise(Error::HTTPError.new('status' => 404))
29
29
  expect(described_class.all).to be_empty
30
30
  end
31
31
  end
@@ -62,7 +62,7 @@ module Artifactory
62
62
  }
63
63
  end
64
64
 
65
- it 'creates a new instnace' do
65
+ it 'creates a new instance' do
66
66
  instance = described_class.from_hash(hash)
67
67
  expect(instance.name).to eq('readers')
68
68
  expect(instance.description).to eq('This list of read-only users')
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ module Artifactory
4
+ describe Resource::Layout do
5
+ let(:client) { double(:client) }
6
+
7
+ before(:each) do
8
+ Artifactory.stub(:client).and_return(client)
9
+ client.stub(:get).and_return(response) if defined?(response)
10
+ end
11
+
12
+ describe '.all' do
13
+ doc = <<-XML
14
+ <config>
15
+ <repoLayouts>
16
+ <repoLayout>
17
+ <name>fake-layout</name>
18
+ </repoLayout>
19
+ </repoLayouts>
20
+ </config>
21
+ XML
22
+ let(:xml) do
23
+ REXML::Document.new(doc)
24
+ end
25
+
26
+ before do
27
+ Resource::System.stub(:configuration).and_return(xml)
28
+ end
29
+
30
+ it 'returns the layouts' do
31
+ expect(described_class.all).to be_a(Array)
32
+ expect(described_class.all.first).to be_a(described_class)
33
+ expect(described_class.all.first.name).to eq('fake-layout')
34
+ end
35
+ end
36
+
37
+ describe '.find' do
38
+ doc = <<-XML
39
+ <config>
40
+ <repoLayouts>
41
+ <repoLayout>
42
+ <name>found-layout</name>
43
+ </repoLayout>
44
+ </repoLayouts>
45
+ </config>
46
+ XML
47
+ let(:xml) do
48
+ REXML::Document.new(doc)
49
+ end
50
+
51
+ before do
52
+ Resource::System.stub(:configuration).and_return(xml)
53
+ end
54
+
55
+ it 'returns the found layout' do
56
+ expect(described_class.find('found-layout')).to be_a(described_class)
57
+ expect(described_class.find('found-layout').name).to eq('found-layout')
58
+ end
59
+ end
60
+ end
61
+ end
@@ -18,9 +18,9 @@ module Artifactory
18
18
  ]
19
19
  end
20
20
  before do
21
- described_class.stub(:find).with(name: 'a', client: client).and_return('a')
22
- described_class.stub(:find).with(name: 'b', client: client).and_return('b')
23
- described_class.stub(:find).with(name: 'c', client: client).and_return('c')
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')
24
24
  end
25
25
 
26
26
  it 'gets /api/repositories' do
@@ -38,7 +38,7 @@ module Artifactory
38
38
 
39
39
  it 'gets /api/repositories/#{name}' do
40
40
  expect(client).to receive(:get).with('/api/repositories/libs-release-local').once
41
- described_class.find(name: 'libs-release-local')
41
+ described_class.find('libs-release-local')
42
42
  end
43
43
  end
44
44
 
@@ -68,7 +68,7 @@ module Artifactory
68
68
  }
69
69
  end
70
70
 
71
- it 'creates a new instnace' do
71
+ it 'creates a new instance' do
72
72
  instance = described_class.from_hash(hash)
73
73
  expect(instance.blacked_out).to be_false
74
74
  expect(instance.description).to eq('Local repository for in-house libraries')
@@ -81,14 +81,27 @@ module Artifactory
81
81
  expect(instance.maximum_unique_snapshots).to eq(0)
82
82
  expect(instance.notes).to eq('')
83
83
  expect(instance.property_sets).to eq(['artifactory'])
84
+ expect(instance.rclass).to eq('local')
84
85
  expect(instance.snapshot_version_behavior).to eq('unique')
85
86
  expect(instance.suppress_pom_checks).to be_false
86
- expect(instance.type).to eq('local')
87
87
  end
88
88
  end
89
89
 
90
- describe '#upload' do
90
+ describe '#save' do
91
91
  let(:client) { double }
92
+ before do
93
+ subject.client = client
94
+ subject.key = 'libs-release-local'
95
+ end
96
+
97
+ it 'PUTS the file to the server' do
98
+ expect(client).to receive(:put).with('/api/repositories/libs-release-local', kind_of(String), kind_of(Hash))
99
+ subject.save
100
+ end
101
+ end
102
+
103
+ describe '#upload' do
104
+ let(:client) { double(put: {}) }
92
105
  before do
93
106
  subject.client = client
94
107
  subject.key = 'libs-release-local'
@@ -96,8 +109,9 @@ module Artifactory
96
109
 
97
110
  context 'when the artifact is a File' do
98
111
  it 'PUTs the file to the server' do
99
- file = double(:file, is_a?: true)
100
- expect(client).to receive(:put).with('libs-release-local/remote/path', { file: file }, {})
112
+ file = double(file)
113
+ File.stub(:new).and_return(file)
114
+ expect(client).to receive(:put).with('libs-release-local/remote/path', file, {})
101
115
 
102
116
  subject.upload(file, '/remote/path')
103
117
  end
@@ -105,10 +119,10 @@ module Artifactory
105
119
 
106
120
  context 'when the artifact is a file path' do
107
121
  it 'PUTs the file at the path to the server' do
108
- file = double(:file)
122
+ file = double(file)
109
123
  path = '/fake/path'
110
124
  File.stub(:new).with('/fake/path').and_return(file)
111
- expect(client).to receive(:put).with('libs-release-local/remote/path', { file: file }, {})
125
+ expect(client).to receive(:put).with('libs-release-local/remote/path', file, {})
112
126
 
113
127
  subject.upload(path, '/remote/path')
114
128
  end
@@ -116,8 +130,9 @@ module Artifactory
116
130
 
117
131
  context 'when matrix properties are given' do
118
132
  it 'converts the hash into matrix properties' do
119
- file = double(:file, is_a?: true)
120
- expect(client).to receive(:put).with('libs-release-local;branch=master;user=Seth%20Vargo/remote/path', { file: file }, {})
133
+ file = double(file)
134
+ File.stub(:new).and_return(file)
135
+ expect(client).to receive(:put).with('libs-release-local;branch=master;user=Seth%20Vargo/remote/path', file, {})
121
136
 
122
137
  subject.upload(file, '/remote/path',
123
138
  branch: 'master',
@@ -129,46 +144,15 @@ module Artifactory
129
144
  context 'when custom headers are given' do
130
145
  it 'passes the headers to the client' do
131
146
  headers = { 'Content-Type' => 'text/plain' }
132
- file = double(:file, is_a?: true)
133
- expect(client).to receive(:put).with('libs-release-local/remote/path', { file: file }, headers)
147
+ file = double(file)
148
+ File.stub(:new).and_return(file)
149
+ expect(client).to receive(:put).with('libs-release-local/remote/path', file, headers)
134
150
 
135
151
  subject.upload(file, '/remote/path', {}, headers)
136
152
  end
137
153
  end
138
154
  end
139
155
 
140
- describe '#upload_with_checksum' do
141
- it 'delegates to #upload' do
142
- expect(subject).to receive(:upload).with(
143
- '/local/file',
144
- '/remote/path',
145
- { branch: 'master' },
146
- {
147
- 'X-Checksum-Deploy' => true,
148
- 'X-Checksum-Sha1' => 'ABCD1234',
149
- },
150
- )
151
- subject.upload_with_checksum('/local/file', '/remote/path',
152
- 'ABCD1234',
153
- { branch: 'master' },
154
- )
155
- end
156
- end
157
-
158
- describe '#upload_from_archive' do
159
- it 'delegates to #upload' do
160
- expect(subject).to receive(:upload).with(
161
- '/local/file',
162
- '/remote/path',
163
- {},
164
- {
165
- 'X-Explode-Archive' => true,
166
- },
167
- )
168
- subject.upload_from_archive('/local/file', '/remote/path')
169
- end
170
- end
171
-
172
156
  describe '#artifacts' do
173
157
  before { subject.key = 'libs-release-local' }
174
158
 
@@ -38,7 +38,8 @@ module Artifactory
38
38
 
39
39
  context 'when the system is not running' do
40
40
  it 'returns false' do
41
- client.stub(:get).and_raise(Error::ConnectionError)
41
+ client.stub(:get)
42
+ .and_raise(Error::ConnectionError.new(Artifactory.endpoint))
42
43
  expect(described_class.ping).to be_false
43
44
  end
44
45
  end
@@ -63,7 +64,8 @@ module Artifactory
63
64
  before { client.stub(:post).and_return(response) }
64
65
 
65
66
  it 'posts /api/system/configuration' do
66
- expect(client).to receive(:post).with('/api/system/configuration', xml).once
67
+ headers = { 'Content-Type' => 'application/xml' }
68
+ expect(client).to receive(:post).with('/api/system/configuration', xml, headers).once
67
69
  described_class.update_configuration(xml)
68
70
  end
69
71
 
@@ -65,7 +65,7 @@ module Artifactory
65
65
  }
66
66
  end
67
67
 
68
- it 'creates a new instnace' do
68
+ it 'creates a new instance' do
69
69
  instance = described_class.from_hash(hash)
70
70
  expect(instance.admin).to be_false
71
71
  expect(instance.email).to eq('admin@example.com')
metadata CHANGED
@@ -1,69 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artifactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.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-02-12 00:00:00.000000000 Z
11
+ date: 2014-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: httpclient
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '2.3'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '2.3'
27
- - !ruby/object:Gem::Dependency
28
- name: i18n
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: '0.5'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ~>
39
- - !ruby/object:Gem::Version
40
- version: '0.5'
41
13
  - !ruby/object:Gem::Dependency
42
14
  name: bundler
43
15
  requirement: !ruby/object:Gem::Requirement
44
16
  requirements:
45
- - - '>='
17
+ - - ">="
46
18
  - !ruby/object:Gem::Version
47
19
  version: '0'
48
20
  type: :development
49
21
  prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
52
- - - '>='
24
+ - - ">="
53
25
  - !ruby/object:Gem::Version
54
26
  version: '0'
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: rake
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
- - - '>='
31
+ - - ">="
60
32
  - !ruby/object:Gem::Version
61
33
  version: '0'
62
34
  type: :development
63
35
  prerelease: false
64
36
  version_requirements: !ruby/object:Gem::Requirement
65
37
  requirements:
66
- - - '>='
38
+ - - ">="
67
39
  - !ruby/object:Gem::Version
68
40
  version: '0'
69
41
  description: A Ruby client for Artifactory
@@ -72,8 +44,8 @@ executables: []
72
44
  extensions: []
73
45
  extra_rdoc_files: []
74
46
  files:
75
- - .gitignore
76
- - .travis.yml
47
+ - ".gitignore"
48
+ - ".travis.yml"
77
49
  - CHANGELOG.md
78
50
  - Gemfile
79
51
  - LICENSE
@@ -91,16 +63,17 @@ files:
91
63
  - lib/artifactory/resources/base.rb
92
64
  - lib/artifactory/resources/build.rb
93
65
  - lib/artifactory/resources/group.rb
66
+ - lib/artifactory/resources/layout.rb
94
67
  - lib/artifactory/resources/plugin.rb
95
68
  - lib/artifactory/resources/repository.rb
96
69
  - lib/artifactory/resources/system.rb
97
70
  - lib/artifactory/resources/user.rb
98
71
  - lib/artifactory/util.rb
99
72
  - lib/artifactory/version.rb
100
- - locales/en.yml
101
73
  - spec/integration/resources/artifact_spec.rb
102
74
  - spec/integration/resources/build_spec.rb
103
75
  - spec/integration/resources/group_spec.rb
76
+ - spec/integration/resources/layout_spec.rb
104
77
  - spec/integration/resources/repository_spec.rb
105
78
  - spec/integration/resources/system_spec.rb
106
79
  - spec/integration/resources/user_spec.rb
@@ -119,6 +92,7 @@ files:
119
92
  - spec/unit/resources/base_spec.rb
120
93
  - spec/unit/resources/build_spec.rb
121
94
  - spec/unit/resources/group_spec.rb
95
+ - spec/unit/resources/layout_spec.rb
122
96
  - spec/unit/resources/plugin_spec.rb
123
97
  - spec/unit/resources/repository_spec.rb
124
98
  - spec/unit/resources/system_spec.rb
@@ -133,17 +107,17 @@ require_paths:
133
107
  - lib
134
108
  required_ruby_version: !ruby/object:Gem::Requirement
135
109
  requirements:
136
- - - '>='
110
+ - - ">="
137
111
  - !ruby/object:Gem::Version
138
112
  version: '0'
139
113
  required_rubygems_version: !ruby/object:Gem::Requirement
140
114
  requirements:
141
- - - '>='
115
+ - - ">="
142
116
  - !ruby/object:Gem::Version
143
117
  version: '0'
144
118
  requirements: []
145
119
  rubyforge_project:
146
- rubygems_version: 2.2.1
120
+ rubygems_version: 2.2.2
147
121
  signing_key:
148
122
  specification_version: 4
149
123
  summary: Artifactory is a simple, lightweight Ruby client for interacting with the
@@ -152,6 +126,7 @@ test_files:
152
126
  - spec/integration/resources/artifact_spec.rb
153
127
  - spec/integration/resources/build_spec.rb
154
128
  - spec/integration/resources/group_spec.rb
129
+ - spec/integration/resources/layout_spec.rb
155
130
  - spec/integration/resources/repository_spec.rb
156
131
  - spec/integration/resources/system_spec.rb
157
132
  - spec/integration/resources/user_spec.rb
@@ -170,6 +145,7 @@ test_files:
170
145
  - spec/unit/resources/base_spec.rb
171
146
  - spec/unit/resources/build_spec.rb
172
147
  - spec/unit/resources/group_spec.rb
148
+ - spec/unit/resources/layout_spec.rb
173
149
  - spec/unit/resources/plugin_spec.rb
174
150
  - spec/unit/resources/repository_spec.rb
175
151
  - spec/unit/resources/system_spec.rb
@@ -1,27 +0,0 @@
1
- en:
2
- artifactory:
3
- errors:
4
- bad_request: >
5
- The Artifactory server declined to server the URL `%{url}'. Here is
6
- more information from the server:
7
-
8
- %{body}
9
- connection_error: >
10
- The Artifactory server at `%{url}' threw an unexpected error. We do not
11
- have any additional information to offer, sorry. Here is what the server
12
- said:
13
-
14
- %{body}
15
- forbidden: >
16
- You are not permitted to access `%{url}'. The Artifactory server
17
- responded with a 403 Forbidden error.
18
- method_not_allowed: >
19
- That HTTP method is not allowed!
20
- not_found: >
21
- The requested URL `%{url}' does not exist on the Artifactory server.
22
- Please confirm you have spelled everything correctly.
23
- unauthorized: >
24
- You are not authorized to access `%{url}'. The Artifactory server
25
- responded with a 401 Unauthorzed. The requested endpoint requires
26
- authentication - try adding basic authentication to your request and
27
- try again.