adyen-admin 0.0.7 → 0.0.8
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.
- data/CHANGES.md +3 -1
- data/README.md +8 -0
- data/VERSION +1 -1
- data/lib/adyen-admin/skin.rb +78 -28
- data/spec/adyen-admin/skin_spec.rb +121 -30
- data/spec/fixtures/cassettes/Adyen_Admin_Client/_get/raises_authenticated_error_when_not_logged_in.yml +9 -9
- data/spec/fixtures/cassettes/Adyen_Admin_Client/_login/passes_with_correct_username_password.yml +35 -47
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_all/freezes_local_skins.yml +4 -4
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_all/returns_the_skins.yml +4 -4
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_all_remote/returns_the_skins.yml +4 -4
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_all_remote/sets_local_path.yml +4 -4
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_decompile/new_remote_skin/downloads_and_decompiles_skin.yml +133 -58
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_download/gets_the_file.yml +65 -65
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_download/is_a_zipfile.yml +65 -65
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_find/returns_no_skin.yml +4 -4
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_find/returns_the_skin.yml +4 -4
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/{_version → _remote_version}/returns_live_value.yml +5 -5
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/{_version → _remote_version}/returns_test_value.yml +6 -6
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/{_version → _remote_version}/returns_uploaded_value.yml +7 -7
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_test_url/returns_url_to_test.yml +17 -17
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_update/create_skin_yml_file.yml +814 -0
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_upload/valid_set/increases_version.yml +907 -106
- data/spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_upload/valid_set/updates_skin_data.yml +6466 -0
- data/spec/fixtures/cassettes/login.yml +36 -48
- data/spec/fixtures/skins/DV3tf95f/skin.yml +6 -0
- metadata +28 -26
- data/spec/fixtures/skins/DV3tf95f/metadata.yml +0 -5
- data/spec/fixtures/skins/example-7hFAQnmt/metadata.yml +0 -5
data/CHANGES.md
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
## vx.x.x - ???
|
4
4
|
* update Docu
|
5
|
-
* parse metafile
|
6
5
|
* parent (instead of base)
|
7
6
|
* add CLI binaries (to compile + upload) -> read from .adyenrc file
|
8
7
|
* make compatible with Live system
|
9
8
|
|
9
|
+
## v0.0.8 - ???
|
10
|
+
* parse metafile
|
11
|
+
|
10
12
|
## v0.0.7
|
11
13
|
* fix download issue
|
12
14
|
* fix name with multiple - issue
|
data/README.md
CHANGED
@@ -29,6 +29,14 @@ zip_file = skin.download # get zip file
|
|
29
29
|
|
30
30
|
skin.decompile(zip_file) # unzip file and move to skin path, backup + overwrite existing files
|
31
31
|
|
32
|
+
zip_file = skin.compile # unzip file and move to skin path, backup + overwrite existing files
|
33
|
+
|
34
|
+
skin.upload(zip_file)
|
35
|
+
|
36
|
+
skin.update # to get latest version
|
37
|
+
|
38
|
+
skin.test_url # a URL which you can use to 'live' test you skin
|
39
|
+
|
32
40
|
```
|
33
41
|
|
34
42
|
### Skins
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/lib/adyen-admin/skin.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'tempfile'
|
2
2
|
require 'zip/zip'
|
3
|
+
require 'yaml'
|
3
4
|
|
4
5
|
module Adyen
|
5
6
|
module Admin
|
@@ -81,44 +82,56 @@ module Adyen
|
|
81
82
|
|
82
83
|
def path=(new_path)
|
83
84
|
if Skin.is_skin_path?(new_path)
|
84
|
-
new_code, *new_name = File.basename(new_path).split("-").reverse
|
85
|
-
self.code ||= new_code
|
86
|
-
self.name ||= new_name.reverse.join("-")
|
87
|
-
raise ArgumentError if self.code && self.code != new_code
|
88
85
|
@path = new_path
|
86
|
+
if !skin_data.empty?
|
87
|
+
self.code = skin_data["code"]
|
88
|
+
self.name = skin_data["name"]
|
89
|
+
else
|
90
|
+
new_code, *new_name = File.basename(new_path).split("-").reverse
|
91
|
+
self.code ||= new_code
|
92
|
+
self.name ||= new_name.reverse.join("-")
|
93
|
+
raise ArgumentError if self.code && self.code != new_code
|
94
|
+
end
|
89
95
|
end
|
90
96
|
end
|
91
97
|
|
92
|
-
|
98
|
+
def skin_data(force_update = false)
|
99
|
+
update if force_update
|
100
|
+
@skin_data ||= YAML.load_file(skin_data_file) rescue {}
|
101
|
+
end
|
93
102
|
|
94
|
-
def
|
95
|
-
|
96
|
-
when :test
|
97
|
-
page = Adyen::Admin.get(VERSION_TEST % code)
|
98
|
-
page.search("body p").first.content.scan(/Version:(\d+)/).flatten.first.to_i
|
99
|
-
when :live
|
100
|
-
page = Adyen::Admin.get(VERSION_LIVE % code)
|
101
|
-
page.search("body p").first.content.scan(/Version:(\d+)/).flatten.first.to_i
|
102
|
-
else
|
103
|
-
page = Adyen::Admin.get(TEST % code)
|
104
|
-
page.search(".data tr td")[2].content.to_i
|
105
|
-
end
|
103
|
+
def uploaded_at
|
104
|
+
skin_data["uploaded_at"]
|
106
105
|
end
|
107
106
|
|
108
|
-
def
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
107
|
+
def version
|
108
|
+
skin_data["version"]
|
109
|
+
end
|
110
|
+
|
111
|
+
def version_live
|
112
|
+
skin_data["version_live"]
|
113
|
+
end
|
114
|
+
|
115
|
+
def version_test
|
116
|
+
skin_data["version_test"]
|
118
117
|
end
|
119
118
|
|
120
119
|
##########################################
|
121
120
|
|
121
|
+
def update
|
122
|
+
@skin_data = {
|
123
|
+
:name => name,
|
124
|
+
:code => code,
|
125
|
+
:uploaded_at => Time.now,
|
126
|
+
:version => remote_version,
|
127
|
+
:version_live => remote_version(:live),
|
128
|
+
:version_test => remote_version(:test),
|
129
|
+
}
|
130
|
+
File.open(skin_data_file, "w") do |file|
|
131
|
+
file.write @skin_data.to_yaml
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
122
135
|
# http://stackoverflow.com/questions/4360043/using-wwwmechanize-to-download-a-file-to-disk-without-loading-it-all-in-memory
|
123
136
|
# Adyen::Admin.client.pluggable_parser.default = Mechanize::FileSaver
|
124
137
|
def download
|
@@ -195,6 +208,7 @@ module Adyen
|
|
195
208
|
end)
|
196
209
|
form = page.form
|
197
210
|
page = form.submit(page.form.button_with(:name => 'submit'))
|
211
|
+
update
|
198
212
|
end
|
199
213
|
|
200
214
|
def publish
|
@@ -205,6 +219,18 @@ module Adyen
|
|
205
219
|
|
206
220
|
#################################
|
207
221
|
|
222
|
+
def test_url(options = {})
|
223
|
+
page = Adyen::Admin.get(TEST % code)
|
224
|
+
page = Adyen::Admin.client.submit(page.form.tap do |form|
|
225
|
+
#:amount => 199, :currency => :shopper_locale, :country_code, :merchant_reference, :merchant_account, :system, :skip, :one_page
|
226
|
+
end)
|
227
|
+
Addressable::URI.parse(page.form.action).tap do |uri|
|
228
|
+
uri.query_values = page.form.fields.inject({}) { |hash, node|
|
229
|
+
hash[node.name] = node.value; hash
|
230
|
+
}
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
208
234
|
def to_s
|
209
235
|
self.code
|
210
236
|
end
|
@@ -222,12 +248,36 @@ module Adyen
|
|
222
248
|
@name = n
|
223
249
|
end
|
224
250
|
|
251
|
+
def skin_data_file
|
252
|
+
File.join(path, 'skin.yml')
|
253
|
+
end
|
254
|
+
|
225
255
|
def self.is_skin_path?(path)
|
226
|
-
%w(skin.html.erb inc css js).each do |sub_path|
|
256
|
+
%w(skin.html.erb skin.yml inc css js).each do |sub_path|
|
227
257
|
return true if File.exists?(File.join(path.to_s, sub_path))
|
228
258
|
end
|
229
259
|
false
|
230
260
|
end
|
261
|
+
|
262
|
+
##################################
|
263
|
+
|
264
|
+
def remote_version(scope = nil)
|
265
|
+
case scope
|
266
|
+
when :test
|
267
|
+
@version_local ||= begin
|
268
|
+
page = Adyen::Admin.get(VERSION_TEST % code)
|
269
|
+
page.search("body p").first.content.scan(/Version:(\d+)/).flatten.first.to_i
|
270
|
+
end
|
271
|
+
when :live
|
272
|
+
page = Adyen::Admin.get(VERSION_LIVE % code)
|
273
|
+
page.search("body p").first.content.scan(/Version:(\d+)/).flatten.first.to_i
|
274
|
+
else
|
275
|
+
page = Adyen::Admin.get(TEST % code)
|
276
|
+
page.search(".data tr td")[2].content.to_i
|
277
|
+
end
|
278
|
+
rescue
|
279
|
+
nil
|
280
|
+
end
|
231
281
|
end
|
232
282
|
end
|
233
283
|
end
|
@@ -118,6 +118,74 @@ module Adyen::Admin
|
|
118
118
|
Skin.new(:path => path).name.should == "example-test"
|
119
119
|
end
|
120
120
|
end
|
121
|
+
|
122
|
+
context "with skin data file" do
|
123
|
+
let(:path) { "#{skin_fixtures}/DV3tf95f" }
|
124
|
+
let(:skin) { Skin.new(:path => path) }
|
125
|
+
|
126
|
+
it "sets name" do
|
127
|
+
skin.name.should == "from-file"
|
128
|
+
end
|
129
|
+
|
130
|
+
it "sets code" do
|
131
|
+
skin.code.should == "customCode"
|
132
|
+
end
|
133
|
+
|
134
|
+
it "sets version" do
|
135
|
+
skin.version.should == 12
|
136
|
+
end
|
137
|
+
|
138
|
+
it "sets version_test" do
|
139
|
+
skin.version_test.should == 3
|
140
|
+
end
|
141
|
+
|
142
|
+
it "sets version_live" do
|
143
|
+
skin.version_live.should == 2
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "#update" do
|
149
|
+
let(:path) { "#{skin_fixtures}/example-7hFAQnmt" }
|
150
|
+
|
151
|
+
before do
|
152
|
+
skin.path = path
|
153
|
+
end
|
154
|
+
|
155
|
+
after do
|
156
|
+
`rm -f #{path}/skin.yml`
|
157
|
+
end
|
158
|
+
|
159
|
+
it "create skin.yml file" do
|
160
|
+
expect do
|
161
|
+
skin.update
|
162
|
+
end.to change { File.exists?("#{path}/skin.yml") }
|
163
|
+
end
|
164
|
+
|
165
|
+
context "local skin" do
|
166
|
+
it "returns version" do
|
167
|
+
skin.version.should be_nil
|
168
|
+
end
|
169
|
+
|
170
|
+
it "returns version" do
|
171
|
+
skin.version_live.should be_nil
|
172
|
+
end
|
173
|
+
|
174
|
+
it "returns version" do
|
175
|
+
skin.version_test.should be_nil
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
context "remote fails" do
|
180
|
+
before do
|
181
|
+
Adyen::Admin.stub(:get).and_raise(StandardError)
|
182
|
+
end
|
183
|
+
|
184
|
+
it "returns version" do
|
185
|
+
skin.update
|
186
|
+
skin.version.should be_nil
|
187
|
+
end
|
188
|
+
end
|
121
189
|
end
|
122
190
|
|
123
191
|
describe "#download" do
|
@@ -193,59 +261,70 @@ module Adyen::Admin
|
|
193
261
|
|
194
262
|
describe "#compile" do
|
195
263
|
let(:skin_code) { "DV3tf95f" }
|
196
|
-
let(:
|
264
|
+
let(:path) { "#{skin_fixtures}/#{skin_code}" }
|
265
|
+
let(:skin) { Skin.new(:path => path) }
|
197
266
|
let(:zip_filename) { skin.compile }
|
198
267
|
|
199
268
|
def zip_contains(file)
|
200
269
|
Zip::ZipFile.open(zip_filename) do |zipfile|
|
201
|
-
return true if zipfile.find_entry(File.join(
|
270
|
+
return true if zipfile.find_entry(File.join(skin.code, file))
|
202
271
|
end
|
203
272
|
false
|
204
273
|
end
|
205
274
|
|
206
275
|
after do
|
207
|
-
`rm -f #{
|
276
|
+
`rm -f #{skin.code}.zip`
|
208
277
|
end
|
209
278
|
|
210
|
-
context "
|
279
|
+
context "no skin.yml" do
|
211
280
|
before do
|
212
|
-
`mv #{
|
281
|
+
`mv #{path}/skin.yml #{path}/skin2.yml`
|
213
282
|
end
|
214
283
|
|
215
284
|
after do
|
216
|
-
`mv #{
|
285
|
+
`mv #{path}/skin2.yml #{path}/skin.yml`
|
286
|
+
end
|
287
|
+
|
288
|
+
context "without base" do
|
289
|
+
before do
|
290
|
+
`mv #{skin_fixtures}/base #{skin_fixtures}/base2`
|
291
|
+
end
|
292
|
+
|
293
|
+
after do
|
294
|
+
`mv #{skin_fixtures}/base2 #{skin_fixtures}/base`
|
295
|
+
end
|
296
|
+
|
297
|
+
it "includes screen file" do
|
298
|
+
zip_contains("css/screen.css").should be_true
|
299
|
+
end
|
300
|
+
|
301
|
+
it "excludes print files" do
|
302
|
+
zip_contains("css/print.css").should_not be_true
|
303
|
+
end
|
217
304
|
end
|
218
305
|
|
219
306
|
it "includes screen file" do
|
220
307
|
zip_contains("css/screen.css").should be_true
|
221
308
|
end
|
222
309
|
|
223
|
-
it "
|
224
|
-
zip_contains("css/print.css").
|
310
|
+
it "includes print file" do
|
311
|
+
zip_contains("css/print.css").should be_true
|
225
312
|
end
|
226
|
-
end
|
227
|
-
|
228
|
-
it "includes screen file" do
|
229
|
-
zip_contains("css/screen.css").should be_true
|
230
|
-
end
|
231
313
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
it "excludes meta file" do
|
237
|
-
zip_contains("metadata.yml").should_not be_true
|
238
|
-
end
|
314
|
+
it "excludes meta file" do
|
315
|
+
zip_contains("skin2.yml").should_not be_true
|
316
|
+
end
|
239
317
|
|
240
|
-
|
241
|
-
|
318
|
+
it "excludes skin file" do
|
319
|
+
zip_contains("skin.html.erb").should_not be_true
|
320
|
+
end
|
242
321
|
end
|
243
322
|
|
244
323
|
context "no exlusion" do
|
245
324
|
let(:zip_filename) { skin.compile(nil) }
|
246
325
|
|
247
326
|
it "excludes meta file" do
|
248
|
-
zip_contains("
|
327
|
+
zip_contains("skin.yml").should be_true
|
249
328
|
end
|
250
329
|
|
251
330
|
it "excludes skin file" do
|
@@ -255,34 +334,46 @@ module Adyen::Admin
|
|
255
334
|
end
|
256
335
|
|
257
336
|
describe "#upload" do
|
337
|
+
let(:path) { "#{skin_fixtures}/example-7hFAQnmt" }
|
338
|
+
|
258
339
|
after do
|
259
340
|
`rm -f #{skin_code}.zip`
|
341
|
+
`rm -f #{path}/skin.yml`
|
260
342
|
end
|
261
343
|
|
262
344
|
context "valid set" do
|
263
|
-
|
264
|
-
skin.path =
|
345
|
+
before do
|
346
|
+
skin.path = path
|
347
|
+
end
|
265
348
|
|
349
|
+
it "increases version" do
|
266
350
|
expect do
|
267
351
|
skin.upload
|
268
|
-
end.to change { skin.
|
352
|
+
end.to change { skin.send(:remote_version) }.by(1)
|
353
|
+
end
|
354
|
+
|
355
|
+
it "updates skin data" do
|
356
|
+
skin.should_receive(:update)
|
357
|
+
|
358
|
+
skin.upload
|
269
359
|
end
|
270
360
|
end
|
271
361
|
end
|
272
362
|
|
273
|
-
describe "#
|
363
|
+
describe "#remote_version" do
|
274
364
|
let(:skin) { Skin.new(:code => "Kx9axnRf", :name => "demo") }
|
365
|
+
let(:version) { 15 }
|
275
366
|
|
276
367
|
it "returns uploaded value" do
|
277
|
-
skin.
|
368
|
+
skin.send(:remote_version).should == version
|
278
369
|
end
|
279
370
|
|
280
371
|
it "returns test value" do
|
281
|
-
skin.
|
372
|
+
skin.send(:remote_version, :test).should == version
|
282
373
|
end
|
283
374
|
|
284
375
|
it "returns live value" do
|
285
|
-
skin.
|
376
|
+
skin.send(:remote_version, :live).should == 0
|
286
377
|
end
|
287
378
|
end
|
288
379
|
|
@@ -29,13 +29,13 @@ http_interactions:
|
|
29
29
|
message: Moved Temporarily
|
30
30
|
headers:
|
31
31
|
Date:
|
32
|
-
- Thu,
|
32
|
+
- Thu, 19 Apr 2012 17:35:02 GMT
|
33
33
|
Server:
|
34
34
|
- Apache
|
35
35
|
Set-Cookie:
|
36
|
-
- JSESSIONID=
|
36
|
+
- JSESSIONID=E9721CF1DF5254FC2788EDBE60AD5D5C.test5e; Path=/ca/; Secure; HttpOnly
|
37
37
|
Location:
|
38
|
-
- https://ca-test.adyen.com/ca/ca/login.shtml;jsessionid=
|
38
|
+
- https://ca-test.adyen.com/ca/ca/login.shtml;jsessionid=E9721CF1DF5254FC2788EDBE60AD5D5C.test5e
|
39
39
|
Content-Length:
|
40
40
|
- "0"
|
41
41
|
Keep-Alive:
|
@@ -48,10 +48,10 @@ http_interactions:
|
|
48
48
|
encoding: US-ASCII
|
49
49
|
string: ""
|
50
50
|
http_version:
|
51
|
-
recorded_at: Thu,
|
51
|
+
recorded_at: Thu, 19 Apr 2012 17:35:02 GMT
|
52
52
|
- request:
|
53
53
|
method: get
|
54
|
-
uri: https://ca-test.adyen.com/ca/ca/login.shtml;jsessionid=
|
54
|
+
uri: https://ca-test.adyen.com/ca/ca/login.shtml;jsessionid=E9721CF1DF5254FC2788EDBE60AD5D5C.test5e
|
55
55
|
body:
|
56
56
|
encoding: US-ASCII
|
57
57
|
string: ""
|
@@ -67,7 +67,7 @@ http_interactions:
|
|
67
67
|
Accept-Language:
|
68
68
|
- en-us,en;q=0.5
|
69
69
|
Cookie:
|
70
|
-
- JSESSIONID=
|
70
|
+
- JSESSIONID=E9721CF1DF5254FC2788EDBE60AD5D5C.test5e
|
71
71
|
Host:
|
72
72
|
- ca-test.adyen.com
|
73
73
|
Connection:
|
@@ -80,7 +80,7 @@ http_interactions:
|
|
80
80
|
message: OK
|
81
81
|
headers:
|
82
82
|
Date:
|
83
|
-
- Thu,
|
83
|
+
- Thu, 19 Apr 2012 17:35:02 GMT
|
84
84
|
Server:
|
85
85
|
- Apache
|
86
86
|
Cache-Control:
|
@@ -242,7 +242,7 @@ http_interactions:
|
|
242
242
|
|
243
243
|
<tr>
|
244
244
|
<td colspan="2"><br />
|
245
|
-
<input type="hidden" name="j_formHash" value="
|
245
|
+
<input type="hidden" name="j_formHash" value="964GlK7lxwq1iYLRIK2WHfvux9CXBM=" />
|
246
246
|
<input type="submit" class="button" value="Submit" /></td>
|
247
247
|
</tr>
|
248
248
|
</table>
|
@@ -267,5 +267,5 @@ http_interactions:
|
|
267
267
|
</html>
|
268
268
|
|
269
269
|
http_version:
|
270
|
-
recorded_at: Thu,
|
270
|
+
recorded_at: Thu, 19 Apr 2012 17:35:02 GMT
|
271
271
|
recorded_with: VCR 2.0.1
|