foreman_scc_manager 1.8.6 → 1.8.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -1
  3. data/app/controllers/api/v2/scc_accounts_controller.rb +1 -1
  4. data/app/controllers/scc_accounts_controller.rb +1 -1
  5. data/app/lib/actions/scc_manager/subscribe_product.rb +19 -7
  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 +57 -10
  10. data/app/models/scc_repository.rb +7 -9
  11. data/app/views/scc_accounts/show.html.erb +5 -0
  12. data/db/migrate/20210205082733_add_subscription_valid_to_scc_products_and_repos.rb +6 -0
  13. data/db/migrate/20210210104407_add_root_repository_id_to_scc_repository.rb +6 -0
  14. data/db/migrate/20210224095050_connect_katello_root_repository_to_scc_repository.rb +28 -0
  15. data/db/migrate/20210713092440_add_permissions.rb +19 -0
  16. data/lib/foreman_scc_manager/engine.rb +4 -2
  17. data/lib/foreman_scc_manager/version.rb +1 -1
  18. data/locale/de/LC_MESSAGES/foreman_scc_manager.mo +0 -0
  19. data/locale/de/foreman_scc_manager.edit.po +574 -0
  20. data/locale/de/foreman_scc_manager.po +40 -21
  21. data/locale/de/foreman_scc_manager.po.time_stamp +0 -0
  22. data/locale/en/foreman_scc_manager.edit.po +566 -0
  23. data/locale/en/foreman_scc_manager.po +21 -3
  24. data/locale/en/foreman_scc_manager.po.time_stamp +0 -0
  25. data/locale/foreman_scc_manager.pot +62 -43
  26. data/test/controllers/api/v2/scc_accounts_test.rb +46 -1
  27. data/test/controllers/scc_accounts_controller_test.rb +51 -1
  28. data/test/fixtures/models/scc_accounts.yml +2 -0
  29. data/test/fixtures/models/scc_products.yml +4 -0
  30. data/test/models/scc_account_test.rb +6 -0
  31. data/test/unit/access_permissions_test.rb +16 -0
  32. metadata +12 -2
@@ -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,41 +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:22
196
- msgid "Use GPG key for SUSE products"
199
+ #: ../app/views/scc_accounts/_form.html.erb:19
200
+ msgid "Sync Date"
197
201
  msgstr ""
198
202
 
199
- #: ../app/views/scc_accounts/_form.html.erb:22
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."
203
+ #: ../app/views/scc_accounts/_form.html.erb:23
204
+ msgid "None"
201
205
  msgstr ""
202
206
 
203
- #: ../app/views/scc_accounts/_form.html.erb:18
204
- msgid "Sync Date"
207
+ #: ../app/views/scc_accounts/_form.html.erb:24
208
+ msgid "Use GPG key for SUSE products"
205
209
  msgstr ""
206
210
 
207
- #: ../app/views/scc_accounts/_form.html.erb:25
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
208
219
  msgid "Test Connection"
209
220
  msgstr ""
210
221
 
@@ -248,15 +259,23 @@ msgstr ""
248
259
  msgid "Add SUSE Customer Center Account"
249
260
  msgstr ""
250
261
 
251
- #: ../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
252
271
  msgid "SUSE Customer Center"
253
272
  msgstr ""
254
273
 
255
- #: ../app/views/scc_accounts/show.html.erb:36
274
+ #: ../app/views/scc_accounts/show.html.erb:44
256
275
  msgid "Please sync your SUSE subscriptions first."
257
276
  msgstr ""
258
277
 
259
- #: ../lib/foreman_scc_manager/engine.rb:66
278
+ #: ../lib/foreman_scc_manager/engine.rb:77
260
279
  msgid "SUSE Subscriptions"
261
280
  msgstr ""
262
281
 
@@ -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
@@ -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 'weekly', assigns(:scc_account).interval
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