crx_packmgr_api_client 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -16
- data/crx_packmgr_api_client-0.2.0.gem +0 -0
- data/crx_packmgr_api_client.gemspec +9 -4
- data/docs/DefaultApi.md +457 -7
- data/docs/{PackageFilter.md → Filter.md} +2 -2
- data/docs/FilterRule.md +9 -0
- data/docs/Group.md +11 -0
- data/docs/{InlineResponse200.md → GroupList.md} +2 -2
- data/docs/InitData.md +13 -0
- data/docs/InstallStatus.md +8 -0
- data/docs/InstallStatusStatus.md +9 -0
- data/docs/Package.md +1 -1
- data/docs/PackageList.md +1 -0
- data/docs/ServiceResponse.md +12 -0
- data/docs/ServiceResponseRequest.md +8 -0
- data/docs/ServiceResponseRequestParam.md +9 -0
- data/docs/ServiceResponseResponse.md +9 -0
- data/docs/UpdateStatus.md +10 -0
- data/git_push.sh +1 -1
- data/lib/crx_packmgr_api_client.rb +13 -2
- data/lib/crx_packmgr_api_client/api/default_api.rb +491 -8
- data/lib/crx_packmgr_api_client/api_client.rb +1 -1
- data/lib/crx_packmgr_api_client/api_error.rb +1 -1
- data/lib/crx_packmgr_api_client/configuration.rb +1 -1
- data/lib/crx_packmgr_api_client/models/{package_filter.rb → filter.rb} +3 -3
- data/lib/crx_packmgr_api_client/models/filter_rule.rb +241 -0
- data/lib/crx_packmgr_api_client/models/group.rb +226 -0
- data/lib/crx_packmgr_api_client/models/{inline_response_200.rb → group_list.rb} +10 -10
- data/lib/crx_packmgr_api_client/models/init_data.rb +246 -0
- data/lib/crx_packmgr_api_client/models/install_status.rb +199 -0
- data/lib/crx_packmgr_api_client/models/install_status_status.rb +208 -0
- data/lib/crx_packmgr_api_client/models/package.rb +2 -2
- data/lib/crx_packmgr_api_client/models/package_list.rb +14 -5
- data/lib/crx_packmgr_api_client/models/service_response.rb +235 -0
- data/lib/crx_packmgr_api_client/models/service_response_request.rb +201 -0
- data/lib/crx_packmgr_api_client/models/service_response_request_param.rb +208 -0
- data/lib/crx_packmgr_api_client/models/service_response_response.rb +208 -0
- data/lib/crx_packmgr_api_client/models/update_status.rb +217 -0
- data/lib/crx_packmgr_api_client/version.rb +2 -2
- data/spec/acceptance/default_api_spec.rb +150 -0
- data/spec/api/default_api_spec.rb +2 -14
- data/spec/api/download_api_spec.rb +95 -0
- data/spec/api/groups_api_spec.rb +193 -0
- data/spec/api/init_api_spec.rb +104 -0
- data/spec/api/installstatus_api_spec.rb +91 -0
- data/spec/api/list_api_spec.rb +130 -0
- data/spec/api/screenshot_api_spec.rb +93 -0
- data/spec/api/service_api_spec.rb +374 -0
- data/spec/api/thumbnail_api_spec.rb +93 -0
- data/spec/api_client_spec.rb +1 -1
- data/spec/configuration_spec.rb +1 -1
- data/spec/files/list.json +533 -0
- data/spec/files/service_response.txt +11 -0
- data/spec/files/service_response1.txt +12 -0
- data/spec/files/test-1.0.0.zip +0 -0
- data/spec/files/thumbnail.png +0 -0
- data/spec/models/filter_rule_spec.rb +63 -0
- data/spec/models/{package_filter_spec.rb → filter_spec.rb} +7 -7
- data/spec/models/{inline_response_200_spec.rb → group_list_spec.rb} +8 -8
- data/spec/models/group_spec.rb +71 -0
- data/spec/models/init_data_spec.rb +83 -0
- data/spec/models/install_status_spec.rb +53 -0
- data/spec/models/install_status_status_spec.rb +59 -0
- data/spec/models/package_list_spec.rb +1 -1
- data/spec/models/package_spec.rb +1 -1
- data/spec/models/service_response_request_param_spec.rb +59 -0
- data/spec/models/service_response_request_spec.rb +53 -0
- data/spec/models/service_response_response_spec.rb +59 -0
- data/spec/models/service_response_spec.rb +77 -0
- data/spec/models/update_status_spec.rb +65 -0
- data/spec/spec_helper.rb +10 -1
- data/spec/spec_helper_acceptance.rb +19 -0
- metadata +130 -17
@@ -0,0 +1,217 @@
|
|
1
|
+
=begin
|
2
|
+
#CRX Package Manager API
|
3
|
+
|
4
|
+
#API for interacting with the CRX Package Manager in AEM.
|
5
|
+
|
6
|
+
OpenAPI spec version: 6.2.0
|
7
|
+
Contact: bryan.stopp@gmail.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
+
you may not use this file except in compliance with the License.
|
12
|
+
You may obtain a copy of the License at
|
13
|
+
|
14
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
|
16
|
+
Unless required by applicable law or agreed to in writing, software
|
17
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
+
See the License for the specific language governing permissions and
|
20
|
+
limitations under the License.
|
21
|
+
|
22
|
+
=end
|
23
|
+
|
24
|
+
require 'date'
|
25
|
+
|
26
|
+
module CrxPackageManager
|
27
|
+
|
28
|
+
class UpdateStatus
|
29
|
+
attr_accessor :success
|
30
|
+
|
31
|
+
attr_accessor :msg
|
32
|
+
|
33
|
+
attr_accessor :path
|
34
|
+
|
35
|
+
|
36
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
37
|
+
def self.attribute_map
|
38
|
+
{
|
39
|
+
:'success' => :'success',
|
40
|
+
:'msg' => :'msg',
|
41
|
+
:'path' => :'path'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# Attribute type mapping.
|
46
|
+
def self.swagger_types
|
47
|
+
{
|
48
|
+
:'success' => :'BOOLEAN',
|
49
|
+
:'msg' => :'String',
|
50
|
+
:'path' => :'String'
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
# Initializes the object
|
55
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
56
|
+
def initialize(attributes = {})
|
57
|
+
return unless attributes.is_a?(Hash)
|
58
|
+
|
59
|
+
# convert string to symbol for hash key
|
60
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
61
|
+
|
62
|
+
if attributes.has_key?(:'success')
|
63
|
+
self.success = attributes[:'success']
|
64
|
+
end
|
65
|
+
|
66
|
+
if attributes.has_key?(:'msg')
|
67
|
+
self.msg = attributes[:'msg']
|
68
|
+
end
|
69
|
+
|
70
|
+
if attributes.has_key?(:'path')
|
71
|
+
self.path = attributes[:'path']
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
77
|
+
# @return Array for valid properies with the reasons
|
78
|
+
def list_invalid_properties
|
79
|
+
invalid_properties = Array.new
|
80
|
+
return invalid_properties
|
81
|
+
end
|
82
|
+
|
83
|
+
# Check to see if the all the properties in the model are valid
|
84
|
+
# @return true if the model is valid
|
85
|
+
def valid?
|
86
|
+
return true
|
87
|
+
end
|
88
|
+
|
89
|
+
# Checks equality by comparing each attribute.
|
90
|
+
# @param [Object] Object to be compared
|
91
|
+
def ==(o)
|
92
|
+
return true if self.equal?(o)
|
93
|
+
self.class == o.class &&
|
94
|
+
success == o.success &&
|
95
|
+
msg == o.msg &&
|
96
|
+
path == o.path
|
97
|
+
end
|
98
|
+
|
99
|
+
# @see the `==` method
|
100
|
+
# @param [Object] Object to be compared
|
101
|
+
def eql?(o)
|
102
|
+
self == o
|
103
|
+
end
|
104
|
+
|
105
|
+
# Calculates hash code according to all attributes.
|
106
|
+
# @return [Fixnum] Hash code
|
107
|
+
def hash
|
108
|
+
[success, msg, path].hash
|
109
|
+
end
|
110
|
+
|
111
|
+
# Builds the object from hash
|
112
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
113
|
+
# @return [Object] Returns the model itself
|
114
|
+
def build_from_hash(attributes)
|
115
|
+
return nil unless attributes.is_a?(Hash)
|
116
|
+
self.class.swagger_types.each_pair do |key, type|
|
117
|
+
if type =~ /^Array<(.*)>/i
|
118
|
+
# check to ensure the input is an array given that the the attribute
|
119
|
+
# is documented as an array but the input is not
|
120
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
121
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
122
|
+
end
|
123
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
124
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
125
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
126
|
+
end
|
127
|
+
|
128
|
+
self
|
129
|
+
end
|
130
|
+
|
131
|
+
# Deserializes the data based on type
|
132
|
+
# @param string type Data type
|
133
|
+
# @param string value Value to be deserialized
|
134
|
+
# @return [Object] Deserialized data
|
135
|
+
def _deserialize(type, value)
|
136
|
+
case type.to_sym
|
137
|
+
when :DateTime
|
138
|
+
DateTime.parse(value)
|
139
|
+
when :Date
|
140
|
+
Date.parse(value)
|
141
|
+
when :String
|
142
|
+
value.to_s
|
143
|
+
when :Integer
|
144
|
+
value.to_i
|
145
|
+
when :Float
|
146
|
+
value.to_f
|
147
|
+
when :BOOLEAN
|
148
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
149
|
+
true
|
150
|
+
else
|
151
|
+
false
|
152
|
+
end
|
153
|
+
when :Object
|
154
|
+
# generic object (usually a Hash), return directly
|
155
|
+
value
|
156
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
157
|
+
inner_type = Regexp.last_match[:inner_type]
|
158
|
+
value.map { |v| _deserialize(inner_type, v) }
|
159
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
160
|
+
k_type = Regexp.last_match[:k_type]
|
161
|
+
v_type = Regexp.last_match[:v_type]
|
162
|
+
{}.tap do |hash|
|
163
|
+
value.each do |k, v|
|
164
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
else # model
|
168
|
+
temp_model = CrxPackageManager.const_get(type).new
|
169
|
+
temp_model.build_from_hash(value)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
# Returns the string representation of the object
|
174
|
+
# @return [String] String presentation of the object
|
175
|
+
def to_s
|
176
|
+
to_hash.to_s
|
177
|
+
end
|
178
|
+
|
179
|
+
# to_body is an alias to to_hash (backward compatibility)
|
180
|
+
# @return [Hash] Returns the object in the form of hash
|
181
|
+
def to_body
|
182
|
+
to_hash
|
183
|
+
end
|
184
|
+
|
185
|
+
# Returns the object in the form of hash
|
186
|
+
# @return [Hash] Returns the object in the form of hash
|
187
|
+
def to_hash
|
188
|
+
hash = {}
|
189
|
+
self.class.attribute_map.each_pair do |attr, param|
|
190
|
+
value = self.send(attr)
|
191
|
+
next if value.nil?
|
192
|
+
hash[param] = _to_hash(value)
|
193
|
+
end
|
194
|
+
hash
|
195
|
+
end
|
196
|
+
|
197
|
+
# Outputs non-array value in the form of hash
|
198
|
+
# For object, use to_hash. Otherwise, just return the value
|
199
|
+
# @param [Object] value Any valid value
|
200
|
+
# @return [Hash] Returns the value in the form of hash
|
201
|
+
def _to_hash(value)
|
202
|
+
if value.is_a?(Array)
|
203
|
+
value.compact.map{ |v| _to_hash(v) }
|
204
|
+
elsif value.is_a?(Hash)
|
205
|
+
{}.tap do |hash|
|
206
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
207
|
+
end
|
208
|
+
elsif value.respond_to? :to_hash
|
209
|
+
value.to_hash
|
210
|
+
else
|
211
|
+
value
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
#API for interacting with the CRX Package Manager in AEM.
|
5
5
|
|
6
|
-
OpenAPI spec version:
|
6
|
+
OpenAPI spec version: 6.2.0
|
7
7
|
Contact: bryan.stopp@gmail.com
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
9
|
|
@@ -22,5 +22,5 @@ limitations under the License.
|
|
22
22
|
=end
|
23
23
|
|
24
24
|
module CrxPackageManager
|
25
|
-
VERSION = "
|
25
|
+
VERSION = "1.0.0"
|
26
26
|
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'spec_helper_acceptance'
|
2
|
+
require 'xmlsimple'
|
3
|
+
|
4
|
+
describe 'DefaultApi' do
|
5
|
+
before do
|
6
|
+
# run before each test
|
7
|
+
config = CrxPackageManager::Configuration.new
|
8
|
+
config.username = 'admin'
|
9
|
+
config.password = 'admin'
|
10
|
+
@instance = CrxPackageManager::DefaultApi.new(CrxPackageManager::ApiClient.new(config))
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
# run after each test
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:package) do
|
18
|
+
file = File.new(File.join(File.dirname(__FILE__), '..', 'files', 'test-1.0.0.zip'))
|
19
|
+
file
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:path) do
|
23
|
+
'/etc/packages/my_packages/test-1.0.0.zip'
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'init' do
|
27
|
+
it 'should work' do
|
28
|
+
data = @instance.init
|
29
|
+
expect(data).to be_a(CrxPackageManager::InitData)
|
30
|
+
expect(data.context_path).to eq('/crx')
|
31
|
+
expect(data.launchpad_context_path).to eq('/')
|
32
|
+
expect(data.jcr_version).to eq('2.0')
|
33
|
+
expect(data.workspace).to eq('crx.default')
|
34
|
+
expect(data.user_id).to eq('Administrator')
|
35
|
+
expect(data.workspaces).to eq(['crx.default'])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'installstatus' do
|
40
|
+
it 'should work' do
|
41
|
+
data = @instance.installstatus
|
42
|
+
expect(data).to be_a(CrxPackageManager::InstallStatus)
|
43
|
+
expect(data.status.finished).to eq(true)
|
44
|
+
expect(data.status.item_count).to eq(0)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
context 'service upload and update' do
|
50
|
+
it 'should support cmd=help' do
|
51
|
+
xml = @instance.service_get('help')
|
52
|
+
parsed = XmlSimple.xml_in(xml, { ForceArray: %r(param), KeyToSymbol: true, AttrToSymbol: true } )
|
53
|
+
sr = CrxPackageManager::ServiceResponse.new
|
54
|
+
sr = sr.build_from_hash(parsed)
|
55
|
+
expect(sr.version).to eq('1.4.1')
|
56
|
+
expect(sr.user).to eq('admin')
|
57
|
+
expect(sr.workspace).to eq('crx.default')
|
58
|
+
expect(sr.request).not_to be_nil
|
59
|
+
req = sr.request
|
60
|
+
params = req.param
|
61
|
+
expect(params).to be_a(Array)
|
62
|
+
expect(params.length).to eq(1)
|
63
|
+
expect(params[0].name).to eq('cmd')
|
64
|
+
response = sr.response
|
65
|
+
expect(response.status[:code].to_i).to eq(200)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should support post' do
|
69
|
+
xml = @instance.service_post(package)
|
70
|
+
parsed = XmlSimple.xml_in(xml, { ForceArray: %r(param), KeyToSymbol: true, AttrToSymbol: true } )
|
71
|
+
sr = CrxPackageManager::ServiceResponse.new
|
72
|
+
sr = sr.build_from_hash(parsed)
|
73
|
+
response = sr.response
|
74
|
+
expect(response.status[:code].to_i).to eq(200)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should support install' do
|
78
|
+
xml = @instance.service_get('inst', name: 'test')
|
79
|
+
parsed = XmlSimple.xml_in(xml, { ForceArray: %r(param), KeyToSymbol: true, AttrToSymbol: true } )
|
80
|
+
sr = CrxPackageManager::ServiceResponse.new
|
81
|
+
sr = sr.build_from_hash(parsed)
|
82
|
+
response = sr.response
|
83
|
+
expect(response.status[:code].to_i).to eq(200)
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'list' do
|
89
|
+
it 'should work' do
|
90
|
+
data = @instance.list(q: 'test')
|
91
|
+
expect(data).to be_a(CrxPackageManager::PackageList)
|
92
|
+
expect(data.total).to eq(1)
|
93
|
+
expect(data.results).not_to be_nil
|
94
|
+
entry = data.results[0]
|
95
|
+
expect(entry).to be_a(CrxPackageManager::Package)
|
96
|
+
expect(entry.pid).to eq('my_packages:test:1.0.0')
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'groups' do
|
101
|
+
it 'should work' do
|
102
|
+
data = @instance.groups(only_top_level: true)
|
103
|
+
expect(data).to be_a(CrxPackageManager::GroupList)
|
104
|
+
expect(data.groups).not_to be_nil
|
105
|
+
data.groups.each do |grp|
|
106
|
+
next if grp.name != 'my_packages'
|
107
|
+
expect(grp.title).to eq('my_packages')
|
108
|
+
expect(grp.count).to eq(1)
|
109
|
+
expect(grp.deep_count).to eq(1)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'thumbnail' do
|
115
|
+
it 'should work' do
|
116
|
+
data = @instance.thumbnail(path: path)
|
117
|
+
expect(data).to be_a(Tempfile)
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'download' do
|
123
|
+
it 'should work' do
|
124
|
+
data = @instance.download(path: '/etc/packages/my_packages/test-1.0.0.zip')
|
125
|
+
expect(data).to be_a(Tempfile)
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'service uninstall and remove' do
|
131
|
+
it 'should support uninstall' do
|
132
|
+
xml = @instance.service_get('uninst', name: 'test')
|
133
|
+
parsed = XmlSimple.xml_in(xml, { ForceArray: %r(param), KeyToSymbol: true, AttrToSymbol: true } )
|
134
|
+
sr = CrxPackageManager::ServiceResponse.new
|
135
|
+
sr = sr.build_from_hash(parsed)
|
136
|
+
response = sr.response
|
137
|
+
expect(response.status[:code].to_i).to eq(200)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should support rm' do
|
141
|
+
xml = @instance.service_get('rm', name: 'test')
|
142
|
+
parsed = XmlSimple.xml_in(xml, { ForceArray: %r(param), KeyToSymbol: true, AttrToSymbol: true } )
|
143
|
+
sr = CrxPackageManager::ServiceResponse.new
|
144
|
+
sr = sr.build_from_hash(parsed)
|
145
|
+
response = sr.response
|
146
|
+
expect(response.status[:code].to_i).to eq(200)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
#API for interacting with the CRX Package Manager in AEM.
|
5
5
|
|
6
|
-
OpenAPI spec version:
|
6
|
+
OpenAPI spec version: 6.2.0
|
7
7
|
Contact: bryan.stopp@gmail.com
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
9
|
|
@@ -38,20 +38,8 @@ describe 'DefaultApi' do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe 'test an instance of DefaultApi' do
|
41
|
-
it 'should create an
|
41
|
+
it 'should create an intact of DefaultApi' do
|
42
42
|
expect(@instance).to be_instance_of(CrxPackageManager::DefaultApi)
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
46
|
-
# unit tests for list
|
47
|
-
# List all available packages.
|
48
|
-
# Returns a list of all available packages defined.
|
49
|
-
# @param [Hash] opts the optional parameters
|
50
|
-
# @return [InlineResponse200]
|
51
|
-
describe 'list test' do
|
52
|
-
it "should work" do
|
53
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
45
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# unit tests for download
|
4
|
+
# Download a package
|
5
|
+
# Downloads the package at the specified path. Returns a Tempfile object.
|
6
|
+
# @param [Hash] opts the optional parameters
|
7
|
+
# @option opts [String] :path The path to the package to download.
|
8
|
+
# @return [File]
|
9
|
+
describe 'DefaultApi#download' do
|
10
|
+
before do
|
11
|
+
config = CrxPackageManager::Configuration.new
|
12
|
+
@instance = CrxPackageManager::DefaultApi.new(CrxPackageManager::ApiClient.new(config))
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:dl) do
|
16
|
+
file = File.new(File.join(File.dirname(__FILE__), '..', 'files', 'test-1.0.0.zip'))
|
17
|
+
file
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should work' do
|
21
|
+
WebMock.reset!
|
22
|
+
path = '/etc/packages/my_packages/test-1.0.0.zip'
|
23
|
+
cfg = @instance.api_client.config
|
24
|
+
get_stub = stub_request(
|
25
|
+
:get, "#{cfg.scheme}://#{cfg.host}#{cfg.base_path}/download.jsp"
|
26
|
+
).with(
|
27
|
+
query: { path: path }
|
28
|
+
).to_return(status: 200, body: dl, headers: { 'Content-Type' => 'application/octet-stream' })
|
29
|
+
|
30
|
+
data = @instance.download(path: path)
|
31
|
+
expect(data).to be_a(Tempfile)
|
32
|
+
expect(get_stub).to have_been_requested
|
33
|
+
data.delete
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should support config changes' do
|
37
|
+
WebMock.reset!
|
38
|
+
path = '/etc/packages/my_packages/test-1.0.0.zip'
|
39
|
+
@instance.api_client.config.configure do |c|
|
40
|
+
c.scheme = 'https'
|
41
|
+
c.host = 'notlocalhost'
|
42
|
+
c.base_path = '/contextroot/crx/packgr'
|
43
|
+
c.debugging = true
|
44
|
+
end
|
45
|
+
cfg = @instance.api_client.config
|
46
|
+
get_stub = stub_request(
|
47
|
+
:get, "#{cfg.scheme}://#{cfg.host}#{cfg.base_path}/download.jsp"
|
48
|
+
).with(
|
49
|
+
query: { path: path }
|
50
|
+
).to_return(status: 200, body: dl, headers: { 'Content-Type' => 'application/octet-stream' })
|
51
|
+
|
52
|
+
data = @instance.download(path: path)
|
53
|
+
expect(data).to be_a(Tempfile)
|
54
|
+
expect(get_stub).to have_been_requested
|
55
|
+
data.delete
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should support failures' do
|
60
|
+
WebMock.reset!
|
61
|
+
path = '/etc/packages/my_packages/test-1.0.0.zip'
|
62
|
+
cfg = @instance.api_client.config
|
63
|
+
get_stub = stub_request(
|
64
|
+
:get, "#{cfg.scheme}://#{cfg.host}#{cfg.base_path}/download.jsp"
|
65
|
+
).with(
|
66
|
+
query: { path: path }
|
67
|
+
).to_return(status: 404)
|
68
|
+
|
69
|
+
begin
|
70
|
+
@instance.download(path: path)
|
71
|
+
rescue CrxPackageManager::ApiError => e
|
72
|
+
expect(e).not_to be_nil
|
73
|
+
expect(e.code).to eq(404)
|
74
|
+
end
|
75
|
+
|
76
|
+
expect(get_stub).to have_been_requested
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should ignore other params' do
|
80
|
+
WebMock.reset!
|
81
|
+
path = '/etc/packages/my_packages/test-1.0.0.zip'
|
82
|
+
cfg = @instance.api_client.config
|
83
|
+
get_stub = stub_request(
|
84
|
+
:get, "#{cfg.scheme}://#{cfg.host}#{cfg.base_path}/download.jsp"
|
85
|
+
).with(
|
86
|
+
query: { path: path }
|
87
|
+
).to_return(status: 200, body: dl, headers: { 'Content-Type' => 'application/octet-stream' })
|
88
|
+
|
89
|
+
data = @instance.download(path: path, other_param: 'value')
|
90
|
+
expect(data).to be_a(Tempfile)
|
91
|
+
expect(get_stub).to have_been_requested
|
92
|
+
data.delete
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|