foreman_scc_manager 1.8.3 → 1.8.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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -0
  3. data/app/controllers/api/v2/scc_accounts_controller.rb +9 -7
  4. data/app/controllers/scc_accounts_controller.rb +30 -4
  5. data/app/lib/actions/scc_manager/subscribe_product.rb +26 -13
  6. data/app/lib/actions/scc_manager/sync.rb +5 -5
  7. data/app/lib/actions/scc_manager/sync_products.rb +10 -13
  8. data/app/lib/actions/scc_manager/sync_repositories.rb +9 -13
  9. data/app/models/scc_account.rb +63 -5
  10. data/app/models/scc_product.rb +20 -2
  11. data/app/models/scc_repository.rb +11 -9
  12. data/app/views/scc_accounts/_form.html.erb +6 -0
  13. data/app/views/scc_accounts/index.html.erb +4 -3
  14. data/app/views/scc_accounts/show.html.erb +13 -4
  15. data/db/migrate/20200520281300_fix_scc_permissions.rb +22 -0
  16. data/db/migrate/20201119084201_add_gpg_key_to_scc_account.rb +6 -0
  17. data/db/migrate/20210205082733_add_subscription_valid_to_scc_products_and_repos.rb +6 -0
  18. data/db/migrate/20210210104407_add_root_repository_id_to_scc_repository.rb +6 -0
  19. data/db/migrate/20210224095050_connect_katello_root_repository_to_scc_repository.rb +28 -0
  20. data/lib/foreman_scc_manager/engine.rb +36 -25
  21. data/lib/foreman_scc_manager/version.rb +1 -1
  22. data/lib/tasks/test.rake +1 -1
  23. data/locale/de/LC_MESSAGES/foreman_scc_manager.mo +0 -0
  24. data/locale/de/foreman_scc_manager.edit.po +574 -0
  25. data/locale/de/foreman_scc_manager.po +40 -21
  26. data/locale/de/foreman_scc_manager.po.time_stamp +0 -0
  27. data/locale/en/foreman_scc_manager.edit.po +566 -0
  28. data/locale/en/foreman_scc_manager.po +21 -3
  29. data/locale/en/foreman_scc_manager.po.time_stamp +0 -0
  30. data/locale/foreman_scc_manager.pot +65 -38
  31. data/test/controllers/api/v2/scc_accounts_test.rb +9 -3
  32. data/test/controllers/scc_accounts_controller_test.rb +104 -0
  33. data/test/controllers/scc_accounts_controller_test2.rb +51 -0
  34. data/test/fixtures/models/scc_extendings.yml +6 -0
  35. data/test/fixtures/models/scc_products.yml +30 -2
  36. data/test/fixtures/models/scc_repositories.yml +29 -0
  37. data/test/models/scc_account_test.rb +70 -0
  38. data/test/models/scc_product_test.rb +69 -1
  39. data/test/support/fixtures_support.rb +3 -2
  40. data/test/test_controller_helper.rb +15 -0
  41. data/test/test_plugin_helper.rb +9 -0
  42. metadata +33 -14
@@ -17,6 +17,9 @@ msgstr ""
17
17
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
18
18
  "\n"
19
19
 
20
+ msgid "(WARNING: Please check your SUSE subscription)"
21
+ msgstr ""
22
+
20
23
  msgid "Actions"
21
24
  msgstr ""
22
25
 
@@ -26,6 +29,9 @@ msgstr "Add SCC account"
26
29
  msgid "Add SUSE Customer Center Account"
27
30
  msgstr "Add SUSE Customer Center Account"
28
31
 
32
+ msgid "Associated GPG key of scc_account"
33
+ msgstr ""
34
+
29
35
  msgid "Base URL"
30
36
  msgstr "Base URL"
31
37
 
@@ -38,6 +44,12 @@ msgstr ""
38
44
  msgid "Cron expression is not valid!"
39
45
  msgstr ""
40
46
 
47
+ msgid "Date and time relative to which the sync interval is run"
48
+ msgstr ""
49
+
50
+ msgid "Delete"
51
+ msgstr ""
52
+
41
53
  msgid "Delete %s?"
42
54
  msgstr ""
43
55
 
@@ -62,9 +74,6 @@ msgstr ""
62
74
  msgid "Interval not set correctly"
63
75
  msgstr ""
64
76
 
65
- msgid "Last Sync time of scc_account"
66
- msgstr ""
67
-
68
77
  msgid "Last synced"
69
78
  msgstr "Last synced"
70
79
 
@@ -86,6 +95,9 @@ msgstr ""
86
95
  msgid "No products selected."
87
96
  msgstr ""
88
97
 
98
+ msgid "None"
99
+ msgstr ""
100
+
89
101
  msgid "Password of scc_account"
90
102
  msgstr ""
91
103
 
@@ -182,6 +194,12 @@ msgstr ""
182
194
  msgid "Update scc_account"
183
195
  msgstr ""
184
196
 
197
+ msgid "Use GPG key for SUSE products"
198
+ msgstr ""
199
+
200
+ msgid "Use this setting if you want to automatically add a GPG key to your SUSE products upon subscription. You can change this setting in the 'Content' > 'Products' menu, later."
201
+ msgstr ""
202
+
185
203
  msgid "Use your 'Organization credentials' obtained from the SUSE Customer Center."
186
204
  msgstr ""
187
205
 
File without changes
@@ -8,8 +8,8 @@ msgid ""
8
8
  msgstr ""
9
9
  "Project-Id-Version: foreman_scc_manager 1.0.0\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2020-03-02 13:47+0000\n"
12
- "PO-Revision-Date: 2020-03-02 13:47+0000\n"
11
+ "POT-Creation-Date: 2021-03-02 07:16+0000\n"
12
+ "PO-Revision-Date: 2021-03-02 07:16+0000\n"
13
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
15
  "Language: \n"
@@ -31,17 +31,17 @@ msgid "Name of the scc_account"
31
31
  msgstr ""
32
32
 
33
33
  #: ../app/controllers/api/v2/scc_accounts_controller.rb:33
34
- #: ../app/controllers/api/v2/scc_accounts_controller.rb:64
34
+ #: ../app/controllers/api/v2/scc_accounts_controller.rb:65
35
35
  msgid "Login id of scc_account"
36
36
  msgstr ""
37
37
 
38
38
  #: ../app/controllers/api/v2/scc_accounts_controller.rb:34
39
- #: ../app/controllers/api/v2/scc_accounts_controller.rb:65
39
+ #: ../app/controllers/api/v2/scc_accounts_controller.rb:66
40
40
  msgid "Password of scc_account"
41
41
  msgstr ""
42
42
 
43
43
  #: ../app/controllers/api/v2/scc_accounts_controller.rb:35
44
- #: ../app/controllers/api/v2/scc_accounts_controller.rb:66
44
+ #: ../app/controllers/api/v2/scc_accounts_controller.rb:67
45
45
  msgid "URL of SUSE for scc_account"
46
46
  msgstr ""
47
47
 
@@ -50,31 +50,35 @@ msgid "Interval for syncing scc_account"
50
50
  msgstr ""
51
51
 
52
52
  #: ../app/controllers/api/v2/scc_accounts_controller.rb:37
53
- msgid "Last Sync time of scc_account"
53
+ msgid "Date and time relative to which the sync interval is run"
54
+ msgstr ""
55
+
56
+ #: ../app/controllers/api/v2/scc_accounts_controller.rb:38
57
+ msgid "Associated GPG key of scc_account"
54
58
  msgstr ""
55
59
 
56
- #: ../app/controllers/api/v2/scc_accounts_controller.rb:41
60
+ #: ../app/controllers/api/v2/scc_accounts_controller.rb:42
57
61
  msgid "Create an scc_account"
58
62
  msgstr ""
59
63
 
60
- #: ../app/controllers/api/v2/scc_accounts_controller.rb:48
64
+ #: ../app/controllers/api/v2/scc_accounts_controller.rb:49
61
65
  msgid "Update scc_account"
62
66
  msgstr ""
63
67
 
64
- #: ../app/controllers/api/v2/scc_accounts_controller.rb:55
68
+ #: ../app/controllers/api/v2/scc_accounts_controller.rb:56
65
69
  msgid "Delete scc_account"
66
70
  msgstr ""
67
71
 
68
- #: ../app/controllers/api/v2/scc_accounts_controller.rb:61
69
72
  #: ../app/controllers/api/v2/scc_accounts_controller.rb:62
73
+ #: ../app/controllers/api/v2/scc_accounts_controller.rb:63
70
74
  msgid "Test connection for scc_account"
71
75
  msgstr ""
72
76
 
73
- #: ../app/controllers/api/v2/scc_accounts_controller.rb:89
77
+ #: ../app/controllers/api/v2/scc_accounts_controller.rb:90
74
78
  msgid "Sync scc_account"
75
79
  msgstr ""
76
80
 
77
- #: ../app/controllers/api/v2/scc_accounts_controller.rb:103
81
+ #: ../app/controllers/api/v2/scc_accounts_controller.rb:104
78
82
  msgid "Bulk subscription of scc_products for scc_account"
79
83
  msgstr ""
80
84
 
@@ -90,25 +94,25 @@ msgstr ""
90
94
  msgid "Subscribe product"
91
95
  msgstr ""
92
96
 
93
- #: ../app/controllers/scc_accounts_controller.rb:64
97
+ #: ../app/controllers/scc_accounts_controller.rb:71
94
98
  msgid "Sync task started."
95
99
  msgstr ""
96
100
 
97
- #: ../app/controllers/scc_accounts_controller.rb:66
98
- #: ../app/controllers/scc_accounts_controller.rb:86
101
+ #: ../app/controllers/scc_accounts_controller.rb:73
102
+ #: ../app/controllers/scc_accounts_controller.rb:93
99
103
  msgid "Failed to add task to queue: %s"
100
104
  msgstr ""
101
105
 
102
- #: ../app/controllers/scc_accounts_controller.rb:68
103
- #: ../app/controllers/scc_accounts_controller.rb:88
106
+ #: ../app/controllers/scc_accounts_controller.rb:75
107
+ #: ../app/controllers/scc_accounts_controller.rb:95
104
108
  msgid "Lock on SCC account already taken: %s"
105
109
  msgstr ""
106
110
 
107
- #: ../app/controllers/scc_accounts_controller.rb:81
111
+ #: ../app/controllers/scc_accounts_controller.rb:88
108
112
  msgid "Task to subscribe products started."
109
113
  msgstr ""
110
114
 
111
- #: ../app/controllers/scc_accounts_controller.rb:83
115
+ #: ../app/controllers/scc_accounts_controller.rb:90
112
116
  msgid "No products selected."
113
117
  msgstr ""
114
118
 
@@ -116,11 +120,11 @@ msgstr ""
116
120
  msgid "Product already subscribed!"
117
121
  msgstr ""
118
122
 
119
- #: ../app/lib/actions/scc_manager/subscribe_product.rb:35 action_names.rb:68
123
+ #: ../app/lib/actions/scc_manager/subscribe_product.rb:46 action_names.rb:5
120
124
  msgid "Subscribe SCC Product"
121
125
  msgstr ""
122
126
 
123
- #: ../app/lib/actions/scc_manager/sync.rb:27 action_names.rb:69
127
+ #: ../app/lib/actions/scc_manager/sync.rb:27 action_names.rb:4
124
128
  msgid "Sync SUSE subscriptions"
125
129
  msgstr ""
126
130
 
@@ -133,31 +137,31 @@ msgid "Unknown"
133
137
  msgstr ""
134
138
 
135
139
  #: ../app/lib/actions/scc_manager/sync_plan_account_repositories.rb:33
136
- #: action_names.rb:70
140
+ #: action_names.rb:9
137
141
  msgid "Update SUSE repositories"
138
142
  msgstr ""
139
143
 
140
- #: ../app/lib/actions/scc_manager/sync_products.rb:34 action_names.rb:71
144
+ #: ../app/lib/actions/scc_manager/sync_products.rb:36 action_names.rb:3
141
145
  msgid "Sync SUSE subscriptions (Products)"
142
146
  msgstr ""
143
147
 
144
- #: ../app/lib/actions/scc_manager/sync_repositories.rb:33 action_names.rb:72
148
+ #: ../app/lib/actions/scc_manager/sync_repositories.rb:34 action_names.rb:2
145
149
  msgid "Sync SUSE subscriptions (Repositories)"
146
150
  msgstr ""
147
151
 
148
- #: ../app/models/scc_account.rb:59
152
+ #: ../app/models/scc_account.rb:62
149
153
  msgid "never synced"
150
154
  msgstr ""
151
155
 
152
- #: ../app/models/scc_account.rb:106
156
+ #: ../app/models/scc_account.rb:109
153
157
  msgid "Interval cannot be nil"
154
158
  msgstr ""
155
159
 
156
- #: ../app/models/scc_account.rb:113
160
+ #: ../app/models/scc_account.rb:116
157
161
  msgid "Interval not set correctly"
158
162
  msgstr ""
159
163
 
160
- #: ../app/models/scc_account.rb:118
164
+ #: ../app/models/scc_account.rb:121
161
165
  msgid "Cron expression is not valid!"
162
166
  msgstr ""
163
167
 
@@ -170,33 +174,48 @@ msgstr ""
170
174
  msgid "SUSE Subscription: "
171
175
  msgstr ""
172
176
 
173
- #: ../app/views/scc_accounts/_form.html.erb:6
177
+ #: ../app/views/scc_accounts/_form.html.erb:7
174
178
  msgid "SUSE Customer Center account"
175
179
  msgstr ""
176
180
 
177
- #: ../app/views/scc_accounts/_form.html.erb:13
181
+ #: ../app/views/scc_accounts/_form.html.erb:14
178
182
  msgid "Use your 'Organization credentials' obtained from the SUSE Customer Center."
179
183
  msgstr ""
180
184
 
181
- #: ../app/views/scc_accounts/_form.html.erb:15
185
+ #: ../app/views/scc_accounts/_form.html.erb:16
182
186
  msgid "Base URL"
183
187
  msgstr ""
184
188
 
185
- #: ../app/views/scc_accounts/_form.html.erb:17
189
+ #: ../app/views/scc_accounts/_form.html.erb:18
186
190
  msgid "Sync interval"
187
191
  msgstr ""
188
192
 
189
- #: ../app/views/scc_accounts/_form.html.erb:17
193
+ #: ../app/views/scc_accounts/_form.html.erb:18
190
194
  msgid ""
191
195
  "The sync interval is used to periodically update the SCC authentication tokens"
192
196
  " of any imported products."
193
197
  msgstr ""
194
198
 
195
- #: ../app/views/scc_accounts/_form.html.erb:18
199
+ #: ../app/views/scc_accounts/_form.html.erb:19
196
200
  msgid "Sync Date"
197
201
  msgstr ""
198
202
 
199
- #: ../app/views/scc_accounts/_form.html.erb:25
203
+ #: ../app/views/scc_accounts/_form.html.erb:23
204
+ msgid "None"
205
+ msgstr ""
206
+
207
+ #: ../app/views/scc_accounts/_form.html.erb:24
208
+ msgid "Use GPG key for SUSE products"
209
+ msgstr ""
210
+
211
+ #: ../app/views/scc_accounts/_form.html.erb:26
212
+ msgid ""
213
+ "Use this setting if you want to automatically add a GPG key to your SUSE produ"
214
+ "cts upon subscription. You can change this setting in the 'Content' > 'Product"
215
+ "s' menu, later."
216
+ msgstr ""
217
+
218
+ #: ../app/views/scc_accounts/_form.html.erb:31
200
219
  msgid "Test Connection"
201
220
  msgstr ""
202
221
 
@@ -240,15 +259,23 @@ msgstr ""
240
259
  msgid "Add SUSE Customer Center Account"
241
260
  msgstr ""
242
261
 
243
- #: ../app/views/scc_accounts/show.html.erb:25
262
+ #: ../app/views/scc_accounts/show.html.erb:1
263
+ msgid "Product Selection for Account %s"
264
+ msgstr ""
265
+
266
+ #: ../app/views/scc_accounts/show.html.erb:17
267
+ msgid "(WARNING: Please check your SUSE subscription)"
268
+ msgstr ""
269
+
270
+ #: ../app/views/scc_accounts/show.html.erb:33
244
271
  msgid "SUSE Customer Center"
245
272
  msgstr ""
246
273
 
247
- #: ../app/views/scc_accounts/show.html.erb:36
274
+ #: ../app/views/scc_accounts/show.html.erb:44
248
275
  msgid "Please sync your SUSE subscriptions first."
249
276
  msgstr ""
250
277
 
251
- #: ../lib/foreman_scc_manager/engine.rb:66
278
+ #: ../lib/foreman_scc_manager/engine.rb:77
252
279
  msgid "SUSE Subscriptions"
253
280
  msgstr ""
254
281
 
@@ -236,7 +236,9 @@ class Api::V2::SccAccountsControllerTest < ActionController::TestCase
236
236
  assert account
237
237
  post :test_connection, params: { :scc_account => { :login => account.login, :password => account.password, :base_url => account.base_url } }
238
238
  assert_response :not_found
239
- assert_match response.body, '"Failed"'
239
+ body = ActiveSupport::JSON.decode(@response.body)
240
+ assert body.key? 'error'
241
+ assert_equal body['success'], false
240
242
  end
241
243
 
242
244
  test 'existing account SCC server connection-test' do
@@ -260,7 +262,9 @@ class Api::V2::SccAccountsControllerTest < ActionController::TestCase
260
262
  assert account
261
263
  post :test_connection, params: { :id => account.id }
262
264
  assert_response :not_found
263
- assert_match response.body, '"Failed"'
265
+ body = ActiveSupport::JSON.decode(@response.body)
266
+ assert body.key? 'error'
267
+ assert_equal body['success'], false
264
268
  end
265
269
 
266
270
  test 'SCC server sync products' do
@@ -289,7 +293,9 @@ class Api::V2::SccAccountsControllerTest < ActionController::TestCase
289
293
  account.scc_products = [product1, product2]
290
294
  put :bulk_subscribe, params: { :id => account.id, :scc_subscribe_product_ids => [] }
291
295
  assert_response :expectation_failed
292
- assert_match response.body, '"No Product selected"'
296
+ body = ActiveSupport::JSON.decode(@response.body)
297
+ assert body.key? 'error'
298
+ assert_match body['error'], 'No Product selected'
293
299
  end
294
300
 
295
301
  test 'should delete scc_account' do
@@ -0,0 +1,104 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class SccAccountsControllerTest < ActionController::TestCase
4
+ def setup
5
+ @scc_account = scc_accounts(:one)
6
+ end
7
+
8
+ def stub_custom_request(url, host = 'scc.example.com', auth = 'Basic b25ldXNlcjpvbmVwYXNz')
9
+ stub_request(:get, url)
10
+ .with(
11
+ headers: {
12
+ 'Accept' => 'application/vnd.scc.suse.com.v4+json',
13
+ 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
14
+ 'Authorization' => auth,
15
+ 'Host' => host,
16
+ 'User-Agent' => "rest-client/2.1.0 (linux-gnu x86_64) ruby/#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}"
17
+ }
18
+ )
19
+ .to_return(status: 200, body: '', headers: {})
20
+ end
21
+
22
+ test 'should get new' do
23
+ get :new, session: set_session_user
24
+ assert_response :success
25
+ assert_select 'title', 'Add SUSE Customer Center Account'
26
+ end
27
+
28
+ test 'should get edit' do
29
+ get :edit, params: { :id => @scc_account.id }, session: set_session_user
30
+ assert_response :success
31
+ assert_select 'title', "Edit #{@scc_account.name}"
32
+ end
33
+
34
+ test 'should get index' do
35
+ get :index, session: set_session_user
36
+ assert_response :success
37
+ assert_not_nil assigns(:scc_accounts)
38
+ body = @response.body
39
+ assert_not_empty body
40
+ assert_select 'title', 'SUSE subscriptions'
41
+ end
42
+
43
+ test 'should show scc_account' do
44
+ get :show, params: { :id => @scc_account.id }, session: set_session_user
45
+
46
+ assert_not_nil assigns(:scc_account)
47
+ assert_response :success
48
+ assert_select 'title', "Product Selection for Account #{@scc_account.name}"
49
+ end
50
+
51
+ test 'should 404 for unknown scc_account' do
52
+ get :show, params: { :id => 'does-not-exist' }, session: set_session_user
53
+
54
+ assert_response :not_found
55
+ end
56
+
57
+ test 'should create scc_account' do
58
+ account = scc_accounts(:two)
59
+ organization = get_organization
60
+ assert organization
61
+ assert account
62
+ assert_difference('SccAccount.count') do
63
+ post :create, params:
64
+ { :scc_account => { :name => account.name, :login => account.login, :password => account.password, :organization_id => organization.id } },
65
+ session: set_session_user
66
+ end
67
+ end
68
+
69
+ test 'should update scc_account' do
70
+ account = scc_accounts(:two)
71
+ put :update, params: { id: account.id, :scc_account => { :sync_date => Time.now, :interval => 'weekly' } }, session: set_session_user
72
+
73
+ assert_equal 'weekly', assigns(:scc_account).interval
74
+ end
75
+
76
+ test 'SCC server sync products' do
77
+ stub_custom_request('https://scc.example.com/connect/organizations/products')
78
+ stub_custom_request('https://scc.example.com/connect/organizations/repositories')
79
+
80
+ account = scc_accounts(:one)
81
+ assert account
82
+ put :sync, params: { :id => account.id }, session: set_session_user
83
+ assert_redirected_to '/scc_accounts'
84
+ end
85
+
86
+ test 'SCC server bulk subscribe products' do
87
+ stub_custom_request('https://scc.example.com/connect/organizations/repositories')
88
+
89
+ account = scc_accounts(:one)
90
+ product1 = scc_products(:one)
91
+ product2 = scc_products(:two)
92
+ account.scc_products = [product1, product2]
93
+ put :bulk_subscribe, params: { :id => account.id, :scc_account => { :scc_subscribe_product_ids => [product1.id, product2.id] } }, session: set_session_user
94
+
95
+ assert_redirected_to '/scc_accounts'
96
+ end
97
+
98
+ test 'should delete scc_account' do
99
+ account = scc_accounts(:two)
100
+ assert_difference 'SccAccount.count', -1 do
101
+ delete :destroy, params: { :id => account.id }, session: set_session_user
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,51 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class SccAccountsControllerTest2 < ActionDispatch::IntegrationTest
4
+ setup do
5
+ @scc_account = scc_accounts(:one)
6
+ end
7
+
8
+ test 'should get index' do
9
+ get scc_accounts_url, session: set_session_user
10
+ # post path, params: { :id => "#{taxonomies(:empty_organization).id}-#{taxonomies(:empty_organization).name}" }
11
+ # post path, params: {:toState => scc_accounts_url, :bastion_page => "select_organization"}
12
+ # follow_redirect!
13
+ assert_response :success
14
+ end
15
+
16
+ test 'should get new' do
17
+ get new_scc_account_url
18
+ assert_response :success
19
+ end
20
+
21
+ test 'should create scc_account' do
22
+ assert_difference('SccAccount.count') do
23
+ post scc_accounts_url, params: { scc_account: {} }
24
+ end
25
+
26
+ assert_redirected_to scc_account_url(SccAccount.last)
27
+ end
28
+
29
+ test 'should show scc_account' do
30
+ get scc_account_url(@scc_account)
31
+ assert_response :success
32
+ end
33
+
34
+ test 'should get edit' do
35
+ get edit_scc_account_url(@scc_account)
36
+ assert_response :success
37
+ end
38
+
39
+ test 'should update scc_account' do
40
+ patch scc_account_url(@scc_account), params: { scc_account: {} }
41
+ assert_redirected_to scc_account_url(@scc_account)
42
+ end
43
+
44
+ test 'should destroy scc_account' do
45
+ assert_difference('SccAccount.count', -1) do
46
+ delete scc_account_url(@scc_account)
47
+ end
48
+
49
+ assert_redirected_to scc_accounts_url
50
+ end
51
+ end