decidim-generators 0.26.10 → 0.27.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +364 -373
- data/exe/decidim +28 -1
- data/lib/decidim/generators/app_generator.rb +124 -13
- data/lib/decidim/generators/app_templates/database.yml.erb +1 -1
- data/lib/decidim/generators/app_templates/dummy_authorization_handler.rb +1 -1
- data/lib/decidim/generators/app_templates/initializer.rb +214 -26
- data/lib/decidim/generators/app_templates/secrets.yml.erb +133 -14
- data/lib/decidim/generators/app_templates/sidekiq.yml.erb +15 -0
- data/lib/decidim/generators/app_templates/storage.yml.erb +42 -0
- data/lib/decidim/generators/component_templates/Gemfile.erb +2 -2
- data/lib/decidim/generators/component_templates/decidim-component.gemspec.erb +1 -1
- data/lib/decidim/generators/install_generator.rb +7 -0
- data/lib/decidim/generators/test/generator_examples.rb +1073 -0
- data/lib/decidim/generators/version.rb +1 -1
- metadata +13 -11
- data/lib/decidim/generators/app_templates/config/boot.rb.tt +0 -16
@@ -0,0 +1,1073 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
shared_examples_for "a new production application" do
|
4
|
+
it "includes optional plugins commented out in Gemfile" do
|
5
|
+
expect(result[1]).to be_success, result[0]
|
6
|
+
|
7
|
+
expect(File.read("#{test_app}/Gemfile"))
|
8
|
+
.to match(/^# gem "decidim-initiatives"/)
|
9
|
+
.and match(/^# gem "decidim-consultations"/)
|
10
|
+
.and match(/^# gem "decidim-elections"/)
|
11
|
+
.and match(/^# gem "decidim-conferences"/)
|
12
|
+
.and match(/^# gem "decidim-templates"/)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
shared_examples_for "a new development application" do
|
17
|
+
it "includes optional plugins uncommented in Gemfile" do
|
18
|
+
expect(result[1]).to be_success, result[0]
|
19
|
+
|
20
|
+
expect(File.read("#{test_app}/Gemfile"))
|
21
|
+
.to match(/^gem "decidim-initiatives"/)
|
22
|
+
.and match(/^gem "decidim-consultations"/)
|
23
|
+
.and match(/^gem "decidim-elections"/)
|
24
|
+
.and match(/^gem "decidim-conferences"/)
|
25
|
+
.and match(/^gem "decidim-templates"/)
|
26
|
+
|
27
|
+
# Checks that every table from a migration is included in the generated schema
|
28
|
+
schema = File.read("#{test_app}/db/schema.rb")
|
29
|
+
tables = []
|
30
|
+
dropped = []
|
31
|
+
Decidim::GemManager.plugins.each do |plugin|
|
32
|
+
Dir.glob("#{plugin}db/migrate/*.rb").each do |migration|
|
33
|
+
lines = File.readlines(migration)
|
34
|
+
tables.concat(lines.filter { |line| line.match? "create_table" }.map { |line| line.match(/(:)([a-z_0-9]+)/)[2] })
|
35
|
+
dropped.concat(lines.filter { |line| line.match? "drop_table" }.map { |line| line.match(/(:)([a-z_0-9]+)/)[2] })
|
36
|
+
tables.concat(lines.filter { |line| line.match? "rename_table" }.map { |line| line.match(/(, :)([a-z_0-9]+)/)[2] })
|
37
|
+
dropped.concat(lines.filter { |line| line.match? "rename_table" }.map { |line| line.match(/(:)([a-z_0-9]+)/)[2] })
|
38
|
+
end
|
39
|
+
end
|
40
|
+
tables.each do |table|
|
41
|
+
next if dropped.include? table
|
42
|
+
|
43
|
+
expect(schema).to match(/create_table "#{table}"|create_table :#{table}/)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Check that important node modules were installed
|
47
|
+
expect(Pathname.new("#{test_app}/node_modules/@rails/webpacker")).to be_directory
|
48
|
+
|
49
|
+
# Check that the configuration tweaks are applied properly
|
50
|
+
expect(File.read("#{test_app}/config/spring.rb")).to match(%r{^require "decidim/spring"})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
shared_context "with application env vars" do
|
55
|
+
# ensure that empty env behave like non-defined envs
|
56
|
+
let(:env_off) do
|
57
|
+
{
|
58
|
+
"RAILS_ENV" => "production",
|
59
|
+
"OMNIAUTH_FACEBOOK_APP_ID" => "",
|
60
|
+
"OMNIAUTH_FACEBOOK_APP_SECRET" => "",
|
61
|
+
"OMNIAUTH_TWITTER_API_KEY" => "",
|
62
|
+
"OMNIAUTH_TWITTER_API_SECRET" => "",
|
63
|
+
"OMNIAUTH_GOOGLE_CLIENT_ID" => "",
|
64
|
+
"OMNIAUTH_GOOGLE_CLIENT_SECRET" => "",
|
65
|
+
"MAPS_API_KEY" => "",
|
66
|
+
"ETHERPAD_SERVER" => "",
|
67
|
+
"ETHERPAD_API_KEY" => "",
|
68
|
+
"DECIDIM_APPLICATION_NAME" => "",
|
69
|
+
"DECIDIM_MAILER_SENDER" => "",
|
70
|
+
"DECIDIM_AVAILABLE_LOCALES" => "",
|
71
|
+
"DECIDIM_DEFAULT_LOCALE" => "",
|
72
|
+
"DECIDIM_ENABLE_HTML_HEADER_SNIPPETS" => "",
|
73
|
+
"DECIDIM_CURRENCY_UNIT" => "",
|
74
|
+
"DECIDIM_IMAGE_UPLOADER_QUALITY" => "",
|
75
|
+
"DECIDIM_MAXIMUM_ATTACHMENT_SIZE" => "",
|
76
|
+
"DECIDIM_MAXIMUM_AVATAR_SIZE" => "",
|
77
|
+
"DECIDIM_MAX_REPORTS_BEFORE_HIDING" => "",
|
78
|
+
"DECIDIM_THROTTLING_MAX_REQUESTS" => "",
|
79
|
+
"DECIDIM_THROTTLING_PERIOD" => "",
|
80
|
+
"DECIDIM_UNCONFIRMED_ACCESS_FOR" => "",
|
81
|
+
"DECIDIM_SYSTEM_ACCESSLIST_IPS" => "",
|
82
|
+
"DECIDIM_BASE_UPLOADS_PATH" => "",
|
83
|
+
"DECIDIM_DEFAULT_CSV_COL_SEP" => "",
|
84
|
+
"DECIDIM_CORS_ENABLED" => "",
|
85
|
+
"DECIDIM_ADMIN_PASSWORD_EXPIRATION_DAYS" => "",
|
86
|
+
"DECIDIM_ADMIN_PASSWORD_MIN_LENGTH" => "",
|
87
|
+
"DECIDIM_ADMIN_PASSWORD_REPETITION_TIMES" => "",
|
88
|
+
"DECIDIM_ADMIN_PASSWORD_STRONG" => "",
|
89
|
+
"DECIDIM_SERVICE_WORKER_ENABLED" => "",
|
90
|
+
"RAILS_LOG_LEVEL" => "nonsense",
|
91
|
+
"STORAGE_PROVIDER" => ""
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
let(:env_false) do
|
96
|
+
{
|
97
|
+
"RAILS_ENV" => "production",
|
98
|
+
"OMNIAUTH_FACEBOOK_APP_ID" => "false",
|
99
|
+
"OMNIAUTH_FACEBOOK_APP_SECRET" => "false",
|
100
|
+
"OMNIAUTH_TWITTER_API_KEY" => "no",
|
101
|
+
"OMNIAUTH_TWITTER_API_SECRET" => "false",
|
102
|
+
"OMNIAUTH_GOOGLE_CLIENT_ID" => "FalSe",
|
103
|
+
"OMNIAUTH_GOOGLE_CLIENT_SECRET" => "false",
|
104
|
+
"MAPS_API_KEY" => "0",
|
105
|
+
"ETHERPAD_SERVER" => "No",
|
106
|
+
"ETHERPAD_API_KEY" => "false",
|
107
|
+
"DECIDIM_AVAILABLE_LOCALES" => "false",
|
108
|
+
"DECIDIM_DEFAULT_LOCALE" => "false",
|
109
|
+
"DECIDIM_ENABLE_HTML_HEADER_SNIPPETS" => "FalSe",
|
110
|
+
"DECIDIM_CURRENCY_UNIT" => "false",
|
111
|
+
"DECIDIM_IMAGE_UPLOADER_QUALITY" => "false",
|
112
|
+
"DECIDIM_MAXIMUM_ATTACHMENT_SIZE" => "false",
|
113
|
+
"DECIDIM_MAXIMUM_AVATAR_SIZE" => "false",
|
114
|
+
"DECIDIM_MAX_REPORTS_BEFORE_HIDING" => "false",
|
115
|
+
"DECIDIM_THROTTLING_MAX_REQUESTS" => "false",
|
116
|
+
"DECIDIM_THROTTLING_PERIOD" => "false",
|
117
|
+
"DECIDIM_UNCONFIRMED_ACCESS_FOR" => "false",
|
118
|
+
"DECIDIM_SYSTEM_ACCESSLIST_IPS" => "false",
|
119
|
+
"DECIDIM_CORS_ENABLED" => "false",
|
120
|
+
"DECIDIM_SERVICE_WORKER_ENABLED" => "false"
|
121
|
+
}
|
122
|
+
end
|
123
|
+
|
124
|
+
let(:env_on) do
|
125
|
+
{
|
126
|
+
"RAILS_ENV" => "production",
|
127
|
+
"OMNIAUTH_FACEBOOK_APP_ID" => "a-facebook-id",
|
128
|
+
"OMNIAUTH_FACEBOOK_APP_SECRET" => "a-facebook-secret",
|
129
|
+
"OMNIAUTH_TWITTER_API_KEY" => "a-twitter-api-key",
|
130
|
+
"OMNIAUTH_TWITTER_API_SECRET" => "a-twitter-api-secret",
|
131
|
+
"OMNIAUTH_GOOGLE_CLIENT_ID" => "a-google-client-id",
|
132
|
+
"OMNIAUTH_GOOGLE_CLIENT_SECRET" => "a-google-client-secret",
|
133
|
+
"SECRET_KEY_BASE" => "a-secret-key-base",
|
134
|
+
"SMTP_USERNAME" => "a-smtp-username",
|
135
|
+
"SMTP_PASSWORD" => "a-smtp-password",
|
136
|
+
"SMTP_ADDRESS" => "a-smtp-address",
|
137
|
+
"SMTP_DOMAIN" => "a-smtp-domain",
|
138
|
+
"SMTP_PORT" => "12345",
|
139
|
+
"SMTP_STARTTLS_AUTO" => "a-smtp-starttls-auto",
|
140
|
+
"SMTP_AUTHENTICATION" => "a-smtp-authentication",
|
141
|
+
"DECIDIM_APPLICATION_NAME" => "\"A test\" {application}",
|
142
|
+
"DECIDIM_MAILER_SENDER" => "noreply@example.org",
|
143
|
+
"DECIDIM_AVAILABLE_LOCALES" => "de, fr, zh-CN",
|
144
|
+
"DECIDIM_DEFAULT_LOCALE" => "zh-CN",
|
145
|
+
"DECIDIM_FORCE_SSL" => "",
|
146
|
+
"DECIDIM_ENABLE_HTML_HEADER_SNIPPETS" => "true",
|
147
|
+
"DECIDIM_CURRENCY_UNIT" => "$",
|
148
|
+
"DECIDIM_IMAGE_UPLOADER_QUALITY" => "91",
|
149
|
+
"DECIDIM_MAXIMUM_ATTACHMENT_SIZE" => "25",
|
150
|
+
"DECIDIM_MAXIMUM_AVATAR_SIZE" => "11",
|
151
|
+
"DECIDIM_MAX_REPORTS_BEFORE_HIDING" => "4",
|
152
|
+
"DECIDIM_TRACK_NEWSLETTER_LINKS" => "",
|
153
|
+
"DECIDIM_DOWNLOAD_YOUR_DATA_EXPIRY_TIME" => "2",
|
154
|
+
"DECIDIM_THROTTLING_MAX_REQUESTS" => "99",
|
155
|
+
"DECIDIM_THROTTLING_PERIOD" => "2",
|
156
|
+
"DECIDIM_UNCONFIRMED_ACCESS_FOR" => "3",
|
157
|
+
"DECIDIM_SYSTEM_ACCESSLIST_IPS" => "127.0.0.1,172.26.0.1/24",
|
158
|
+
"DECIDIM_BASE_UPLOADS_PATH" => "some-path/",
|
159
|
+
"DECIDIM_DEFAULT_CSV_COL_SEP" => ",",
|
160
|
+
"DECIDIM_CORS_ENABLED" => "true",
|
161
|
+
"DECIDIM_SERVICE_WORKER_ENABLED" => "true",
|
162
|
+
"DECIDIM_CONSENT_COOKIE_NAME" => ":weird-consent-cookie-name:",
|
163
|
+
"DECIDIM_CACHE_KEY_SEPARATOR" => ":",
|
164
|
+
"DECIDIM_EXPIRE_SESSION_AFTER" => "45",
|
165
|
+
"DECIDIM_ENABLE_REMEMBER_ME" => "",
|
166
|
+
"DECIDIM_SESSION_TIMEOUT_INTERVAL" => "33",
|
167
|
+
"DECIDIM_FOLLOW_HTTP_X_FORWARDED_HOST" => "true",
|
168
|
+
"DECIDIM_MAXIMUM_CONVERSATION_MESSAGE_LENGTH" => "1234",
|
169
|
+
"DECIDIM_PASSWORD_BLACKLIST" => "i-dont-like-this-password, i-dont,like,this,one,either, password123456",
|
170
|
+
"DECIDIM_ALLOW_OPEN_REDIRECTS" => "true",
|
171
|
+
"DECIDIM_ADMIN_PASSWORD_EXPIRATION_DAYS" => "93",
|
172
|
+
"DECIDIM_ADMIN_PASSWORD_MIN_LENGTH" => "18",
|
173
|
+
"DECIDIM_ADMIN_PASSWORD_REPETITION_TIMES" => "8",
|
174
|
+
"DECIDIM_ADMIN_PASSWORD_STRONG" => "false",
|
175
|
+
"RAILS_LOG_LEVEL" => "fatal",
|
176
|
+
"RAILS_ASSET_HOST" => "http://assets.example.org",
|
177
|
+
"ETHERPAD_SERVER" => "http://a-etherpad-server.com",
|
178
|
+
"ETHERPAD_API_KEY" => "an-etherpad-key",
|
179
|
+
"ETHERPAD_API_VERSION" => "1.2.2",
|
180
|
+
"MAPS_PROVIDER" => "here",
|
181
|
+
"MAPS_API_KEY" => "a-maps-api-key",
|
182
|
+
"VAPID_PUBLIC_KEY" => "a-vapid-public-key",
|
183
|
+
"VAPID_PRIVATE_KEY" => "a-vapid-private-key",
|
184
|
+
"STORAGE_PROVIDER" => "test",
|
185
|
+
"STORAGE_CDN_HOST" => "https://cdn.example.org",
|
186
|
+
"API_SCHEMA_MAX_PER_PAGE" => "31",
|
187
|
+
"API_SCHEMA_MAX_COMPLEXITY" => "3001",
|
188
|
+
"API_SCHEMA_MAX_DEPTH" => "11",
|
189
|
+
"PROPOSALS_SIMILARITY_THRESHOLD" => "0.99",
|
190
|
+
"PROPOSALS_SIMILARITY_LIMIT" => "3",
|
191
|
+
"PROPOSALS_PARTICIPATORY_SPACE_HIGHLIGHTED_PROPOSALS_LIMIT" => "6",
|
192
|
+
"PROPOSALS_PROCESS_GROUP_HIGHLIGHTED_PROPOSALS_LIMIT" => "5",
|
193
|
+
"MEETINGS_UPCOMING_MEETING_NOTIFICATION" => "3",
|
194
|
+
"MEETINGS_ENABLE_PROPOSAL_LINKING" => "false",
|
195
|
+
"MEETINGS_EMBEDDABLE_SERVICES" => "www.youtube.com www.twitch.tv meet.jit.si 8x8.vc",
|
196
|
+
"BUDGETS_ENABLE_PROPOSAL_LINKING" => "false",
|
197
|
+
"ACCOUNTABILITY_ENABLE_PROPOSAL_LINKING" => "false",
|
198
|
+
"CONSULTATIONS_STATS_CACHE_EXPIRATION_TIME" => "7",
|
199
|
+
"INITIATIVES_CREATION_ENABLED" => "false",
|
200
|
+
"INITIATIVES_SIMILARITY_THRESHOLD" => "0.99",
|
201
|
+
"INITIATIVES_SIMILARITY_LIMIT" => "10",
|
202
|
+
"INITIATIVES_MINIMUM_COMMITTEE_MEMBERS" => "3",
|
203
|
+
"INITIATIVES_DEFAULT_SIGNATURE_TIME_PERIOD_LENGTH" => "133",
|
204
|
+
"INITIATIVES_DEFAULT_COMPONENTS" => "pages, proposals,budgets",
|
205
|
+
"INITIATIVES_FIRST_NOTIFICATION_PERCENTAGE" => "10",
|
206
|
+
"INITIATIVES_SECOND_NOTIFICATION_PERCENTAGE" => "70",
|
207
|
+
"INITIATIVES_STATS_CACHE_EXPIRATION_TIME" => "7",
|
208
|
+
"INITIATIVES_MAX_TIME_IN_VALIDATING_STATE" => "50",
|
209
|
+
"INITIATIVES_PRINT_ENABLED" => "false",
|
210
|
+
"INITIATIVES_DO_NOT_REQUIRE_AUTHORIZATION" => "true",
|
211
|
+
"BULLETIN_BOARD_SERVER" => "a-bulletin-board-server",
|
212
|
+
"BULLETIN_BOARD_PUBLIC_KEY" => "a-bulletin-public-key",
|
213
|
+
"BULLETIN_BOARD_API_KEY" => "an-authority-api-key",
|
214
|
+
"AUTHORITY_NAME" => "an-authority-name",
|
215
|
+
"AUTHORITY_PRIVATE_KEY" => "an-authority-private-key",
|
216
|
+
"ELECTIONS_SCHEME_NAME" => "an-elections-scheme-name",
|
217
|
+
"ELECTIONS_NUMBER_OF_TRUSTEES" => "345",
|
218
|
+
"ELECTIONS_QUORUM" => "987",
|
219
|
+
"ELECTIONS_SETUP_MINIMUM_HOURS_BEFORE_START" => "4",
|
220
|
+
"ELECTIONS_START_VOTE_MAXIMUM_HOURS_BEFORE_START" => "7",
|
221
|
+
"ELECTIONS_VOTER_TOKEN_EXPIRATION_MINUTES" => "123",
|
222
|
+
"VOTINGS_CHECK_CENSUS_MAX_REQUESTS" => "6",
|
223
|
+
"VOTINGS_THROTTLING_PERIOD" => "2",
|
224
|
+
"VOTINGS_CENSUS_ACCESS_CODES_EXPORT_EXPIRY_TIME" => "3"
|
225
|
+
}
|
226
|
+
end
|
227
|
+
|
228
|
+
let(:env_maps_osm) do
|
229
|
+
{
|
230
|
+
"RAILS_ENV" => "production",
|
231
|
+
"MAPS_PROVIDER" => "osm",
|
232
|
+
"MAPS_API_KEY" => "another-maps-api-key",
|
233
|
+
"MAPS_DYNAMIC_URL" => "https://tiles.example.org/{z}/{x}/{y}.png?key={apiKey}&{foo}",
|
234
|
+
"MAPS_STATIC_URL" => "https://staticmap.example.org/",
|
235
|
+
"MAPS_ATTRIBUTION" => '<a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap</a> contributors',
|
236
|
+
"MAPS_GEOCODING_HOST" => "nominatim.example.org"
|
237
|
+
}
|
238
|
+
end
|
239
|
+
|
240
|
+
let(:env_maps_mix) do
|
241
|
+
{
|
242
|
+
"RAILS_ENV" => "production",
|
243
|
+
"MAPS_STATIC_PROVIDER" => "here",
|
244
|
+
"MAPS_DYNAMIC_PROVIDER" => "osm",
|
245
|
+
"MAPS_STATIC_API_KEY" => "a-maps-api-key",
|
246
|
+
"MAPS_DYNAMIC_API_KEY" => "another-maps-api-key",
|
247
|
+
"MAPS_DYNAMIC_URL" => "https://tiles.example.org/{z}/{x}/{y}.png?key={apiKey}&{foo}",
|
248
|
+
"MAPS_ATTRIBUTION" => '<a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap</a> contributors',
|
249
|
+
"MAPS_GEOCODING_HOST" => "nominatim.example.org",
|
250
|
+
"MAPS_EXTRA_VARS" => URI.encode_www_form({ api_key: true, num: 123, foo: "bar=baz" })
|
251
|
+
}
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
shared_examples_for "an application with configurable env vars" do
|
256
|
+
include_context "with application env vars"
|
257
|
+
|
258
|
+
let(:secrets_off) do
|
259
|
+
{
|
260
|
+
%w(omniauth facebook enabled) => false,
|
261
|
+
%w(omniauth twitter enabled) => false,
|
262
|
+
%w(omniauth google_oauth2 enabled) => false,
|
263
|
+
%w(decidim application_name) => "My Application Name",
|
264
|
+
%w(decidim mailer_sender) => "change-me@example.org",
|
265
|
+
%w(decidim available_locales) => %w(ca cs de en es eu fi fr it ja nl pl pt ro),
|
266
|
+
%w(decidim default_locale) => "en",
|
267
|
+
%w(decidim force_ssl) => "auto",
|
268
|
+
%w(decidim enable_html_header_snippets) => false,
|
269
|
+
%w(decidim currency_unit) => "€",
|
270
|
+
%w(decidim image_uploader_quality) => 80,
|
271
|
+
%w(decidim maximum_attachment_size) => 10,
|
272
|
+
%w(decidim maximum_avatar_size) => 5,
|
273
|
+
%w(decidim max_reports_before_hiding) => 3,
|
274
|
+
%w(decidim track_newsletter_links) => "auto",
|
275
|
+
%w(decidim download_your_data_expiry_time) => 7,
|
276
|
+
%w(decidim throttling_max_requests) => 100,
|
277
|
+
%w(decidim throttling_period) => 1,
|
278
|
+
%w(decidim unconfirmed_access_for) => 0,
|
279
|
+
%w(decidim system_accesslist_ips) => [],
|
280
|
+
%w(decidim base_uploads_path) => nil,
|
281
|
+
%w(decidim default_csv_col_sep) => ";",
|
282
|
+
%w(decidim cors_enabled) => false,
|
283
|
+
%w(decidim service_worker_enabled) => true,
|
284
|
+
%w(decidim consent_cookie_name) => "decidim-consent",
|
285
|
+
%w(decidim cache_key_separator) => "/",
|
286
|
+
%w(decidim expire_session_after) => 30,
|
287
|
+
%w(decidim enable_remember_me) => "auto",
|
288
|
+
%w(decidim session_timeout_interval) => 10,
|
289
|
+
%w(decidim follow_http_x_forwarded_host) => false,
|
290
|
+
%w(decidim maximum_conversation_message_length) => 1000,
|
291
|
+
%w(decidim password_blacklist) => [],
|
292
|
+
%w(decidim allow_open_redirects) => false,
|
293
|
+
%w(decidim admin_password expiration_days) => 90,
|
294
|
+
%w(decidim admin_password min_length) => 15,
|
295
|
+
%w(decidim admin_password repetition_times) => 5,
|
296
|
+
%w(decidim admin_password strong) => true,
|
297
|
+
%w(etherpad server) => nil,
|
298
|
+
%w(etherpad api_key) => nil,
|
299
|
+
%w(etherpad api_version) => "1.2.1",
|
300
|
+
%w(maps dynamic_provider) => nil,
|
301
|
+
%w(maps static_provider) => nil,
|
302
|
+
%w(maps static_api_key) => nil,
|
303
|
+
%w(maps dynamic_api_key) => nil,
|
304
|
+
%w(maps static_url) => nil,
|
305
|
+
%w(maps dynamic_url) => nil,
|
306
|
+
%w(maps attribution) => nil,
|
307
|
+
%w(maps extra_vars) => nil,
|
308
|
+
%w(maps geocoding_host) => nil,
|
309
|
+
%w(vapid enabled) => false,
|
310
|
+
%w(vapid public_key) => nil,
|
311
|
+
%w(vapid private_key) => nil,
|
312
|
+
%w(storage provider) => "local",
|
313
|
+
%w(storage cdn_host) => nil,
|
314
|
+
%w(decidim api schema_max_per_page) => 50,
|
315
|
+
%w(decidim api schema_max_complexity) => 5000,
|
316
|
+
%w(decidim api schema_max_depth) => 15,
|
317
|
+
%w(decidim proposals similarity_threshold) => 0.25,
|
318
|
+
%w(decidim proposals similarity_limit) => 10,
|
319
|
+
%w(decidim proposals participatory_space_highlighted_proposals_limit) => 4,
|
320
|
+
%w(decidim proposals process_group_highlighted_proposals_limit) => 3,
|
321
|
+
%w(decidim meetings upcoming_meeting_notification) => 2,
|
322
|
+
%w(decidim meetings enable_proposal_linking) => "auto",
|
323
|
+
%w(decidim meetings embeddable_services) => [],
|
324
|
+
%w(decidim budgets enable_proposal_linking) => "auto",
|
325
|
+
%w(decidim accountability enable_proposal_linking) => "auto",
|
326
|
+
%w(decidim consultations stats_cache_expiration_time) => 5,
|
327
|
+
%w(decidim initiatives creation_enabled) => "auto",
|
328
|
+
%w(decidim initiatives similarity_threshold) => 0.25,
|
329
|
+
%w(decidim initiatives similarity_limit) => 5,
|
330
|
+
%w(decidim initiatives minimum_committee_members) => 2,
|
331
|
+
%w(decidim initiatives default_signature_time_period_length) => 120,
|
332
|
+
%w(decidim initiatives default_components) => %w(pages meetings),
|
333
|
+
%w(decidim initiatives first_notification_percentage) => 33,
|
334
|
+
%w(decidim initiatives second_notification_percentage) => 66,
|
335
|
+
%w(decidim initiatives stats_cache_expiration_time) => 5,
|
336
|
+
%w(decidim initiatives max_time_in_validating_state) => 60,
|
337
|
+
%w(decidim initiatives print_enabled) => "auto",
|
338
|
+
%w(decidim initiatives do_not_require_authorization) => false,
|
339
|
+
%w(elections setup_minimum_hours_before_start) => 3,
|
340
|
+
%w(elections start_vote_maximum_hours_before_start) => 6,
|
341
|
+
%w(elections voter_token_expiration_minutes) => 120,
|
342
|
+
%w(elections votings check_census_max_requests) => 5,
|
343
|
+
%w(elections votings throttling_period) => 1,
|
344
|
+
%w(elections votings census access_codes_export_expiry_time) => 2
|
345
|
+
}
|
346
|
+
end
|
347
|
+
|
348
|
+
let(:secrets_on) do
|
349
|
+
{
|
350
|
+
%w(omniauth facebook enabled) => true,
|
351
|
+
%w(omniauth facebook app_id) => "a-facebook-id",
|
352
|
+
%w(omniauth facebook app_secret) => "a-facebook-secret",
|
353
|
+
%w(omniauth twitter enabled) => true,
|
354
|
+
%w(omniauth twitter api_key) => "a-twitter-api-key",
|
355
|
+
%w(omniauth twitter api_secret) => "a-twitter-api-secret",
|
356
|
+
%w(omniauth google_oauth2 enabled) => true,
|
357
|
+
%w(omniauth google_oauth2 client_id) => "a-google-client-id",
|
358
|
+
%w(omniauth google_oauth2 client_secret) => "a-google-client-secret",
|
359
|
+
%w(secret_key_base) => "a-secret-key-base",
|
360
|
+
%w(smtp_username) => "a-smtp-username",
|
361
|
+
%w(smtp_password) => "a-smtp-password",
|
362
|
+
%w(smtp_address) => "a-smtp-address",
|
363
|
+
%w(smtp_domain) => "a-smtp-domain",
|
364
|
+
%w(smtp_port) => 12_345,
|
365
|
+
%w(smtp_starttls_auto) => true,
|
366
|
+
%w(smtp_authentication) => "a-smtp-authentication",
|
367
|
+
%w(decidim application_name) => "\"A test\" {application}",
|
368
|
+
%w(decidim mailer_sender) => "noreply@example.org",
|
369
|
+
%w(decidim available_locales) => %w(de fr zh-CN),
|
370
|
+
%w(decidim default_locale) => "zh-CN",
|
371
|
+
%w(decidim force_ssl) => false,
|
372
|
+
%w(decidim enable_html_header_snippets) => true,
|
373
|
+
%w(decidim currency_unit) => "$",
|
374
|
+
%w(decidim image_uploader_quality) => 91,
|
375
|
+
%w(decidim maximum_attachment_size) => 25,
|
376
|
+
%w(decidim maximum_avatar_size) => 11,
|
377
|
+
%w(decidim max_reports_before_hiding) => 4,
|
378
|
+
%w(decidim track_newsletter_links) => false,
|
379
|
+
%w(decidim download_your_data_expiry_time) => 2,
|
380
|
+
%w(decidim throttling_max_requests) => 99,
|
381
|
+
%w(decidim throttling_period) => 2,
|
382
|
+
%w(decidim unconfirmed_access_for) => 3,
|
383
|
+
%w(decidim system_accesslist_ips) => ["127.0.0.1", "172.26.0.1/24"],
|
384
|
+
%w(decidim base_uploads_path) => "some-path/",
|
385
|
+
%w(decidim default_csv_col_sep) => ",",
|
386
|
+
%w(decidim cors_enabled) => true,
|
387
|
+
%w(decidim service_worker_enabled) => true,
|
388
|
+
%w(decidim consent_cookie_name) => ":weird-consent-cookie-name:",
|
389
|
+
%w(decidim cache_key_separator) => ":",
|
390
|
+
%w(decidim expire_session_after) => 45,
|
391
|
+
%w(decidim enable_remember_me) => false,
|
392
|
+
%w(decidim session_timeout_interval) => 33,
|
393
|
+
%w(decidim follow_http_x_forwarded_host) => true,
|
394
|
+
%w(decidim maximum_conversation_message_length) => 1234,
|
395
|
+
%w(decidim password_blacklist) => ["i-dont-like-this-password", "i-dont,like,this,one,either", "password123456"],
|
396
|
+
%w(decidim allow_open_redirects) => true,
|
397
|
+
%w(decidim admin_password expiration_days) => 93,
|
398
|
+
%w(decidim admin_password min_length) => 18,
|
399
|
+
%w(decidim admin_password repetition_times) => 8,
|
400
|
+
%w(decidim admin_password strong) => false,
|
401
|
+
%w(etherpad server) => "http://a-etherpad-server.com",
|
402
|
+
%w(etherpad api_key) => "an-etherpad-key",
|
403
|
+
%w(etherpad api_version) => "1.2.2",
|
404
|
+
%w(maps dynamic_provider) => "here",
|
405
|
+
%w(maps static_provider) => "here",
|
406
|
+
%w(maps static_api_key) => "a-maps-api-key",
|
407
|
+
%w(maps dynamic_api_key) => "a-maps-api-key",
|
408
|
+
%w(maps static_url) => nil,
|
409
|
+
%w(maps dynamic_url) => nil,
|
410
|
+
%w(maps attribution) => nil,
|
411
|
+
%w(maps extra_vars) => nil,
|
412
|
+
%w(maps geocoding_host) => nil,
|
413
|
+
%w(vapid enabled) => true,
|
414
|
+
%w(vapid public_key) => "a-vapid-public-key",
|
415
|
+
%w(vapid private_key) => "a-vapid-private-key",
|
416
|
+
%w(storage provider) => "test",
|
417
|
+
%w(storage cdn_host) => "https://cdn.example.org",
|
418
|
+
%w(decidim api schema_max_per_page) => 31,
|
419
|
+
%w(decidim api schema_max_complexity) => 3001,
|
420
|
+
%w(decidim api schema_max_depth) => 11,
|
421
|
+
%w(decidim proposals similarity_threshold) => 0.99,
|
422
|
+
%w(decidim proposals similarity_limit) => 3,
|
423
|
+
%w(decidim proposals participatory_space_highlighted_proposals_limit) => 6,
|
424
|
+
%w(decidim proposals process_group_highlighted_proposals_limit) => 5,
|
425
|
+
%w(decidim meetings upcoming_meeting_notification) => 3,
|
426
|
+
%w(decidim meetings enable_proposal_linking) => false,
|
427
|
+
%w(decidim meetings embeddable_services) => %w(www.youtube.com www.twitch.tv meet.jit.si 8x8.vc),
|
428
|
+
%w(decidim budgets enable_proposal_linking) => false,
|
429
|
+
%w(decidim accountability enable_proposal_linking) => false,
|
430
|
+
%w(decidim consultations stats_cache_expiration_time) => 7,
|
431
|
+
%w(decidim initiatives creation_enabled) => false,
|
432
|
+
%w(decidim initiatives similarity_threshold) => 0.99,
|
433
|
+
%w(decidim initiatives similarity_limit) => 10,
|
434
|
+
%w(decidim initiatives minimum_committee_members) => 3,
|
435
|
+
%w(decidim initiatives default_signature_time_period_length) => 133,
|
436
|
+
%w(decidim initiatives default_components) => %w(pages proposals budgets),
|
437
|
+
%w(decidim initiatives first_notification_percentage) => 10,
|
438
|
+
%w(decidim initiatives second_notification_percentage) => 70,
|
439
|
+
%w(decidim initiatives stats_cache_expiration_time) => 7,
|
440
|
+
%w(decidim initiatives max_time_in_validating_state) => 50,
|
441
|
+
%w(decidim initiatives print_enabled) => false,
|
442
|
+
%w(decidim initiatives do_not_require_authorization) => true,
|
443
|
+
%w(elections bulletin_board_server) => "a-bulletin-board-server",
|
444
|
+
%w(elections bulletin_board_public_key) => "a-bulletin-public-key",
|
445
|
+
%w(elections authority_api_key) => "an-authority-api-key",
|
446
|
+
%w(elections authority_name) => "an-authority-name",
|
447
|
+
%w(elections authority_private_key) => "an-authority-private-key",
|
448
|
+
%w(elections scheme_name) => "an-elections-scheme-name",
|
449
|
+
%w(elections number_of_trustees) => 345,
|
450
|
+
%w(elections quorum) => 987,
|
451
|
+
%w(elections setup_minimum_hours_before_start) => 4,
|
452
|
+
%w(elections start_vote_maximum_hours_before_start) => 7,
|
453
|
+
%w(elections voter_token_expiration_minutes) => 123,
|
454
|
+
%w(elections votings check_census_max_requests) => 6,
|
455
|
+
%w(elections votings throttling_period) => 2,
|
456
|
+
%w(elections votings census access_codes_export_expiry_time) => 3
|
457
|
+
}
|
458
|
+
end
|
459
|
+
|
460
|
+
let(:initializer_off) do
|
461
|
+
{
|
462
|
+
"application_name" => "My Application Name",
|
463
|
+
"mailer_sender" => "change-me@example.org",
|
464
|
+
"available_locales" => %w(ca cs de en es eu fi fr it ja nl pl pt ro),
|
465
|
+
"default_locale" => "en",
|
466
|
+
"force_ssl" => true,
|
467
|
+
"enable_html_header_snippets" => false,
|
468
|
+
"currency_unit" => "€",
|
469
|
+
"image_uploader_quality" => 80,
|
470
|
+
"maximum_attachment_size" => 10_485_760, # 10 megabytes
|
471
|
+
"maximum_avatar_size" => 5_242_880, # 5 megabytes
|
472
|
+
"max_reports_before_hiding" => 3,
|
473
|
+
"track_newsletter_links" => true,
|
474
|
+
"download_your_data_expiry_time" => 604_800, # 7 days
|
475
|
+
"throttling_max_requests" => 100,
|
476
|
+
"throttling_period" => 60, # 1 minute
|
477
|
+
"unconfirmed_access_for" => 0,
|
478
|
+
"system_accesslist_ips" => [],
|
479
|
+
"base_uploads_path" => nil,
|
480
|
+
"default_csv_col_sep" => ";",
|
481
|
+
"cors_enabled" => false,
|
482
|
+
"consent_cookie_name" => "decidim-consent",
|
483
|
+
"cache_key_separator" => "/",
|
484
|
+
"expire_session_after" => 1800, # 30 minutes
|
485
|
+
"enable_remember_me" => true,
|
486
|
+
"session_timeout_interval" => 10,
|
487
|
+
"follow_http_x_forwarded_host" => false,
|
488
|
+
"maximum_conversation_message_length" => 1000,
|
489
|
+
"password_blacklist" => [],
|
490
|
+
"allow_open_redirects" => false,
|
491
|
+
"etherpad" => nil,
|
492
|
+
"maps" => nil
|
493
|
+
}
|
494
|
+
end
|
495
|
+
|
496
|
+
let(:initializer_on) do
|
497
|
+
{
|
498
|
+
"application_name" => "\"A test\" {application}",
|
499
|
+
"mailer_sender" => "noreply@example.org",
|
500
|
+
"available_locales" => %w(de fr zh-CN),
|
501
|
+
"default_locale" => "zh-CN",
|
502
|
+
"force_ssl" => false,
|
503
|
+
"enable_html_header_snippets" => true,
|
504
|
+
"currency_unit" => "$",
|
505
|
+
"image_uploader_quality" => 91,
|
506
|
+
"maximum_attachment_size" => 26_214_400, # 25 megabytes
|
507
|
+
"maximum_avatar_size" => 11_534_336, # 11 megabytes
|
508
|
+
"max_reports_before_hiding" => 4,
|
509
|
+
"track_newsletter_links" => false,
|
510
|
+
"download_your_data_expiry_time" => 172_800, # 2 days
|
511
|
+
"throttling_max_requests" => 99,
|
512
|
+
"throttling_period" => 120, # 2 minutes
|
513
|
+
"unconfirmed_access_for" => 259_200, # 3 days
|
514
|
+
"system_accesslist_ips" => ["127.0.0.1", "172.26.0.1/24"],
|
515
|
+
"base_uploads_path" => "some-path/",
|
516
|
+
"default_csv_col_sep" => ",",
|
517
|
+
"cors_enabled" => true,
|
518
|
+
"consent_cookie_name" => ":weird-consent-cookie-name:",
|
519
|
+
"cache_key_separator" => ":",
|
520
|
+
"expire_session_after" => 2700, # 45 minutes
|
521
|
+
"enable_remember_me" => false,
|
522
|
+
"session_timeout_interval" => 33,
|
523
|
+
"follow_http_x_forwarded_host" => true,
|
524
|
+
"maximum_conversation_message_length" => 1234,
|
525
|
+
"password_blacklist" => ["i-dont-like-this-password", "i-dont,like,this,one,either", "password123456"],
|
526
|
+
"allow_open_redirects" => true,
|
527
|
+
"etherpad" => {
|
528
|
+
"server" => "http://a-etherpad-server.com",
|
529
|
+
"api_key" => "an-etherpad-key",
|
530
|
+
"api_version" => "1.2.2"
|
531
|
+
},
|
532
|
+
"maps" => {
|
533
|
+
"provider" => "here",
|
534
|
+
"api_key" => "a-maps-api-key",
|
535
|
+
"static" => {
|
536
|
+
"url" => "https://image.maps.ls.hereapi.com/mia/1.6/mapview"
|
537
|
+
},
|
538
|
+
"dynamic" => {
|
539
|
+
"provider" => "here",
|
540
|
+
"api_key" => "a-maps-api-key",
|
541
|
+
"tile_layer" => {}
|
542
|
+
}
|
543
|
+
}
|
544
|
+
}
|
545
|
+
end
|
546
|
+
|
547
|
+
let(:initializer_maps_osm) do
|
548
|
+
{
|
549
|
+
"maps" => {
|
550
|
+
"provider" => "osm",
|
551
|
+
"api_key" => "another-maps-api-key",
|
552
|
+
"static" => {
|
553
|
+
"url" => "https://staticmap.example.org/"
|
554
|
+
},
|
555
|
+
"dynamic" => {
|
556
|
+
"provider" => "osm",
|
557
|
+
"api_key" => "another-maps-api-key",
|
558
|
+
"tile_layer" => {
|
559
|
+
"url" => "https://tiles.example.org/{z}/{x}/{y}.png?key={apiKey}&{foo}",
|
560
|
+
"attribution" => '<a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap</a> contributors'
|
561
|
+
}
|
562
|
+
},
|
563
|
+
"geocoding" => {
|
564
|
+
"host" => "nominatim.example.org",
|
565
|
+
"use_https" => true
|
566
|
+
}
|
567
|
+
}
|
568
|
+
}
|
569
|
+
end
|
570
|
+
|
571
|
+
let(:initializer_maps_mix) do
|
572
|
+
{
|
573
|
+
"maps" => {
|
574
|
+
"provider" => "here",
|
575
|
+
"api_key" => "a-maps-api-key",
|
576
|
+
"static" => {
|
577
|
+
"url" => "https://image.maps.ls.hereapi.com/mia/1.6/mapview"
|
578
|
+
},
|
579
|
+
"dynamic" => {
|
580
|
+
"provider" => "osm",
|
581
|
+
"api_key" => "another-maps-api-key",
|
582
|
+
"tile_layer" => {
|
583
|
+
"url" => "https://tiles.example.org/{z}/{x}/{y}.png?key={apiKey}&{foo}",
|
584
|
+
"attribution" => '<a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap</a> contributors',
|
585
|
+
"api_key" => true,
|
586
|
+
"num" => 123,
|
587
|
+
"foo" => "bar=baz"
|
588
|
+
}
|
589
|
+
},
|
590
|
+
"geocoding" => {
|
591
|
+
"host" => "nominatim.example.org",
|
592
|
+
"use_https" => true
|
593
|
+
}
|
594
|
+
}
|
595
|
+
}
|
596
|
+
end
|
597
|
+
|
598
|
+
let(:api_initializer_off) do
|
599
|
+
{
|
600
|
+
"schema_max_per_page" => 50,
|
601
|
+
"schema_max_complexity" => 5000,
|
602
|
+
"schema_max_depth" => 15
|
603
|
+
}
|
604
|
+
end
|
605
|
+
|
606
|
+
let(:api_initializer_on) do
|
607
|
+
{
|
608
|
+
"schema_max_per_page" => 31,
|
609
|
+
"schema_max_complexity" => 3001,
|
610
|
+
"schema_max_depth" => 11
|
611
|
+
}
|
612
|
+
end
|
613
|
+
|
614
|
+
let(:proposals_initializer_off) do
|
615
|
+
{
|
616
|
+
"similarity_threshold" => 0.25,
|
617
|
+
"similarity_limit" => 10,
|
618
|
+
"participatory_space_highlighted_proposals_limit" => 4,
|
619
|
+
"process_group_highlighted_proposals_limit" => 3
|
620
|
+
}
|
621
|
+
end
|
622
|
+
|
623
|
+
let(:proposals_initializer_on) do
|
624
|
+
{
|
625
|
+
"similarity_threshold" => 0.99,
|
626
|
+
"similarity_limit" => 3,
|
627
|
+
"participatory_space_highlighted_proposals_limit" => 6,
|
628
|
+
"process_group_highlighted_proposals_limit" => 5
|
629
|
+
}
|
630
|
+
end
|
631
|
+
|
632
|
+
let(:meetings_initializer_off) do
|
633
|
+
{
|
634
|
+
"upcoming_meeting_notification" => 172_800, # 2.days
|
635
|
+
"enable_proposal_linking" => true,
|
636
|
+
"embeddable_services" => %w(www.youtube.com www.twitch.tv meet.jit.si)
|
637
|
+
}
|
638
|
+
end
|
639
|
+
|
640
|
+
let(:meetings_initializer_on) do
|
641
|
+
{
|
642
|
+
"upcoming_meeting_notification" => 259_200, # 3.days
|
643
|
+
"enable_proposal_linking" => false,
|
644
|
+
"embeddable_services" => %w(www.youtube.com www.twitch.tv meet.jit.si 8x8.vc)
|
645
|
+
}
|
646
|
+
end
|
647
|
+
|
648
|
+
let(:budgets_initializer_off) do
|
649
|
+
{
|
650
|
+
"enable_proposal_linking" => true
|
651
|
+
}
|
652
|
+
end
|
653
|
+
|
654
|
+
let(:budgets_initializer_on) do
|
655
|
+
{
|
656
|
+
"enable_proposal_linking" => false
|
657
|
+
}
|
658
|
+
end
|
659
|
+
|
660
|
+
let(:accountability_initializer_off) do
|
661
|
+
{
|
662
|
+
"enable_proposal_linking" => true
|
663
|
+
}
|
664
|
+
end
|
665
|
+
|
666
|
+
let(:accountability_initializer_on) do
|
667
|
+
{
|
668
|
+
"enable_proposal_linking" => false
|
669
|
+
}
|
670
|
+
end
|
671
|
+
|
672
|
+
# The logs settings have changed between Rails 6.0 abd 6.1 and this may be here
|
673
|
+
# https://github.com/rails/rails/commit/73079940111e8b85bf87953e5ef9fafeece5b5da
|
674
|
+
let(:rails_off) do
|
675
|
+
{
|
676
|
+
"Rails.logger.level" => 1,
|
677
|
+
"Rails.application.config.log_level" => "info",
|
678
|
+
"Rails.application.config.action_controller.asset_host" => nil,
|
679
|
+
"Rails.application.config.active_storage.service" => "local",
|
680
|
+
"Decidim::EngineRouter.new(nil, {}).send(:configured_default_url_options)" => { "protocol" => "https" }
|
681
|
+
}
|
682
|
+
end
|
683
|
+
|
684
|
+
let(:rails_on) do
|
685
|
+
{
|
686
|
+
"Rails.logger.level" => 4,
|
687
|
+
"Rails.application.config.log_level" => "fatal",
|
688
|
+
"Rails.application.config.action_controller.asset_host" => "http://assets.example.org",
|
689
|
+
"Rails.application.config.active_storage.service" => "test",
|
690
|
+
"Decidim::AssetRouter.new(nil).send(:default_options)" => { "host" => "https://cdn.example.org" },
|
691
|
+
"Decidim::Api::Schema.default_max_page_size" => 31,
|
692
|
+
"Decidim::Api::Schema.max_complexity" => 3001,
|
693
|
+
"Decidim::Api::Schema.max_depth" => 11
|
694
|
+
}
|
695
|
+
end
|
696
|
+
|
697
|
+
# This is using a big example to avoid recreating the application every time
|
698
|
+
it "env vars generate secrets application" do
|
699
|
+
expect(result[1]).to be_success, result[0]
|
700
|
+
# Test onto the secret generated when ENV vars are empty strings or undefined
|
701
|
+
json_off = json_secrets_for(test_app, env_off)
|
702
|
+
secrets_off.each do |keys, value|
|
703
|
+
current = json_off.dig(*keys)
|
704
|
+
expect(current).to eq(value), "Secret #{keys} = (#{current}) expected to match Env:OFF (#{value})"
|
705
|
+
end
|
706
|
+
|
707
|
+
# Test onto the secret generated when ENV vars are set
|
708
|
+
json_on = json_secrets_for(test_app, env_on)
|
709
|
+
secrets_on.each do |keys, value|
|
710
|
+
current = json_on.dig(*keys)
|
711
|
+
expect(current).to eq(value), "Secret #{keys} = (#{current}) expected to match Env:ON (#{value})"
|
712
|
+
end
|
713
|
+
|
714
|
+
# Test onto the initializer when ENV vars are empty strings or undefined
|
715
|
+
json_off = initializer_config_for(test_app, env_off)
|
716
|
+
initializer_off.each do |key, value|
|
717
|
+
current = json_off[key]
|
718
|
+
expect(current).to eq(value), "Initializer (#{key}) = (#{current}) expected to match Env:OFF (#{value})"
|
719
|
+
end
|
720
|
+
|
721
|
+
# Test onto the initializer when ENV vars are set to the string "false"
|
722
|
+
json_false = initializer_config_for(test_app, env_false)
|
723
|
+
initializer_off.each do |key, value|
|
724
|
+
current = json_false[key]
|
725
|
+
expect(current).to eq(value), "Initializer (#{key}) = (#{current}) expected to match Env:FALSE (#{value})"
|
726
|
+
end
|
727
|
+
|
728
|
+
# Test onto the initializer when ENV vars are set
|
729
|
+
json_on = initializer_config_for(test_app, env_on)
|
730
|
+
initializer_on.each do |key, value|
|
731
|
+
current = json_on[key]
|
732
|
+
expect(current).to eq(value), "Initializer (#{key}) = (#{current}) expected to match Env:ON (#{value})"
|
733
|
+
end
|
734
|
+
|
735
|
+
# Test onto the initializer when ENV vars are set to OpenstreetMap configuration
|
736
|
+
json_on = initializer_config_for(test_app, env_maps_osm)
|
737
|
+
initializer_maps_osm.each do |key, value|
|
738
|
+
current = json_on[key]
|
739
|
+
expect(current).to eq(value), "Initializer (#{key}) = (#{current}) expected to match Env:Maps OSM (#{value})"
|
740
|
+
end
|
741
|
+
|
742
|
+
# Test onto the initializer when ENV vars are set to OpenstreetMap-HERE mix configuration
|
743
|
+
json_on = initializer_config_for(test_app, env_maps_mix)
|
744
|
+
initializer_maps_mix.each do |key, value|
|
745
|
+
current = json_on[key]
|
746
|
+
expect(current).to eq(value), "Initializer (#{key}) = (#{current}) expected to match Env:Maps MIX (#{value})"
|
747
|
+
end
|
748
|
+
|
749
|
+
# Test onto the initializer with ENV vars OFF for the API module
|
750
|
+
json_off = initializer_config_for(test_app, env_off, "Decidim::Api")
|
751
|
+
api_initializer_off.each do |key, value|
|
752
|
+
current = json_off[key]
|
753
|
+
expect(current).to eq(value), "API Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
754
|
+
end
|
755
|
+
|
756
|
+
# Test onto the initializer with ENV vars ON for the API module
|
757
|
+
json_on = initializer_config_for(test_app, env_on, "Decidim::Api")
|
758
|
+
api_initializer_on.each do |key, value|
|
759
|
+
current = json_on[key]
|
760
|
+
expect(current).to eq(value), "API Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
761
|
+
end
|
762
|
+
|
763
|
+
# Test onto the initializer with ENV vars OFF for the Proposals module
|
764
|
+
json_off = initializer_config_for(test_app, env_off, "Decidim::Proposals")
|
765
|
+
proposals_initializer_off.each do |key, value|
|
766
|
+
current = json_off[key]
|
767
|
+
expect(current).to eq(value), "Proposals Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
768
|
+
end
|
769
|
+
|
770
|
+
# Test onto the initializer with ENV vars ON for the Proposals module
|
771
|
+
json_on = initializer_config_for(test_app, env_on, "Decidim::Proposals")
|
772
|
+
proposals_initializer_on.each do |key, value|
|
773
|
+
current = json_on[key]
|
774
|
+
expect(current).to eq(value), "Proposals Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
775
|
+
end
|
776
|
+
|
777
|
+
# Test onto the initializer with ENV vars OFF for the Meetings module
|
778
|
+
json_off = initializer_config_for(test_app, env_off, "Decidim::Meetings")
|
779
|
+
meetings_initializer_off.each do |key, value|
|
780
|
+
current = json_off[key]
|
781
|
+
expect(current).to eq(value), "Meetings Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
782
|
+
end
|
783
|
+
|
784
|
+
# Test onto the initializer with ENV vars ON for the Meetings module
|
785
|
+
json_on = initializer_config_for(test_app, env_on, "Decidim::Meetings")
|
786
|
+
meetings_initializer_on.each do |key, value|
|
787
|
+
current = json_on[key]
|
788
|
+
expect(current).to eq(value), "Meetings Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
789
|
+
end
|
790
|
+
|
791
|
+
# Test onto the initializer with ENV vars OFF for the Budgets module
|
792
|
+
json_off = initializer_config_for(test_app, env_off, "Decidim::Budgets")
|
793
|
+
budgets_initializer_off.each do |key, value|
|
794
|
+
current = json_off[key]
|
795
|
+
expect(current).to eq(value), "Budgets Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
796
|
+
end
|
797
|
+
|
798
|
+
# Test onto the initializer with ENV vars ON for the Budgets module
|
799
|
+
json_on = initializer_config_for(test_app, env_on, "Decidim::Budgets")
|
800
|
+
budgets_initializer_on.each do |key, value|
|
801
|
+
current = json_on[key]
|
802
|
+
expect(current).to eq(value), "Budgets Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
803
|
+
end
|
804
|
+
|
805
|
+
# Test onto the initializer with ENV vars OFF for the Accountability module
|
806
|
+
json_off = initializer_config_for(test_app, env_off, "Decidim::Accountability")
|
807
|
+
accountability_initializer_off.each do |key, value|
|
808
|
+
current = json_off[key]
|
809
|
+
expect(current).to eq(value), "Accountability Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
810
|
+
end
|
811
|
+
|
812
|
+
# Test onto the initializer with ENV vars ON for the Accountability module
|
813
|
+
json_on = initializer_config_for(test_app, env_on, "Decidim::Accountability")
|
814
|
+
accountability_initializer_on.each do |key, value|
|
815
|
+
current = json_on[key]
|
816
|
+
expect(current).to eq(value), "Accountability Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
817
|
+
end
|
818
|
+
|
819
|
+
# Test onto some extra Rails configs when ENV vars are empty or undefined
|
820
|
+
rails_off.each do |key, value|
|
821
|
+
current = rails_value(key, test_app, env_off)
|
822
|
+
expect(current).to eq(value), "Rails config (#{key}) = (#{current}) expected to match Env:OFF (#{value})"
|
823
|
+
end
|
824
|
+
|
825
|
+
# Test onto some extra Rails configs when ENV vars are set
|
826
|
+
rails_on.each do |key, value|
|
827
|
+
current = rails_value(key, test_app, env_on)
|
828
|
+
expect(current).to eq(value), "Rails config (#{key}) = (#{current}) expected to match Env:ON (#{value})"
|
829
|
+
end
|
830
|
+
end
|
831
|
+
end
|
832
|
+
|
833
|
+
shared_examples_for "an application with extra configurable env vars" do
|
834
|
+
include_context "with application env vars"
|
835
|
+
|
836
|
+
let(:consultations_initializer_off) do
|
837
|
+
{
|
838
|
+
"stats_cache_expiration_time" => 300 # 5.minutes
|
839
|
+
}
|
840
|
+
end
|
841
|
+
|
842
|
+
let(:consultations_initializer_on) do
|
843
|
+
{
|
844
|
+
"stats_cache_expiration_time" => 420 # 7.minutes
|
845
|
+
}
|
846
|
+
end
|
847
|
+
|
848
|
+
let(:initiatives_initializer_off) do
|
849
|
+
{
|
850
|
+
"creation_enabled" => true,
|
851
|
+
"similarity_threshold" => 0.25,
|
852
|
+
"similarity_limit" => 5,
|
853
|
+
"minimum_committee_members" => 2,
|
854
|
+
"default_signature_time_period_length" => 120,
|
855
|
+
"default_components" => %w(pages meetings),
|
856
|
+
"first_notification_percentage" => 33,
|
857
|
+
"second_notification_percentage" => 66,
|
858
|
+
"stats_cache_expiration_time" => 300, # 5.minutes
|
859
|
+
"max_time_in_validating_state" => 5_184_000, # 60.days
|
860
|
+
"print_enabled" => true,
|
861
|
+
"do_not_require_authorization" => false
|
862
|
+
}
|
863
|
+
end
|
864
|
+
|
865
|
+
let(:initiatives_initializer_on) do
|
866
|
+
{
|
867
|
+
"creation_enabled" => false,
|
868
|
+
"similarity_threshold" => 0.99,
|
869
|
+
"similarity_limit" => 10,
|
870
|
+
"minimum_committee_members" => 3,
|
871
|
+
"default_signature_time_period_length" => 133,
|
872
|
+
"default_components" => %w(pages proposals budgets),
|
873
|
+
"first_notification_percentage" => 10,
|
874
|
+
"second_notification_percentage" => 70,
|
875
|
+
"stats_cache_expiration_time" => 420, # 7.minutes
|
876
|
+
"max_time_in_validating_state" => 4_320_000, # 50.days
|
877
|
+
"print_enabled" => false,
|
878
|
+
"do_not_require_authorization" => true
|
879
|
+
}
|
880
|
+
end
|
881
|
+
|
882
|
+
let(:elections_initializer_off) do
|
883
|
+
{
|
884
|
+
"setup_minimum_hours_before_start" => 3,
|
885
|
+
"start_vote_maximum_hours_before_start" => 6,
|
886
|
+
"voter_token_expiration_minutes" => 120
|
887
|
+
}
|
888
|
+
end
|
889
|
+
|
890
|
+
let(:elections_initializer_on) do
|
891
|
+
{
|
892
|
+
"setup_minimum_hours_before_start" => 4,
|
893
|
+
"start_vote_maximum_hours_before_start" => 7,
|
894
|
+
"voter_token_expiration_minutes" => 123
|
895
|
+
}
|
896
|
+
end
|
897
|
+
|
898
|
+
let(:votings_initializer_off) do
|
899
|
+
{
|
900
|
+
"check_census_max_requests" => 5,
|
901
|
+
"throttling_period" => 60 # 1.minute
|
902
|
+
}
|
903
|
+
end
|
904
|
+
|
905
|
+
let(:votings_initializer_on) do
|
906
|
+
{
|
907
|
+
"check_census_max_requests" => 6,
|
908
|
+
"throttling_period" => 120 # 2.minutes
|
909
|
+
}
|
910
|
+
end
|
911
|
+
|
912
|
+
let(:census_initializer_off) do
|
913
|
+
{
|
914
|
+
"census_access_codes_export_expiry_time" => 172_800 # 2.days
|
915
|
+
}
|
916
|
+
end
|
917
|
+
|
918
|
+
let(:census_initializer_on) do
|
919
|
+
{
|
920
|
+
"census_access_codes_export_expiry_time" => 259_200 # 3.days
|
921
|
+
}
|
922
|
+
end
|
923
|
+
|
924
|
+
it "env vars generate secrets application" do
|
925
|
+
expect(result[1]).to be_success, result[0]
|
926
|
+
|
927
|
+
# Test onto the initializer with ENV vars OFF for the Consultations module
|
928
|
+
json_off = initializer_config_for(test_app, env_off, "Decidim::Consultations")
|
929
|
+
consultations_initializer_off.each do |key, value|
|
930
|
+
current = json_off[key]
|
931
|
+
expect(current).to eq(value), "Consultations Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
932
|
+
end
|
933
|
+
|
934
|
+
# Test onto the initializer with ENV vars ON for the Consultations module
|
935
|
+
json_on = initializer_config_for(test_app, env_on, "Decidim::Consultations")
|
936
|
+
consultations_initializer_on.each do |key, value|
|
937
|
+
current = json_on[key]
|
938
|
+
expect(current).to eq(value), "Consultations Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
939
|
+
end
|
940
|
+
|
941
|
+
# Test onto the initializer with ENV vars OFF for the Initiatives module
|
942
|
+
json_off = initializer_config_for(test_app, env_off, "Decidim::Initiatives")
|
943
|
+
initiatives_initializer_off.each do |key, value|
|
944
|
+
current = json_off[key]
|
945
|
+
expect(current).to eq(value), "Initiatives Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
946
|
+
end
|
947
|
+
|
948
|
+
# Test onto the initializer with ENV vars ON for the Initiatives module
|
949
|
+
json_on = initializer_config_for(test_app, env_on, "Decidim::Initiatives")
|
950
|
+
initiatives_initializer_on.each do |key, value|
|
951
|
+
current = json_on[key]
|
952
|
+
expect(current).to eq(value), "Initiatives Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
953
|
+
end
|
954
|
+
|
955
|
+
# Test onto the initializer with ENV vars OFF for the Elections module
|
956
|
+
json_off = initializer_config_for(test_app, env_off, "Decidim::Elections")
|
957
|
+
elections_initializer_off.each do |key, value|
|
958
|
+
current = json_off[key]
|
959
|
+
expect(current).to eq(value), "Elections Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
960
|
+
end
|
961
|
+
|
962
|
+
# Test onto the initializer with ENV vars ON for the Elections module
|
963
|
+
json_on = initializer_config_for(test_app, env_on, "Decidim::Elections")
|
964
|
+
elections_initializer_on.each do |key, value|
|
965
|
+
current = json_on[key]
|
966
|
+
expect(current).to eq(value), "Elections Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
967
|
+
end
|
968
|
+
|
969
|
+
# Test onto the initializer with ENV vars OFF for the Votings module
|
970
|
+
json_off = initializer_config_for(test_app, env_off, "Decidim::Votings")
|
971
|
+
votings_initializer_off.each do |key, value|
|
972
|
+
current = json_off[key]
|
973
|
+
expect(current).to eq(value), "Votings Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
974
|
+
end
|
975
|
+
|
976
|
+
# Test onto the initializer with ENV vars ON for the Votings module
|
977
|
+
json_on = initializer_config_for(test_app, env_on, "Decidim::Votings")
|
978
|
+
votings_initializer_on.each do |key, value|
|
979
|
+
current = json_on[key]
|
980
|
+
expect(current).to eq(value), "Votings Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
981
|
+
end
|
982
|
+
|
983
|
+
# Test onto the initializer with ENV vars OFF for the Votings::Census module
|
984
|
+
json_off = initializer_config_for(test_app, env_off, "Decidim::Votings::Census")
|
985
|
+
census_initializer_off.each do |key, value|
|
986
|
+
current = json_off[key]
|
987
|
+
expect(current).to eq(value), "Votings::Census Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
988
|
+
end
|
989
|
+
|
990
|
+
# Test onto the initializer with ENV vars ON for the Votings::Census module
|
991
|
+
json_on = initializer_config_for(test_app, env_on, "Decidim::Votings::Census")
|
992
|
+
census_initializer_on.each do |key, value|
|
993
|
+
current = json_on[key]
|
994
|
+
expect(current).to eq(value), "Votings::Census Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
995
|
+
end
|
996
|
+
end
|
997
|
+
end
|
998
|
+
|
999
|
+
shared_examples_for "an application with wrong cloud storage options" do
|
1000
|
+
it "creating fails" do
|
1001
|
+
expect(result[1]).not_to be_success, result[0]
|
1002
|
+
end
|
1003
|
+
end
|
1004
|
+
|
1005
|
+
shared_examples_for "an application with cloud storage gems" do
|
1006
|
+
let(:services) do
|
1007
|
+
%w(local s3 gcs azure)
|
1008
|
+
end
|
1009
|
+
let(:storage_envs) do
|
1010
|
+
{
|
1011
|
+
"RAILS_ENV" => "production",
|
1012
|
+
"AWS_ACCESS_KEY_ID" => "my-aws-id",
|
1013
|
+
"AWS_SECRET_ACCESS_KEY" => "my-aws-secret",
|
1014
|
+
"AWS_REGION" => "eu-west-1",
|
1015
|
+
# "AWS_ENDPOINT" => "https://s3.amazonaws.com",
|
1016
|
+
"AWS_BUCKET" => "test",
|
1017
|
+
"AZURE_STORAGE_ACCOUNT_NAME" => "test",
|
1018
|
+
"AZURE_STORAGE_ACCESS_KEY" => "dGVzdA==\n", # Base64 of "test"
|
1019
|
+
"AZURE_CONTAINER" => "test"
|
1020
|
+
}
|
1021
|
+
end
|
1022
|
+
|
1023
|
+
it "includes cloud storage gems in the Gemfile" do
|
1024
|
+
expect(result[1]).to be_success, result[0]
|
1025
|
+
|
1026
|
+
expect(File.read("#{test_app}/Gemfile"))
|
1027
|
+
.to match(/gem ["']+aws-sdk-s3["']+/)
|
1028
|
+
.and match(/gem ["']+azure-storage-blob["']+/)
|
1029
|
+
.and match(/gem ["']+google-cloud-storage["']+/)
|
1030
|
+
|
1031
|
+
services.each do |service|
|
1032
|
+
current = rails_value("Rails.application.config.active_storage.service", test_app, storage_envs.merge({ "STORAGE_PROVIDER" => service }))
|
1033
|
+
expect(current).to eq(service), "Rails storage service (#{current}) expected to match provider (#{service})"
|
1034
|
+
end
|
1035
|
+
end
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
shared_examples_for "an application with storage and queue gems" do
|
1039
|
+
let(:queue_envs_off) do
|
1040
|
+
{
|
1041
|
+
"RAILS_ENV" => "production"
|
1042
|
+
}
|
1043
|
+
end
|
1044
|
+
let(:queue_envs_on) do
|
1045
|
+
{
|
1046
|
+
"RAILS_ENV" => "production",
|
1047
|
+
"QUEUE_ADAPTER" => "sidekiq",
|
1048
|
+
"SIDEKIQ_CONCURRENCY" => "11"
|
1049
|
+
}
|
1050
|
+
end
|
1051
|
+
|
1052
|
+
it "includes storage and queue gems in the Gemfile" do
|
1053
|
+
expect(result[1]).to be_success, result[0]
|
1054
|
+
|
1055
|
+
expect(File.read("#{test_app}/Gemfile"))
|
1056
|
+
.to match(/gem ["']+aws-sdk-s3["']+/)
|
1057
|
+
.and match(/gem ["']+sidekiq["']+/)
|
1058
|
+
|
1059
|
+
current = rails_value("Rails.application.config.active_job.queue_adapter", test_app, queue_envs_off)
|
1060
|
+
expect(current).to eq("async"), "sidekiq queue (#{current}) expected to be async"
|
1061
|
+
|
1062
|
+
current = rails_value("Rails.application.config.active_job.queue_adapter", test_app, queue_envs_on)
|
1063
|
+
expect(current).to eq("sidekiq"), "sidekiq queue (#{current}) expected to be sidekiq"
|
1064
|
+
current = rails_value("YAML.load(ERB.new(IO.read(\"config/sidekiq.yml\")).result)", test_app, queue_envs_off)
|
1065
|
+
expect(current["concurrency"]).to eq(5), "sidekiq concurrency (#{current["concurrency"]}) expected to eq 5"
|
1066
|
+
|
1067
|
+
current = rails_value("YAML.load(ERB.new(IO.read(\"config/sidekiq.yml\")).result)", test_app, queue_envs_on)
|
1068
|
+
expect(current["concurrency"]).to eq(11), "sidekiq concurrency (#{current["concurrency"]}) expected to eq 11"
|
1069
|
+
|
1070
|
+
queues = %w(mailers vote_reminder reminders default newsletter newsletters_opt_in conference_diplomas events translations user_report block_user metrics exports)
|
1071
|
+
expect(current["queues"].flatten).to include(*queues), "sidekiq queues (#{current["queues"].flatten}) expected to eq containt (#{queues})"
|
1072
|
+
end
|
1073
|
+
end
|