foreman_scc_manager 1.8.8 → 1.8.13
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.
- checksums.yaml +4 -4
- data/README.md +20 -8
- data/Rakefile +5 -9
- data/app/controllers/api/v2/scc_products_controller.rb +14 -3
- data/app/controllers/scc_accounts_controller.rb +3 -3
- data/app/lib/scc_manager.rb +5 -9
- data/app/models/scc_account.rb +8 -13
- data/app/models/scc_repository.rb +2 -2
- data/config/routes.rb +1 -1
- data/db/migrate/20210713092440_add_permissions.rb +19 -0
- data/db/migrate/20211022100718_add_product_class_to_scc_product.rb +5 -0
- data/lib/foreman_scc_manager/engine.rb +26 -6
- data/lib/foreman_scc_manager/version.rb +1 -1
- data/locale/de/foreman_scc_manager.edit.po +125 -128
- data/locale/en/foreman_scc_manager.edit.po +99 -103
- data/test/actions/sync_test.rb +24 -0
- data/test/controllers/api/v2/scc_accounts_test.rb +46 -1
- data/test/controllers/api/v2/scc_products_test.rb +21 -1
- data/test/controllers/scc_accounts_controller_test.rb +51 -1
- data/test/controllers/scc_accounts_controller_test2.rb +2 -0
- data/test/fixtures/models/katello_products.yml.bak +10 -0
- data/test/fixtures/models/scc_accounts.yml +2 -0
- data/test/fixtures/models/scc_products.yml +18 -3
- data/test/models/katello_products.rb +10 -0
- data/test/models/scc_product_test.rb +1 -1
- data/test/test_controller_helper.rb +6 -2
- data/test/test_plugin_helper.rb +2 -0
- data/test/unit/access_permissions_test.rb +18 -0
- metadata +24 -8
@@ -50,7 +50,7 @@ msgid "Date and time relative to which the sync interval is run"
|
|
50
50
|
msgstr ""
|
51
51
|
|
52
52
|
#: ../app/controllers/api/v2/scc_accounts_controller.rb:38
|
53
|
-
msgid "Associated
|
53
|
+
msgid "Associated GPG key of scc_account"
|
54
54
|
msgstr ""
|
55
55
|
|
56
56
|
#: ../app/controllers/api/v2/scc_accounts_controller.rb:42
|
@@ -113,11 +113,11 @@ msgstr ""
|
|
113
113
|
msgid "Product already subscribed!"
|
114
114
|
msgstr "Product already subscribed!"
|
115
115
|
|
116
|
-
#: ../app/lib/actions/scc_manager/subscribe_product.rb:46 action_names.rb:
|
116
|
+
#: ../app/lib/actions/scc_manager/subscribe_product.rb:46 action_names.rb:78
|
117
117
|
msgid "Subscribe SCC Product"
|
118
118
|
msgstr "Subscribe SCC Product"
|
119
119
|
|
120
|
-
#: ../app/lib/actions/scc_manager/sync.rb:27 action_names.rb:
|
120
|
+
#: ../app/lib/actions/scc_manager/sync.rb:27 action_names.rb:76
|
121
121
|
msgid "Sync SUSE subscriptions"
|
122
122
|
msgstr "Sync SUSE subscriptions"
|
123
123
|
|
@@ -129,31 +129,31 @@ msgstr ""
|
|
129
129
|
msgid "Unknown"
|
130
130
|
msgstr ""
|
131
131
|
|
132
|
-
#: ../app/lib/actions/scc_manager/sync_plan_account_repositories.rb:33 action_names.rb:
|
132
|
+
#: ../app/lib/actions/scc_manager/sync_plan_account_repositories.rb:33 action_names.rb:77
|
133
133
|
msgid "Update SUSE repositories"
|
134
134
|
msgstr ""
|
135
135
|
|
136
|
-
#: ../app/lib/actions/scc_manager/sync_products.rb:36 action_names.rb:
|
136
|
+
#: ../app/lib/actions/scc_manager/sync_products.rb:36 action_names.rb:79
|
137
137
|
msgid "Sync SUSE subscriptions (Products)"
|
138
138
|
msgstr "Sync SUSE subscriptions (Products)"
|
139
139
|
|
140
|
-
#: ../app/lib/actions/scc_manager/sync_repositories.rb:34 action_names.rb:
|
140
|
+
#: ../app/lib/actions/scc_manager/sync_repositories.rb:34 action_names.rb:75
|
141
141
|
msgid "Sync SUSE subscriptions (Repositories)"
|
142
142
|
msgstr "Sync SUSE subscriptions (Repositories)"
|
143
143
|
|
144
|
-
#: ../app/models/scc_account.rb:
|
144
|
+
#: ../app/models/scc_account.rb:57
|
145
145
|
msgid "never synced"
|
146
146
|
msgstr ""
|
147
147
|
|
148
|
-
#: ../app/models/scc_account.rb:
|
148
|
+
#: ../app/models/scc_account.rb:104
|
149
149
|
msgid "Interval cannot be nil"
|
150
150
|
msgstr ""
|
151
151
|
|
152
|
-
#: ../app/models/scc_account.rb:
|
152
|
+
#: ../app/models/scc_account.rb:111
|
153
153
|
msgid "Interval not set correctly"
|
154
154
|
msgstr ""
|
155
155
|
|
156
|
-
#: ../app/models/scc_account.rb:
|
156
|
+
#: ../app/models/scc_account.rb:116
|
157
157
|
msgid "Cron expression is not valid!"
|
158
158
|
msgstr ""
|
159
159
|
|
@@ -261,304 +261,300 @@ msgstr "SUSE Customer Center"
|
|
261
261
|
msgid "Please sync your SUSE subscriptions first."
|
262
262
|
msgstr "Please sync your SUSE subscriptions first."
|
263
263
|
|
264
|
-
#: ../lib/foreman_scc_manager/engine.rb:
|
264
|
+
#: ../lib/foreman_scc_manager/engine.rb:79
|
265
265
|
msgid "SUSE Subscriptions"
|
266
266
|
msgstr "SUSE Subscriptions"
|
267
267
|
|
268
|
+
#: action_names.rb:2
|
269
|
+
msgid "Copy version units to library"
|
270
|
+
msgstr ""
|
271
|
+
|
272
|
+
#: action_names.rb:3
|
273
|
+
msgid "Import"
|
274
|
+
msgstr ""
|
275
|
+
|
276
|
+
#: action_names.rb:4
|
277
|
+
msgid "Export Library"
|
278
|
+
msgstr ""
|
279
|
+
|
280
|
+
#: action_names.rb:5
|
281
|
+
msgid "Export"
|
282
|
+
msgstr ""
|
283
|
+
|
268
284
|
#: action_names.rb:6
|
269
|
-
msgid "
|
285
|
+
msgid "Hypervisors update"
|
270
286
|
msgstr ""
|
271
287
|
|
272
288
|
#: action_names.rb:7
|
273
|
-
msgid "
|
289
|
+
msgid "Update for host"
|
274
290
|
msgstr ""
|
275
291
|
|
276
292
|
#: action_names.rb:8
|
277
|
-
msgid "
|
293
|
+
msgid "Update Content Overrides"
|
294
|
+
msgstr ""
|
295
|
+
|
296
|
+
#: action_names.rb:9
|
297
|
+
msgid "Remove subscriptions"
|
278
298
|
msgstr ""
|
279
299
|
|
280
300
|
#: action_names.rb:10
|
281
|
-
msgid "
|
301
|
+
msgid "Hypervisors"
|
282
302
|
msgstr ""
|
283
303
|
|
284
304
|
#: action_names.rb:11
|
285
|
-
msgid "
|
305
|
+
msgid "Install Applicable Errata"
|
286
306
|
msgstr ""
|
287
307
|
|
288
308
|
#: action_names.rb:12
|
289
|
-
msgid "
|
309
|
+
msgid "Destroy Content Host"
|
290
310
|
msgstr ""
|
291
311
|
|
292
312
|
#: action_names.rb:13
|
293
|
-
msgid "
|
313
|
+
msgid "Auto attach subscriptions"
|
294
314
|
msgstr ""
|
295
315
|
|
296
316
|
#: action_names.rb:14
|
297
|
-
msgid "
|
317
|
+
msgid "Attach subscriptions"
|
298
318
|
msgstr ""
|
299
319
|
|
300
320
|
#: action_names.rb:15
|
301
|
-
msgid "
|
321
|
+
msgid "Update"
|
302
322
|
msgstr ""
|
303
323
|
|
304
324
|
#: action_names.rb:16
|
305
|
-
msgid "
|
325
|
+
msgid "Publish Lifecycle Environment Repositories"
|
306
326
|
msgstr ""
|
307
327
|
|
308
328
|
#: action_names.rb:17
|
309
|
-
msgid "
|
329
|
+
msgid "Delete Package Group"
|
310
330
|
msgstr ""
|
311
331
|
|
312
332
|
#: action_names.rb:18
|
313
|
-
msgid "
|
333
|
+
msgid "Delete"
|
314
334
|
msgstr ""
|
315
335
|
|
316
336
|
#: action_names.rb:19
|
317
|
-
msgid "
|
337
|
+
msgid "Create"
|
318
338
|
msgstr ""
|
319
339
|
|
320
340
|
#: action_names.rb:20
|
321
|
-
msgid "
|
341
|
+
msgid "Delete Lifecycle Environment"
|
322
342
|
msgstr ""
|
323
343
|
|
324
344
|
#: action_names.rb:21
|
325
|
-
msgid "
|
345
|
+
msgid "Republish Version Repositories"
|
326
346
|
msgstr ""
|
327
347
|
|
328
348
|
#: action_names.rb:22
|
329
|
-
msgid "
|
349
|
+
msgid "Synchronize"
|
330
350
|
msgstr ""
|
331
351
|
|
332
352
|
#: action_names.rb:23
|
333
|
-
msgid "
|
353
|
+
msgid "Remove Content"
|
334
354
|
msgstr ""
|
335
355
|
|
336
356
|
#: action_names.rb:24
|
337
|
-
msgid "Incremental Update
|
357
|
+
msgid "Incremental Update"
|
338
358
|
msgstr ""
|
339
359
|
|
340
360
|
#: action_names.rb:25
|
341
|
-
msgid "
|
361
|
+
msgid "Import Default Content View"
|
342
362
|
msgstr ""
|
343
363
|
|
344
364
|
#: action_names.rb:26
|
345
|
-
msgid "
|
365
|
+
msgid "Import Content View Version"
|
346
366
|
msgstr ""
|
347
367
|
|
348
368
|
#: action_names.rb:27
|
349
|
-
msgid "
|
369
|
+
msgid "Enable"
|
350
370
|
msgstr ""
|
351
371
|
|
352
372
|
#: action_names.rb:28
|
353
|
-
msgid "
|
373
|
+
msgid "Disable"
|
354
374
|
msgstr ""
|
355
375
|
|
356
376
|
#: action_names.rb:29
|
357
|
-
msgid "
|
377
|
+
msgid "Verify checksum"
|
358
378
|
msgstr ""
|
359
379
|
|
360
380
|
#: action_names.rb:30
|
361
|
-
msgid "
|
381
|
+
msgid "Filtered index content"
|
362
382
|
msgstr ""
|
363
383
|
|
364
384
|
#: action_names.rb:31
|
365
|
-
msgid "
|
385
|
+
msgid "Fetch pxe files"
|
366
386
|
msgstr ""
|
367
387
|
|
368
388
|
#: action_names.rb:32
|
369
|
-
msgid "
|
389
|
+
msgid "Errata mail"
|
370
390
|
msgstr ""
|
371
391
|
|
372
392
|
#: action_names.rb:33
|
373
|
-
msgid "
|
393
|
+
msgid "Discover"
|
374
394
|
msgstr ""
|
375
395
|
|
376
396
|
#: action_names.rb:34
|
377
|
-
msgid "
|
397
|
+
msgid "Remove Version"
|
378
398
|
msgstr ""
|
379
399
|
|
380
400
|
#: action_names.rb:35
|
381
|
-
msgid "
|
401
|
+
msgid "Remove from Environment"
|
382
402
|
msgstr ""
|
383
403
|
|
384
404
|
#: action_names.rb:36
|
385
|
-
msgid "
|
405
|
+
msgid "Remove Versions and Associations"
|
386
406
|
msgstr ""
|
387
407
|
|
388
408
|
#: action_names.rb:37
|
389
|
-
msgid "
|
409
|
+
msgid "Publish"
|
390
410
|
msgstr ""
|
391
411
|
|
392
412
|
#: action_names.rb:38
|
393
|
-
msgid "
|
413
|
+
msgid "Promotion to Environment"
|
394
414
|
msgstr ""
|
395
415
|
|
396
416
|
#: action_names.rb:39
|
397
|
-
msgid "
|
417
|
+
msgid "Product Create"
|
398
418
|
msgstr ""
|
399
419
|
|
400
420
|
#: action_names.rb:40
|
401
|
-
msgid "
|
421
|
+
msgid "Destroy"
|
402
422
|
msgstr ""
|
403
423
|
|
404
424
|
#: action_names.rb:41
|
405
|
-
msgid "
|
425
|
+
msgid "Create Import History"
|
406
426
|
msgstr ""
|
407
427
|
|
408
428
|
#: action_names.rb:42
|
409
|
-
msgid "
|
429
|
+
msgid "Create Export History"
|
410
430
|
msgstr ""
|
411
431
|
|
412
432
|
#: action_names.rb:43
|
413
|
-
msgid "Update
|
433
|
+
msgid "Update http proxy"
|
414
434
|
msgstr ""
|
415
435
|
|
416
436
|
#: action_names.rb:44
|
417
|
-
msgid "
|
437
|
+
msgid "Promote"
|
418
438
|
msgstr ""
|
419
439
|
|
420
440
|
#: action_names.rb:45
|
421
|
-
msgid "
|
441
|
+
msgid "Reindex subscriptions"
|
422
442
|
msgstr ""
|
423
443
|
|
424
444
|
#: action_names.rb:46
|
425
|
-
msgid "
|
445
|
+
msgid "Delete Product"
|
426
446
|
msgstr ""
|
427
447
|
|
428
448
|
#: action_names.rb:47
|
429
|
-
msgid "
|
449
|
+
msgid "Instance update"
|
430
450
|
msgstr ""
|
431
451
|
|
432
452
|
#: action_names.rb:48
|
433
|
-
msgid "
|
453
|
+
msgid "Index package groups"
|
434
454
|
msgstr ""
|
435
455
|
|
436
456
|
#: action_names.rb:49
|
437
|
-
msgid "
|
457
|
+
msgid "Index module streams"
|
438
458
|
msgstr ""
|
439
459
|
|
440
460
|
#: action_names.rb:50
|
441
|
-
msgid "
|
461
|
+
msgid "Index errata"
|
442
462
|
msgstr ""
|
443
463
|
|
444
464
|
#: action_names.rb:51
|
445
|
-
msgid "
|
465
|
+
msgid "Index content"
|
446
466
|
msgstr ""
|
447
467
|
|
448
468
|
#: action_names.rb:52
|
449
|
-
msgid "
|
469
|
+
msgid "Upload into"
|
450
470
|
msgstr ""
|
451
471
|
|
452
472
|
#: action_names.rb:53
|
453
|
-
msgid "
|
473
|
+
msgid "Create Package Group"
|
454
474
|
msgstr ""
|
455
475
|
|
456
476
|
#: action_names.rb:54
|
457
|
-
msgid "
|
477
|
+
msgid "Update redhat repository"
|
458
478
|
msgstr ""
|
459
479
|
|
460
480
|
#: action_names.rb:55
|
461
|
-
msgid "
|
481
|
+
msgid "Update http proxy details"
|
462
482
|
msgstr ""
|
463
483
|
|
464
484
|
#: action_names.rb:56
|
465
|
-
msgid "
|
485
|
+
msgid "Update content urls"
|
466
486
|
msgstr ""
|
467
487
|
|
468
488
|
#: action_names.rb:57
|
469
|
-
msgid "
|
489
|
+
msgid "Run Sync Plan:"
|
470
490
|
msgstr ""
|
471
491
|
|
472
492
|
#: action_names.rb:58
|
473
|
-
msgid "
|
493
|
+
msgid "Combined Profile Update"
|
474
494
|
msgstr ""
|
475
495
|
|
476
496
|
#: action_names.rb:59
|
477
|
-
msgid "
|
497
|
+
msgid "Package Profile Update"
|
478
498
|
msgstr ""
|
479
499
|
|
480
500
|
#: action_names.rb:60
|
481
|
-
msgid "
|
501
|
+
msgid "Updating System Purpose for host"
|
482
502
|
msgstr ""
|
483
503
|
|
484
504
|
#: action_names.rb:61
|
485
|
-
msgid "
|
505
|
+
msgid "Update release version for host"
|
486
506
|
msgstr ""
|
487
507
|
|
488
508
|
#: action_names.rb:62
|
489
|
-
msgid "
|
509
|
+
msgid "Incremental Update of Content View Version(s) "
|
490
510
|
msgstr ""
|
491
511
|
|
492
512
|
#: action_names.rb:63
|
493
|
-
msgid "
|
513
|
+
msgid "Sync capsule"
|
494
514
|
msgstr ""
|
495
515
|
|
496
516
|
#: action_names.rb:64
|
497
|
-
msgid "
|
517
|
+
msgid "Synchronize smart proxy"
|
498
518
|
msgstr ""
|
499
519
|
|
500
520
|
#: action_names.rb:65
|
501
|
-
msgid "
|
521
|
+
msgid "Generate repository applicability"
|
502
522
|
msgstr ""
|
503
523
|
|
504
524
|
#: action_names.rb:66
|
505
|
-
msgid "
|
525
|
+
msgid "Bulk generate applicability for hosts"
|
506
526
|
msgstr ""
|
507
527
|
|
508
528
|
#: action_names.rb:67
|
509
|
-
msgid "
|
529
|
+
msgid "Generate host applicability"
|
510
530
|
msgstr ""
|
511
531
|
|
512
532
|
#: action_names.rb:68
|
513
|
-
msgid "
|
533
|
+
msgid "Agent action"
|
514
534
|
msgstr ""
|
515
535
|
|
516
536
|
#: action_names.rb:69
|
517
|
-
msgid "
|
537
|
+
msgid "Delete Activation Key"
|
518
538
|
msgstr ""
|
519
539
|
|
520
540
|
#: action_names.rb:70
|
521
|
-
msgid "
|
541
|
+
msgid "Abstract async task"
|
522
542
|
msgstr ""
|
523
543
|
|
524
544
|
#: action_names.rb:71
|
525
|
-
msgid "
|
545
|
+
msgid "Remote action:"
|
526
546
|
msgstr ""
|
527
547
|
|
528
548
|
#: action_names.rb:72
|
529
|
-
msgid "
|
549
|
+
msgid "Import Puppet classes"
|
530
550
|
msgstr ""
|
531
551
|
|
532
552
|
#: action_names.rb:73
|
533
|
-
msgid "
|
553
|
+
msgid "Import facts"
|
534
554
|
msgstr ""
|
535
555
|
|
536
556
|
#: action_names.rb:74
|
537
|
-
msgid "
|
538
|
-
msgstr ""
|
539
|
-
|
540
|
-
#: action_names.rb:75
|
541
|
-
msgid "Fetch pxe files"
|
542
|
-
msgstr ""
|
543
|
-
|
544
|
-
#: action_names.rb:76
|
545
|
-
msgid "Index module streams"
|
546
|
-
msgstr ""
|
547
|
-
|
548
|
-
#: action_names.rb:77
|
549
|
-
msgid "Index package groups"
|
550
|
-
msgstr ""
|
551
|
-
|
552
|
-
#: action_names.rb:78
|
553
|
-
msgid "Filtered index content"
|
554
|
-
msgstr ""
|
555
|
-
|
556
|
-
#: action_names.rb:79
|
557
|
-
msgid "Index errata"
|
558
|
-
msgstr ""
|
559
|
-
|
560
|
-
#: action_names.rb:80
|
561
|
-
msgid "Index content"
|
557
|
+
msgid "Action with sub plans"
|
562
558
|
msgstr ""
|
563
559
|
|
564
560
|
#: gemspec.rb:2
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class SccManagerActions < ActiveSupport::TestCase
|
4
|
+
include Dynflow::Testing
|
5
|
+
|
6
|
+
let(:action_class) { ::Actions::SccManager::Sync }
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@scc_account = scc_accounts(:one)
|
10
|
+
# ensure we have an org label
|
11
|
+
get_organization
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'plan sync action' do
|
15
|
+
action = create_action(action_class)
|
16
|
+
action.stubs(:action_subject).with(@scc_account)
|
17
|
+
|
18
|
+
assert_respond_to(action, :phase)
|
19
|
+
plan_action(action, @scc_account)
|
20
|
+
|
21
|
+
assert_action_planned_with(action, ::Actions::SccManager::SyncProducts, @scc_account)
|
22
|
+
assert_action_planned_with(action, ::Actions::SccManager::SyncRepositories, @scc_account)
|
23
|
+
end
|
24
|
+
end
|
@@ -208,13 +208,52 @@ class Api::V2::SccAccountsControllerTest < ActionController::TestCase
|
|
208
208
|
assert_response :ok
|
209
209
|
end
|
210
210
|
|
211
|
-
test 'should refuse update scc_account' do
|
211
|
+
test 'should refuse update scc_account with invalid interval' do
|
212
212
|
account = scc_accounts(:two)
|
213
213
|
put :update, params: { id: account.id, :scc_account => { :interval => 'yearly' } }
|
214
214
|
assert_equal 'yearly', assigns(:scc_account).interval
|
215
215
|
assert_response :unprocessable_entity
|
216
216
|
end
|
217
217
|
|
218
|
+
test 'should refuse update scc_account with empty date' do
|
219
|
+
account = scc_accounts(:two)
|
220
|
+
put :update, params: { id: account.id, :scc_account => { :interval => 'weekly', :sync_date => '' } }
|
221
|
+
assert_response :unprocessable_entity
|
222
|
+
assert_error_message 'Sync date must be a valid datetime'
|
223
|
+
end
|
224
|
+
|
225
|
+
test 'should fail to update scc_account with interval set and invalid date' do
|
226
|
+
account = scc_accounts(:two)
|
227
|
+
put :update, params: { id: account.id, :scc_account => { :sync_date => 'invalid_date', :interval => 'weekly' } }
|
228
|
+
|
229
|
+
assert_response :unprocessable_entity
|
230
|
+
assert_error_message 'Sync date must be a valid datetime'
|
231
|
+
end
|
232
|
+
|
233
|
+
test 'should fail to update scc_account with empty name' do
|
234
|
+
account = scc_accounts(:two)
|
235
|
+
put :update, params: { id: account.id, :scc_account => { :name => '', :sync_date => Time.now, :interval => 'weekly' } }
|
236
|
+
|
237
|
+
assert_response :unprocessable_entity
|
238
|
+
assert_error_message "Name can't be blank"
|
239
|
+
end
|
240
|
+
|
241
|
+
test 'should fail to update scc_account with empty login' do
|
242
|
+
account = scc_accounts(:two)
|
243
|
+
put :update, params: { id: account.id, :scc_account => { :login => '', :sync_date => Time.now, :interval => 'weekly' } }
|
244
|
+
|
245
|
+
assert_response :unprocessable_entity
|
246
|
+
assert_error_message "Login can't be blank"
|
247
|
+
end
|
248
|
+
|
249
|
+
test 'should fail to update scc_account with empty base_url' do
|
250
|
+
account = scc_accounts(:two)
|
251
|
+
put :update, params: { id: account.id, :scc_account => { :base_url => '', :sync_date => Time.now, :interval => 'weekly' } }
|
252
|
+
|
253
|
+
assert_response :unprocessable_entity
|
254
|
+
assert_error_message "Base url can't be blank"
|
255
|
+
end
|
256
|
+
|
218
257
|
test 'new account SCC server connection-test' do
|
219
258
|
scc_setup
|
220
259
|
account = scc_accounts(:one)
|
@@ -305,4 +344,10 @@ class Api::V2::SccAccountsControllerTest < ActionController::TestCase
|
|
305
344
|
end
|
306
345
|
assert_response :ok
|
307
346
|
end
|
347
|
+
|
348
|
+
private
|
349
|
+
|
350
|
+
def assert_error_message(message)
|
351
|
+
assert_includes JSON.parse(response.body)['error']['full_messages'], message
|
352
|
+
end
|
308
353
|
end
|
@@ -5,7 +5,9 @@ class Api::V2::SccProductsControllerTest < ActionController::TestCase
|
|
5
5
|
@scc_account = scc_accounts(:one)
|
6
6
|
@scc_product1 = scc_products(:one)
|
7
7
|
@scc_product2 = scc_products(:two)
|
8
|
-
@
|
8
|
+
@scc_product3 = scc_products(:three)
|
9
|
+
@scc_product4 = scc_products(:four)
|
10
|
+
@scc_account.scc_products = [@scc_product1, @scc_product2, @scc_product3, @scc_product4]
|
9
11
|
end
|
10
12
|
|
11
13
|
test 'should get index' do
|
@@ -37,4 +39,22 @@ class Api::V2::SccProductsControllerTest < ActionController::TestCase
|
|
37
39
|
put :subscribe, params: { :id => 'doest-not-exit', :scc_account_id => @scc_account.id }
|
38
40
|
assert_response :not_found
|
39
41
|
end
|
42
|
+
|
43
|
+
test 'show subscribed products only' do
|
44
|
+
get :index, params: { :scc_account_id => @scc_account.id, :subscribed_only => true }
|
45
|
+
assert_response :success
|
46
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
47
|
+
assert_not_empty body
|
48
|
+
assert_equal 2, body['results'].count
|
49
|
+
assert_equal 2, body['subtotal']
|
50
|
+
end
|
51
|
+
|
52
|
+
test 'show all products if subscribed_only flag is set to false' do
|
53
|
+
get :index, params: { :scc_account_id => @scc_account.id, :subscribed_only => false }
|
54
|
+
assert_response :success
|
55
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
56
|
+
assert_not_empty body
|
57
|
+
assert_equal 4, body['results'].count
|
58
|
+
assert_equal 4, body['subtotal']
|
59
|
+
end
|
40
60
|
end
|
@@ -69,8 +69,58 @@ class SccAccountsControllerTest < ActionController::TestCase
|
|
69
69
|
test 'should update scc_account' do
|
70
70
|
account = scc_accounts(:two)
|
71
71
|
put :update, params: { id: account.id, :scc_account => { :sync_date => Time.now, :interval => 'weekly' } }, session: set_session_user
|
72
|
+
assert_redirected_to '/scc_accounts'
|
73
|
+
assert_equal 'weekly', SccAccount.find(account.id).interval
|
74
|
+
end
|
75
|
+
|
76
|
+
test 'should update scc_account with empty date if interval not set' do
|
77
|
+
account = scc_accounts(:two)
|
78
|
+
put :update, params: { id: account.id, :scc_account => { :name => 'new_name', :sync_date => '', :interval => 'never' } }, session: set_session_user
|
79
|
+
|
80
|
+
assert_equal 'new_name', SccAccount.find(account.id).name
|
81
|
+
end
|
82
|
+
|
83
|
+
test 'updates scc_account even if the date is invalid' do
|
84
|
+
# @todo reminder to fix this in the future
|
85
|
+
account = scc_accounts(:two)
|
86
|
+
put :update, params: { id: account.id, :scc_account => { :name => 'new_name', :sync_date => 'invalid_date', :interval => 'never' } }, session: set_session_user
|
87
|
+
|
88
|
+
assert_not_equal account.name, SccAccount.find(account.id).name
|
89
|
+
end
|
90
|
+
|
91
|
+
test 'should fail to update scc_account with interval set and empty date' do
|
92
|
+
account = scc_accounts(:two)
|
93
|
+
put :update, params: { id: account.id, :scc_account => { :sync_date => '', :interval => 'weekly' } }, session: set_session_user
|
94
|
+
|
95
|
+
assert_equal SccAccount.find(account.id).sync_date, account.sync_date
|
96
|
+
end
|
97
|
+
|
98
|
+
test 'should fail to update scc_account with interval set and invalid date' do
|
99
|
+
account = scc_accounts(:two)
|
100
|
+
put :update, params: { id: account.id, :scc_account => { :sync_date => 'invalid_date', :interval => 'weekly' } }, session: set_session_user
|
101
|
+
|
102
|
+
assert_equal SccAccount.find(account.id).sync_date, account.sync_date
|
103
|
+
end
|
104
|
+
|
105
|
+
test 'should fail to update scc_account with empty name' do
|
106
|
+
account = scc_accounts(:two)
|
107
|
+
put :update, params: { id: account.id, :scc_account => { :name => '', :sync_date => Time.now, :interval => 'weekly' } }, session: set_session_user
|
108
|
+
|
109
|
+
assert_equal account.name, SccAccount.find(account.id).name
|
110
|
+
end
|
111
|
+
|
112
|
+
test 'should fail to update scc_account with empty login' do
|
113
|
+
account = scc_accounts(:two)
|
114
|
+
put :update, params: { id: account.id, :scc_account => { :login => '', :sync_date => Time.now, :interval => 'weekly' } }, session: set_session_user
|
115
|
+
|
116
|
+
assert_equal account.login, SccAccount.find(account.id).login
|
117
|
+
end
|
118
|
+
|
119
|
+
test 'should fail to update scc_account with empty base url' do
|
120
|
+
account = scc_accounts(:two)
|
121
|
+
put :update, params: { id: account.id, :scc_account => { :base_url => '', :sync_date => Time.now, :interval => 'weekly' } }, session: set_session_user
|
72
122
|
|
73
|
-
assert_equal
|
123
|
+
assert_equal account.base_url, SccAccount.find(account.id).base_url
|
74
124
|
end
|
75
125
|
|
76
126
|
test 'SCC server sync products' do
|
@@ -6,6 +6,7 @@ one:
|
|
6
6
|
name: onename
|
7
7
|
interval: never
|
8
8
|
organization_id: <%= ActiveRecord::FixtureSet.identify(:empty_organization) %>
|
9
|
+
sync_date: Time.now
|
9
10
|
|
10
11
|
two:
|
11
12
|
login: twouser
|
@@ -14,6 +15,7 @@ two:
|
|
14
15
|
name: twoname
|
15
16
|
interval: never
|
16
17
|
organization_id: <%= ActiveRecord::FixtureSet.identify(:empty_organization) %>
|
18
|
+
sync_date: 2021-07-05T21:33:49
|
17
19
|
|
18
20
|
account_missing_url:
|
19
21
|
login: fakeuser1
|