artifactory 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 562e2e027e6ca103ce6c1570126b43087a7dcd62
4
- data.tar.gz: 37774d16b6e2ac098b1219af3cac95d248d12873
3
+ metadata.gz: cebccbe5005de8daa87ddb5c2cff9e7fd3a47d28
4
+ data.tar.gz: 8a616316ec8cbcf35a53fb49646273fad0e8ac09
5
5
  SHA512:
6
- metadata.gz: 65431df8d3d1e2442ba29013bdcb58b2b49c80bb1baef033b25e6382084e9206d178ae018c615ae38a04296a0dbac661fd544708a354fabd02ebbaac4810e323
7
- data.tar.gz: a53dc84bbc5a61acf178fa25fe14e8efe577141e5971f237b8aced47932b3fad0a654c078f849e2a1d8bf84c6f8e28c6d154086968dec7390dc5a2acee45b197
6
+ metadata.gz: 3e66007bc0e0c3a17bf27df588bd10ef21b7f60b39581c464254723f57d18d44d6299cd52deacf8a735b59fdf1e5d9d136799b57d00ae41fca11cc215c28b049
7
+ data.tar.gz: dac023ee6fea73f52003e52840b018996ad77b0fe425522bd03457798e2558b94599ae6376a36ffe7dd67886821f458306e0543e2e9230ce690f98ed33e1a4bf
@@ -3,6 +3,10 @@ Artifactory Client CHANGELOG
3
3
  This file is used to document the changes between releases of the Artifactory
4
4
  Ruby client.
5
5
 
6
+ v2.1.2 (08-26-2014)
7
+ -------------------
8
+ - Use the proper REST verbs on various resources to prevent a bug
9
+
6
10
  v2.1.1 (08-25-2014)
7
11
  -------------------
8
12
  - Use the proper name for POM consistency checks
@@ -70,12 +70,17 @@ module Artifactory
70
70
  end
71
71
 
72
72
  #
73
- # Save the group to the artifactory server.
73
+ # Creates or updates a group configuration depending on if the
74
+ # group configuration previously existed.
74
75
  #
75
76
  # @return [Boolean]
76
77
  #
77
78
  def save
78
- client.put(api_path, to_json, headers)
79
+ if self.class.find(name, client: client)
80
+ client.post(api_path, to_json, headers)
81
+ else
82
+ client.put(api_path, to_json, headers)
83
+ end
79
84
  true
80
85
  end
81
86
 
@@ -65,8 +65,22 @@ module Artifactory
65
65
  attribute :snapshot_version_behavior, 'non-unique'
66
66
  attribute :suppress_pom_consistency_checks, false
67
67
 
68
+ #
69
+ # Creates or updates a repository configuration depending on if the
70
+ # repository configuration previously existed. This method also works
71
+ # around Artifactory's dangerous default behavior:
72
+ #
73
+ # > An existing repository with the same key are removed from the
74
+ # > configuration and its content is removed!
75
+ #
76
+ # @return [Boolean]
77
+ #
68
78
  def save
69
- client.put(api_path, to_json, headers)
79
+ if self.class.find(key, client: client)
80
+ client.post(api_path, to_json, headers)
81
+ else
82
+ client.put(api_path, to_json, headers)
83
+ end
70
84
  true
71
85
  end
72
86
 
@@ -74,12 +74,17 @@ module Artifactory
74
74
  end
75
75
 
76
76
  #
77
- # Save the user to the artifactory server.
77
+ # Creates or updates a user configuration depending on if the
78
+ # user configuration previously existed.
78
79
  #
79
80
  # @return [Boolean]
80
81
  #
81
82
  def save
82
- client.put(api_path, to_json, headers)
83
+ if self.class.find(name, client: client)
84
+ client.post(api_path, to_json, headers)
85
+ else
86
+ client.put(api_path, to_json, headers)
87
+ end
83
88
  true
84
89
  end
85
90
 
@@ -1,3 +1,3 @@
1
1
  module Artifactory
2
- VERSION = '2.1.1'
2
+ VERSION = '2.1.2'
3
3
  end
@@ -71,6 +71,11 @@ module Artifactory
71
71
  })
72
72
  end
73
73
 
74
+ # Simulate a non-existent repository
75
+ app.get('/api/repositories/libs-testing-local') do
76
+ status 400
77
+ end
78
+
74
79
  app.put('/api/repositories/libs-testing-local') do
75
80
  content_type 'text/plain'
76
81
  "Repository libs-resting-local created successfully!\n"
@@ -71,5 +71,35 @@ module Artifactory
71
71
  expect(instance.realm_attributes).to be_nil
72
72
  end
73
73
  end
74
+
75
+ describe '#save' do
76
+ let(:client) { double }
77
+ before do
78
+ subject.client = client
79
+ subject.name = 'deployers'
80
+ end
81
+
82
+ context 'when the group is new' do
83
+ before do
84
+ allow(described_class).to receive(:find).with(subject.name, client: client).and_return(nil)
85
+ end
86
+
87
+ it 'PUTS the group to the server' do
88
+ expect(client).to receive(:put).with("/api/security/groups/#{subject.name}", kind_of(String), kind_of(Hash))
89
+ subject.save
90
+ end
91
+ end
92
+
93
+ context 'when the group exists' do
94
+ before do
95
+ allow(described_class).to receive(:find).with(subject.name, client: client).and_return({name: subject.name})
96
+ end
97
+
98
+ it 'POSTS the group to the server' do
99
+ expect(client).to receive(:post).with("/api/security/groups/#{subject.name}", kind_of(String), kind_of(Hash))
100
+ subject.save
101
+ end
102
+ end
103
+ end
74
104
  end
75
105
  end
@@ -94,9 +94,26 @@ module Artifactory
94
94
  subject.key = 'libs-release-local'
95
95
  end
96
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
97
+ context 'when the repository is new' do
98
+ before do
99
+ allow(described_class).to receive(:find).with(subject.key, client: client).and_return(nil)
100
+ end
101
+
102
+ it 'PUTS the file to the server' do
103
+ expect(client).to receive(:put).with("/api/repositories/#{subject.key}", kind_of(String), kind_of(Hash))
104
+ subject.save
105
+ end
106
+ end
107
+
108
+ context 'when the repository exists' do
109
+ before do
110
+ allow(described_class).to receive(:find).with(subject.key, client: client).and_return({key: subject.key})
111
+ end
112
+
113
+ it 'POSTS the file to the server' do
114
+ expect(client).to receive(:post).with("/api/repositories/#{subject.key}", kind_of(String), kind_of(Hash))
115
+ subject.save
116
+ end
100
117
  end
101
118
  end
102
119
 
@@ -78,5 +78,35 @@ module Artifactory
78
78
  expect(instance.realm).to eq('artifactory')
79
79
  end
80
80
  end
81
+
82
+ describe '#save' do
83
+ let(:client) { double }
84
+ before do
85
+ subject.client = client
86
+ subject.name = 'schisamo'
87
+ end
88
+
89
+ context 'when the user is new' do
90
+ before do
91
+ allow(described_class).to receive(:find).with(subject.name, client: client).and_return(nil)
92
+ end
93
+
94
+ it 'PUTS the user to the server' do
95
+ expect(client).to receive(:put).with("/api/security/users/#{subject.name}", kind_of(String), kind_of(Hash))
96
+ subject.save
97
+ end
98
+ end
99
+
100
+ context 'when the user exists' do
101
+ before do
102
+ allow(described_class).to receive(:find).with(subject.name, client: client).and_return({name: subject.name})
103
+ end
104
+
105
+ it 'POSTS the user to the server' do
106
+ expect(client).to receive(:post).with("/api/security/users/#{subject.name}", kind_of(String), kind_of(Hash))
107
+ subject.save
108
+ end
109
+ end
110
+ end
81
111
  end
82
112
  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: 2.1.1
4
+ version: 2.1.2
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-08-25 00:00:00.000000000 Z
11
+ date: 2014-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler