roda-gen 1.0.0
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 +7 -0
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +94 -0
- data/bin/roda +11 -0
- data/lib/roda-gen.rb +3 -0
- data/lib/roda_gen/app_name.rb +29 -0
- data/lib/roda_gen/cli.rb +122 -0
- data/lib/roda_gen/generators/daemon.rb +78 -0
- data/lib/roda_gen/generators/migration.rb +68 -0
- data/lib/roda_gen/generators/migration_numbering.rb +21 -0
- data/lib/roda_gen/generators/model.rb +75 -0
- data/lib/roda_gen/generators/project.rb +145 -0
- data/lib/roda_gen/generators/route.rb +71 -0
- data/lib/roda_gen/generators/templates/daemon/bin/%daemon_name%.tt +13 -0
- data/lib/roda_gen/generators/templates/daemon/lib/daemon/%daemon_name%.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/daemon/spec/daemons/%daemon_name%_spec.rb.tt +18 -0
- data/lib/roda_gen/generators/templates/migration/db/migrate/%migration_filename%.rb.tt +6 -0
- data/lib/roda_gen/generators/templates/model/db/migrate/%migration_filename%.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/model/models/%resource_name%.rb.tt +5 -0
- data/lib/roda_gen/generators/templates/model/spec/models/%resource_name%_spec.rb.tt +18 -0
- data/lib/roda_gen/generators/templates/project/%app_name%.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/project/.bundle/config.tt +3 -0
- data/lib/roda_gen/generators/templates/project/.erb_lint.yml.tt +29 -0
- data/lib/roda_gen/generators/templates/project/.gitignore.tt +19 -0
- data/lib/roda_gen/generators/templates/project/.reek.yml.tt +45 -0
- data/lib/roda_gen/generators/templates/project/.rspec.tt +4 -0
- data/lib/roda_gen/generators/templates/project/.rubocop.yml.tt +119 -0
- data/lib/roda_gen/generators/templates/project/.ruby-version.tt +1 -0
- data/lib/roda_gen/generators/templates/project/.rubycritic.yml.tt +15 -0
- data/lib/roda_gen/generators/templates/project/Gemfile.tt +109 -0
- data/lib/roda_gen/generators/templates/project/Procfile.dev.tt +7 -0
- data/lib/roda_gen/generators/templates/project/README.md.tt +891 -0
- data/lib/roda_gen/generators/templates/project/Rakefile.tt +3 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/admin.js.tt +84 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/app.js.tt +29 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/push.js.tt +53 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/upload.js.tt +200 -0
- data/lib/roda_gen/generators/templates/project/assets/stylesheets/app.css.tt +52 -0
- data/lib/roda_gen/generators/templates/project/assets/stylesheets/typography.css.tt +85 -0
- data/lib/roda_gen/generators/templates/project/bin/console.tt +2 -0
- data/lib/roda_gen/generators/templates/project/bin/dev.tt +8 -0
- data/lib/roda_gen/generators/templates/project/bin/gdpr_worker.tt +13 -0
- data/lib/roda_gen/generators/templates/project/bin/push_sender.tt +13 -0
- data/lib/roda_gen/generators/templates/project/bin/setup.tt +224 -0
- data/lib/roda_gen/generators/templates/project/bin/shrine_clean_cache.tt +13 -0
- data/lib/roda_gen/generators/templates/project/config/boot.rb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/config/console.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/config/database.rb.tt +45 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/00_environments.rb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/01_logger.rb.tt +46 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/02_app_config.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/10_database.rb.tt +3 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/15_mail.rb.tt +53 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/20_redis.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/25_rack_attack.rb.tt +96 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/30_i18n.rb.tt +37 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/35_listen_job.rb.tt +4 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/37_shrine.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/40_routing.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/41_render.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/43_static.rb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/44_sessions.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/45_security.rb.tt +49 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/46_flash.rb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/47_json.rb.tt +8 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/48_errors.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/49_misc.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/50_mailer.rb.tt +52 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/51_locale_kit.rb.tt +29 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/52_consent_kit.rb.tt +28 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/55_audit_log.rb.tt +16 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/56_form_helper.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/57_rodauth.rb.tt +304 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/60_web_push.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/61_flipper.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/62_split.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/config/puma.rb.tt +24 -0
- data/lib/roda_gen/generators/templates/project/config/settings/development.yml.tt +9 -0
- data/lib/roda_gen/generators/templates/project/config/settings/production.yml.tt +13 -0
- data/lib/roda_gen/generators/templates/project/config/settings/test.yml.tt +9 -0
- data/lib/roda_gen/generators/templates/project/config/settings.yml.tt +45 -0
- data/lib/roda_gen/generators/templates/project/config.ru.tt +36 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_account_profiles.rb.tt +66 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_accounts.rb.tt +70 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_audit_log.rb.tt +185 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_authorization.rb.tt +68 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_countries.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_calling_codes.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_exit_codes.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_languages.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_time_zones.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_currencies.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_gdpr_requests.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_languages.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_push_subscriptions.rb.tt +16 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_rodauth_features.rb.tt +105 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_settings.rb.tt +60 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/01_countries.csv.tt +250 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/01_currencies.csv.tt +162 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/01_languages.csv.tt +144 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_calling_codes.csv.tt +237 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_exit_codes.csv.tt +239 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_languages.csv.tt +226 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_time_zones.csv.tt +369 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/03_setting_system_defaults.yml.tt +35 -0
- data/lib/roda_gen/generators/templates/project/db/seeds.rb.tt +69 -0
- data/lib/roda_gen/generators/templates/project/deploy/Caddyfile.tt +69 -0
- data/lib/roda_gen/generators/templates/project/deploy/logrotate/%app_name%-caddy.tt +11 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-audit-partition.service.tt +21 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-audit-partition.timer.tt +16 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-gdpr-worker.service.tt +25 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-push-sender.service.tt +25 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-shrine-cleanup.service.tt +21 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-shrine-cleanup.timer.tt +16 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%.service.tt +36 -0
- data/lib/roda_gen/generators/templates/project/helpers/audit_helper.rb.tt +59 -0
- data/lib/roda_gen/generators/templates/project/helpers/authorization_helper.rb.tt +25 -0
- data/lib/roda_gen/generators/templates/project/helpers/current_account_helper.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/helpers/feature_flag_helper.rb.tt +34 -0
- data/lib/roda_gen/generators/templates/project/helpers/form_helper.rb.tt +50 -0
- data/lib/roda_gen/generators/templates/project/helpers/http_cache_helper.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/helpers/logger_helper.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/helpers/split_helper.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/lib/audit_context.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/lib/audit_lookup.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/base.rb.tt +104 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/gdpr_worker.rb.tt +53 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/push_sender.rb.tt +47 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/shrine_cache_cleaner.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/lib/deploy_check.rb.tt +96 -0
- data/lib/roda_gen/generators/templates/project/lib/filtered_logger.rb.tt +54 -0
- data/lib/roda_gen/generators/templates/project/lib/gdpr.rb.tt +106 -0
- data/lib/roda_gen/generators/templates/project/lib/rbac_audit.rb.tt +47 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/.rubocop.yml.tt +4 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/audit.rake.tt +85 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/console.rake.tt +8 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/db.rake.tt +104 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/deploy.rake.tt +38 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/flags.rake.tt +47 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/gdpr.rake.tt +31 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/parser_current_shim.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/quality.rake.tt +84 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/secrets.rake.tt +154 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/spec.rake.tt +136 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/split.rake.tt +27 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/tailwind.rake.tt +35 -0
- data/lib/roda_gen/generators/templates/project/locales/de.yml.tt +325 -0
- data/lib/roda_gen/generators/templates/project/locales/en.yml.tt +321 -0
- data/lib/roda_gen/generators/templates/project/locales/es.yml.tt +326 -0
- data/lib/roda_gen/generators/templates/project/locales/fr.yml.tt +329 -0
- data/lib/roda_gen/generators/templates/project/locales/it.yml.tt +325 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/de.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/en.yml.tt +6 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/es.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/fr.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/it.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/sv.yml.tt +274 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/tru.yml.tt +274 -0
- data/lib/roda_gen/generators/templates/project/locales/sv.yml.tt +319 -0
- data/lib/roda_gen/generators/templates/project/locales/tru.yml.tt +294 -0
- data/lib/roda_gen/generators/templates/project/log/.keep.tt +0 -0
- data/lib/roda_gen/generators/templates/project/models/account.rb.tt +50 -0
- data/lib/roda_gen/generators/templates/project/models/account_privilege.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/models/account_profile.rb.tt +115 -0
- data/lib/roda_gen/generators/templates/project/models/account_role.rb.tt +14 -0
- data/lib/roda_gen/generators/templates/project/models/audit_action.rb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/models/audit_actor_type.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/models/audit_log.rb.tt +257 -0
- data/lib/roda_gen/generators/templates/project/models/audit_status.rb.tt +9 -0
- data/lib/roda_gen/generators/templates/project/models/country.rb.tt +17 -0
- data/lib/roda_gen/generators/templates/project/models/country_calling_code.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/country_exit_code.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/country_language.rb.tt +8 -0
- data/lib/roda_gen/generators/templates/project/models/country_time_zone.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/currency.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/gdpr_request.rb.tt +32 -0
- data/lib/roda_gen/generators/templates/project/models/gender.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/language.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/models/privilege.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/models/push_subscription.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/models/role.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/models/role_privilege.rb.tt +14 -0
- data/lib/roda_gen/generators/templates/project/models/setting_system_default.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/models/setting_user_value.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/models/settings.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/models/signup_form_data.rb.tt +61 -0
- data/lib/roda_gen/generators/templates/project/models.rb.tt +6 -0
- data/lib/roda_gen/generators/templates/project/package.json.tt +13 -0
- data/lib/roda_gen/generators/templates/project/public/apple-touch-icon.png +0 -0
- data/lib/roda_gen/generators/templates/project/public/favicon.ico +0 -0
- data/lib/roda_gen/generators/templates/project/public/favicon.svg.tt +5 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/JetBrainsMono-Italic-Variable.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/JetBrainsMono-Variable.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-Bold.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-BoldItalic.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-Italic.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-Regular.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NOTICE.md +17 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriac-Bold.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriac-Regular.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriacWestern-Bold.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriacWestern-Regular.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/manifest.webmanifest.tt +12 -0
- data/lib/roda_gen/generators/templates/project/public/robots.txt.tt +4 -0
- data/lib/roda_gen/generators/templates/project/public/service-worker.js.tt +27 -0
- data/lib/roda_gen/generators/templates/project/routes/account.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/routes/admin.rb.tt +118 -0
- data/lib/roda_gen/generators/templates/project/routes/gdpr.rb.tt +32 -0
- data/lib/roda_gen/generators/templates/project/routes/heartbeat.rb.tt +35 -0
- data/lib/roda_gen/generators/templates/project/routes/legal.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/routes/profile.rb.tt +56 -0
- data/lib/roda_gen/generators/templates/project/routes/push.rb.tt +25 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/role_boundary_spec.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/spec_helper.rb.tt +146 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/support/auth_helpers.rb.tt +71 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/auth_spec.rb.tt +25 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/consent_nojs_spec.rb.tt +60 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/create_account_form_spec.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/otp_lifecycle_spec.rb.tt +67 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/profile_form_spec.rb.tt +17 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/upload_spec.rb.tt +102 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/wcag/auth_pages_spec.rb.tt +61 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/wcag/legal_pages_spec.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/spec/daemons/base_spec.rb.tt +106 -0
- data/lib/roda_gen/generators/templates/project/spec/daemons/gdpr_worker_spec.rb.tt +72 -0
- data/lib/roda_gen/generators/templates/project/spec/daemons/push_sender_spec.rb.tt +74 -0
- data/lib/roda_gen/generators/templates/project/spec/locale_parity_spec.rb.tt +58 -0
- data/lib/roda_gen/generators/templates/project/spec/models/account_profile_spec.rb.tt +180 -0
- data/lib/roda_gen/generators/templates/project/spec/models/account_spec.rb.tt +104 -0
- data/lib/roda_gen/generators/templates/project/spec/models/audit_actor_type_spec.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/spec/models/audit_log_spec.rb.tt +398 -0
- data/lib/roda_gen/generators/templates/project/spec/models/audit_status_spec.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/spec/models/authorization_spec.rb.tt +82 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_calling_code_spec.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_exit_code_spec.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_language_spec.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_spec.rb.tt +29 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_time_zone_spec.rb.tt +9 -0
- data/lib/roda_gen/generators/templates/project/spec/models/currency_spec.rb.tt +9 -0
- data/lib/roda_gen/generators/templates/project/spec/models/deploy_check_spec.rb.tt +143 -0
- data/lib/roda_gen/generators/templates/project/spec/models/gdpr_spec.rb.tt +110 -0
- data/lib/roda_gen/generators/templates/project/spec/models/language_spec.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/spec/models/rbac_audit_spec.rb.tt +110 -0
- data/lib/roda_gen/generators/templates/project/spec/models/setting_system_default_spec.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/spec/models/setting_user_value_spec.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/spec/models/settings_spec.rb.tt +63 -0
- data/lib/roda_gen/generators/templates/project/spec/models/signup_form_data_spec.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/spec/spec_helper.rb.tt +93 -0
- data/lib/roda_gen/generators/templates/project/spec/support/audit_log_helpers.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/spec/support/audit_lookup_shared_examples.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/spec/support/auth_helpers.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/spec/support/faker.rb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/spec/web/admin_spec.rb.tt +155 -0
- data/lib/roda_gen/generators/templates/project/spec/web/audit_log_spec.rb.tt +159 -0
- data/lib/roda_gen/generators/templates/project/spec/web/auth_spec.rb.tt +492 -0
- data/lib/roda_gen/generators/templates/project/spec/web/authorization_spec.rb.tt +110 -0
- data/lib/roda_gen/generators/templates/project/spec/web/boot_spec.rb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/spec/web/consent_banner_spec.rb.tt +46 -0
- data/lib/roda_gen/generators/templates/project/spec/web/feature_flag_helper_spec.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/spec/web/flags_spec.rb.tt +67 -0
- data/lib/roda_gen/generators/templates/project/spec/web/gdpr_spec.rb.tt +55 -0
- data/lib/roda_gen/generators/templates/project/spec/web/heartbeat_spec.rb.tt +65 -0
- data/lib/roda_gen/generators/templates/project/spec/web/host_allowlist_spec.rb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/spec/web/legal_spec.rb.tt +61 -0
- data/lib/roda_gen/generators/templates/project/spec/web/locale_resolver_spec.rb.tt +34 -0
- data/lib/roda_gen/generators/templates/project/spec/web/logger_helper_spec.rb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/spec/web/logger_spec.rb.tt +82 -0
- data/lib/roda_gen/generators/templates/project/spec/web/otp_audit_spec.rb.tt +147 -0
- data/lib/roda_gen/generators/templates/project/spec/web/profile_spec.rb.tt +97 -0
- data/lib/roda_gen/generators/templates/project/spec/web/push_spec.rb.tt +55 -0
- data/lib/roda_gen/generators/templates/project/spec/web/rack_attack_runtime_spec.rb.tt +52 -0
- data/lib/roda_gen/generators/templates/project/spec/web/rack_attack_spec.rb.tt +81 -0
- data/lib/roda_gen/generators/templates/project/spec/web/rbac_audit_spec.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/spec/web/request_id_spec.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/spec/web/role_boundary_spec.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/spec/web/session_skip_spec.rb.tt +74 -0
- data/lib/roda_gen/generators/templates/project/spec/web/split_helper_spec.rb.tt +38 -0
- data/lib/roda_gen/generators/templates/project/spec/web/type_routing_spec.rb.tt +55 -0
- data/lib/roda_gen/generators/templates/project/spec/web/upload_zone_spec.rb.tt +91 -0
- data/lib/roda_gen/generators/templates/project/tmp/.keep.tt +0 -0
- data/lib/roda_gen/generators/templates/project/vendor/.keep.tt +0 -0
- data/lib/roda_gen/generators/templates/project/views/403.erb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/views/404.erb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/views/500.erb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/views/_head_meta.erb.tt +29 -0
- data/lib/roda_gen/generators/templates/project/views/_impersonate_picker.erb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/views/_language_switcher.erb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/views/_locked_accounts.erb.tt +18 -0
- data/lib/roda_gen/generators/templates/project/views/_upload_zone.erb.tt +35 -0
- data/lib/roda_gen/generators/templates/project/views/account/profile.erb.tt +149 -0
- data/lib/roda_gen/generators/templates/project/views/admin/flags.erb.tt +51 -0
- data/lib/roda_gen/generators/templates/project/views/consent_kit/_banner.erb.tt +59 -0
- data/lib/roda_gen/generators/templates/project/views/consent_kit/_preferences.erb.tt +87 -0
- data/lib/roda_gen/generators/templates/project/views/gdpr/erased.erb.tt +6 -0
- data/lib/roda_gen/generators/templates/project/views/gdpr/index.erb.tt +28 -0
- data/lib/roda_gen/generators/templates/project/views/layout.erb.tt +112 -0
- data/lib/roda_gen/generators/templates/project/views/legal/contact.erb.tt +44 -0
- data/lib/roda_gen/generators/templates/project/views/legal/cookies.erb.tt +47 -0
- data/lib/roda_gen/generators/templates/project/views/legal/disclaimer.erb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/views/legal/privacy.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/mailers/account_unlocked.erb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/views/mailers/data_erased.erb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/views/mailers/data_export.erb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/add-recovery-codes.erb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/change-login.erb.tt +44 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/change-password.erb.tt +41 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/close-account.erb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/confirm-password.erb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/create-account.erb.tt +183 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/login.erb.tt +51 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/logout.erb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-auth.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-disable.erb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-setup.erb.tt +48 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-unlock-not-available.erb.tt +18 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-unlock.erb.tt +28 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/recovery-auth.erb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/recovery-codes.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/remember.erb.tt +35 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/reset-password-request.erb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/reset-password.erb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/two-factor-auth.erb.tt +8 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/two-factor-disable.erb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/two-factor-manage.erb.tt +36 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/unlock-account-request.erb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/unlock-account.erb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/verify-account-resend.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/verify-account.erb.tt +32 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/verify-login-change.erb.tt +8 -0
- data/lib/roda_gen/generators/templates/route/routes/%plural%.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/route/spec/web/%plural%_spec.rb.tt +36 -0
- data/lib/roda_gen/generators/templates/route/views/%plural%/index.erb.tt +11 -0
- data/lib/roda_gen/generators/templates/route/views/%plural%/show.erb.tt +7 -0
- data/lib/roda_gen/generators/templates/upload/db/migrate/%migration_filename%.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/upload/helpers/upload_serving.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/upload/models/%resource_name%.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/upload/models/%resource_name%_uploader.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/upload/routes/%plural%.rb.tt +44 -0
- data/lib/roda_gen/generators/templates/upload/spec/web/%plural%_spec.rb.tt +56 -0
- data/lib/roda_gen/generators/templates/upload/views/%plural%/index.erb.tt +18 -0
- data/lib/roda_gen/generators/upload.rb +83 -0
- data/lib/roda_gen/project_context.rb +30 -0
- data/lib/roda_gen/version.rb +5 -0
- data/lib/roda_gen.rb +16 -0
- metadata +497 -0
data/lib/roda_gen/generators/templates/project/spec/browser/uat/create_account_form_spec.rb.tt
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'UAT: create-account form chain JS' do
|
|
6
|
+
it 'auto-selects the preferred language and first time zone when country changes' do
|
|
7
|
+
visit '/account/create-account'
|
|
8
|
+
|
|
9
|
+
select 'Sweden', from: 'country'
|
|
10
|
+
|
|
11
|
+
expect(find('select[name="language"]').value).to eq('sv')
|
|
12
|
+
expect(find('select[name="time_zone"]').value).to eq('Europe/Stockholm')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 're-syncs when the country changes a second time' do
|
|
16
|
+
visit '/account/create-account'
|
|
17
|
+
|
|
18
|
+
select 'Sweden', from: 'country'
|
|
19
|
+
expect(find('select[name="language"]').value).to eq('sv')
|
|
20
|
+
|
|
21
|
+
select 'France', from: 'country'
|
|
22
|
+
|
|
23
|
+
expect(find('select[name="language"]').value).to eq('fr')
|
|
24
|
+
expect(find('select[name="time_zone"]').value).to eq('Europe/Paris')
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../spec_helper'
|
|
4
|
+
require 'rotp'
|
|
5
|
+
|
|
6
|
+
RSpec.describe 'UAT: OTP enable/login/disable lifecycle' do
|
|
7
|
+
let(:email) { "uat-otp-#{SecureRandom.hex(4)}@example.com" }
|
|
8
|
+
let(:password) { 'correct horse battery staple' }
|
|
9
|
+
|
|
10
|
+
def enable_otp
|
|
11
|
+
visit '/en/account/otp-setup'
|
|
12
|
+
user_key = find_field('otp_secret', type: 'hidden').value
|
|
13
|
+
fill_in 'otp', with: ROTP::TOTP.new(user_key, interval: 1).now
|
|
14
|
+
fill_in 'password', with: password if has_field?('password') # grace expired
|
|
15
|
+
click_button 'Setup TOTP Authentication'
|
|
16
|
+
user_key
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def submit_otp_challenge(user_key)
|
|
20
|
+
expect(page).to have_current_path(%r{/account/otp-auth\z}, ignore_query: true)
|
|
21
|
+
# Rodauth's otp_update_last_use guard drops a code submitted within otp_interval of the previous use,
|
|
22
|
+
# even a valid one. otp_interval is 1s in test (57_rodauth.rb)
|
|
23
|
+
sleep 1.2
|
|
24
|
+
fill_in 'otp', with: ROTP::TOTP.new(user_key, interval: 1).now
|
|
25
|
+
click_button 'Authenticate Using TOTP'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def disable_all_two_factor
|
|
29
|
+
visit '/en/account/multifactor-disable'
|
|
30
|
+
fill_in 'password', with: password if has_field?('password')
|
|
31
|
+
click_button 'Remove All Multifactor Authentication Methods'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'sign up → enable → logout → login w/ OTP → disable → login w/o OTP → re-enable → login w/ OTP' do
|
|
35
|
+
# language: 'en' keeps Rodauth's button labels English, the test asserts on those exact strings
|
|
36
|
+
account = sign_up_and_verify(email: email, password: password, language: 'en')
|
|
37
|
+
|
|
38
|
+
log_in(email: email, password: password)
|
|
39
|
+
first_user_key = enable_otp
|
|
40
|
+
expect(DB[:account_otp_keys].where(id: account.id).count).to eq(1)
|
|
41
|
+
|
|
42
|
+
log_out
|
|
43
|
+
log_in(email: email, password: password)
|
|
44
|
+
submit_otp_challenge(first_user_key)
|
|
45
|
+
expect(page).to have_no_current_path(%r{/account/otp-auth\z}, ignore_query: true)
|
|
46
|
+
|
|
47
|
+
# auto_remove_recovery_codes? true wipes any recovery codes too
|
|
48
|
+
disable_all_two_factor
|
|
49
|
+
expect(DB[:account_otp_keys].where(id: account.id).count).to eq(0)
|
|
50
|
+
expect(DB[:account_recovery_codes].where(id: account.id).count).to eq(0)
|
|
51
|
+
|
|
52
|
+
# Without the uses_two_factor_authentication? guard in after_login every login would loop
|
|
53
|
+
# /otp-auth to /multifactor-manage
|
|
54
|
+
log_out
|
|
55
|
+
log_in(email: email, password: password)
|
|
56
|
+
expect(page).to have_no_current_path(%r{/account/otp-auth\z}, ignore_query: true)
|
|
57
|
+
|
|
58
|
+
second_user_key = enable_otp
|
|
59
|
+
expect(second_user_key).not_to eq(first_user_key)
|
|
60
|
+
expect(DB[:account_otp_keys].where(id: account.id).count).to eq(1)
|
|
61
|
+
|
|
62
|
+
log_out
|
|
63
|
+
log_in(email: email, password: password)
|
|
64
|
+
submit_otp_challenge(second_user_key)
|
|
65
|
+
expect(page).to have_no_current_path(%r{/account/otp-auth\z}, ignore_query: true)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../spec_helper'
|
|
4
|
+
|
|
5
|
+
# app.js wires syncAll() to country.change only, on init it would clobber a saved language that
|
|
6
|
+
# differs from the country default on every page load
|
|
7
|
+
RSpec.describe 'UAT: /account/profile preserves saved selects on initial load' do
|
|
8
|
+
it 'keeps the saved language when it differs from the country default' do
|
|
9
|
+
email = Faker::Internet.email(name: "uat-#{SecureRandom.hex(4)}")
|
|
10
|
+
# Sweden auto-picks sv, language: 'en' overrides it so the saved profile is SE + en
|
|
11
|
+
sign_up_and_log_in(email: email, language: 'en')
|
|
12
|
+
|
|
13
|
+
visit '/account/profile'
|
|
14
|
+
|
|
15
|
+
expect(find('select[name="language"]').value).to eq('en')
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
|
|
6
|
+
# Folder dropping (the webkitGetAsEntry walk) can't be synthesised, a scripted DataTransfer yields no
|
|
7
|
+
# entries, so that path stays a manual check. The folder picker carries webkitRelativePath and is covered
|
|
8
|
+
RSpec.describe 'UAT: drop zone uploads with a progress bar per file' do
|
|
9
|
+
let(:app) do
|
|
10
|
+
Class.new(<%= @app.camel %>) do
|
|
11
|
+
hash_branch('upload') do |r|
|
|
12
|
+
rodauth.require_authentication
|
|
13
|
+
r.on('cache') { r.run Shrine.upload_endpoint(:cache, **direct_upload_options) }
|
|
14
|
+
r.get('small') { view(inline: form_with_zone(max_files: 2)) }
|
|
15
|
+
r.get { view(inline: form_with_zone(max_files: 100)) }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# The recipe's options verbatim, keep in step with spec/web/upload_zone_spec.rb
|
|
19
|
+
def direct_upload_options
|
|
20
|
+
{
|
|
21
|
+
max_size: Settings.for_system('file_upload_max_size').to_i,
|
|
22
|
+
upload_context: lambda do |request|
|
|
23
|
+
path = request.params['relative_path'].to_s
|
|
24
|
+
keep = path.length.between?(1, 512) && !path.start_with?('/') && !path.split('/').include?('..')
|
|
25
|
+
keep ? { metadata: { 'relative_path' => path } } : {}
|
|
26
|
+
end
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def form_with_zone(max_files:)
|
|
31
|
+
<<~ERB
|
|
32
|
+
<form method="post" action="/upload" enctype="multipart/form-data">
|
|
33
|
+
<%%== render('./_upload_zone', locals: { url: '/upload/cache', max_files: #{max_files} }) %>
|
|
34
|
+
<button type="submit" class="btn btn-primary">Save</button>
|
|
35
|
+
</form>
|
|
36
|
+
ERB
|
|
37
|
+
end
|
|
38
|
+
end.freeze.app
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Capybara boots one server per app object, so swap in the subclass per example with its own session
|
|
42
|
+
around do |example|
|
|
43
|
+
previous = Capybara.app
|
|
44
|
+
Capybara.app = app
|
|
45
|
+
Capybara.using_session(:upload_zone) { example.run }
|
|
46
|
+
ensure
|
|
47
|
+
Capybara.app = previous
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def with_files(names = %w[one.txt two.txt three.txt])
|
|
51
|
+
Dir.mktmpdir do |dir|
|
|
52
|
+
paths = names.map { |name| File.join(dir, name).tap { File.write(it, name * 200) } }
|
|
53
|
+
yield dir, paths
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# An inline style on the progress bar would fire securitypolicyviolation under the self-only CSP
|
|
58
|
+
def record_csp_violations
|
|
59
|
+
page.execute_script(<<~JS)
|
|
60
|
+
window.__csp = [];
|
|
61
|
+
document.addEventListener('securitypolicyviolation', function (e) { window.__csp.push(e.violatedDirective); });
|
|
62
|
+
JS
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
before do
|
|
66
|
+
sign_up_and_log_in
|
|
67
|
+
visit '/en/upload'
|
|
68
|
+
record_csp_violations
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'uploads picked files with a progress bar each and hands the form the cached JSON' do
|
|
72
|
+
with_files do |_dir, paths|
|
|
73
|
+
attach_file('Choose files', paths)
|
|
74
|
+
expect(page).to have_css('progress[value="100"]', count: 3)
|
|
75
|
+
expect(page).to have_field('files[]', type: 'hidden', count: 3, visible: :all)
|
|
76
|
+
expect(page).to have_button('Save', disabled: false)
|
|
77
|
+
end
|
|
78
|
+
expect(page.evaluate_script('window.__csp')).to eq([])
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'keeps the structure of a picked folder as relative_path' do
|
|
82
|
+
with_files(%w[a.txt]) do |dir, _paths|
|
|
83
|
+
attach_file('Choose a folder', dir)
|
|
84
|
+
expect(page).to have_css('progress[value="100"]', count: 1)
|
|
85
|
+
json = JSON.parse(find_field('files[]', type: 'hidden', visible: :all).value)
|
|
86
|
+
expect(json.dig('metadata', 'relative_path')).to eq("#{File.basename(dir)}/a.txt")
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'refuses a drop over the client-side file cap without sending anything' do
|
|
91
|
+
visit '/en/upload/small'
|
|
92
|
+
with_files do |_dir, paths|
|
|
93
|
+
attach_file('Choose files', paths)
|
|
94
|
+
expect(page).to have_css('[data-upload-message]', text: 'Too many files at once')
|
|
95
|
+
expect(page).to have_no_css('progress')
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'renders the zone without accessibility violations' do
|
|
100
|
+
expect(AxeAudit.violations(page)).to be_empty
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'WCAG: Rodauth pages' do
|
|
6
|
+
describe 'GET /create-account' do
|
|
7
|
+
it 'has no axe violations' do
|
|
8
|
+
visit '/account/create-account'
|
|
9
|
+
expect(page).to be_axe_clean
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe 'GET /login' do
|
|
14
|
+
it 'has no axe violations' do
|
|
15
|
+
visit '/account/login'
|
|
16
|
+
expect(page).to be_axe_clean
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe 'GET /reset-password-request' do
|
|
21
|
+
it 'has no axe violations' do
|
|
22
|
+
visit '/account/reset-password-request'
|
|
23
|
+
expect(page).to be_axe_clean
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# URLs locked to /en/, locale_kit's user_locale_resolver switches to the profile language once the session
|
|
28
|
+
# carries account_id and the login form would render in Swedish, breaking click_button 'Login'
|
|
29
|
+
describe 'GET /account/profile (authenticated)' do
|
|
30
|
+
it 'has no axe violations' do
|
|
31
|
+
email = Faker::Internet.email(name: "wcag-#{SecureRandom.hex(4)}")
|
|
32
|
+
password = 'correct horse battery staple'
|
|
33
|
+
|
|
34
|
+
visit '/en/account/create-account'
|
|
35
|
+
fill_in 'login', with: email
|
|
36
|
+
fill_in 'password', with: password
|
|
37
|
+
fill_in 'password-confirm', with: password if has_field?('password-confirm')
|
|
38
|
+
fill_in 'first_name', with: 'WCAG'
|
|
39
|
+
fill_in 'last_name', with: 'Tester'
|
|
40
|
+
fill_in 'address', with: '1 Test St'
|
|
41
|
+
fill_in 'postal_code', with: '12345'
|
|
42
|
+
fill_in 'city', with: 'Stockholm'
|
|
43
|
+
select 'Sweden', from: 'country'
|
|
44
|
+
fill_in 'mobile_number', with: '+46709876543'
|
|
45
|
+
fill_in 'personal_identity_number', with: Faker::IDNumber.swedish_personal_identity_number
|
|
46
|
+
click_button 'Create Account'
|
|
47
|
+
|
|
48
|
+
account = Account.first(email: email)
|
|
49
|
+
account.update(status_id: 2)
|
|
50
|
+
DB[:account_verification_keys].where(id: account.id).delete
|
|
51
|
+
|
|
52
|
+
visit '/en/account/login'
|
|
53
|
+
fill_in 'login', with: email
|
|
54
|
+
fill_in 'password', with: password
|
|
55
|
+
click_button 'Login'
|
|
56
|
+
|
|
57
|
+
visit '/en/account/profile'
|
|
58
|
+
expect(page).to be_axe_clean
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'WCAG: legal pages' do
|
|
6
|
+
describe 'GET /legal/contact' do
|
|
7
|
+
it 'has no axe violations' do
|
|
8
|
+
visit '/legal/contact'
|
|
9
|
+
expect(page).to be_axe_clean
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe 'GET /legal/privacy' do
|
|
14
|
+
it 'has no axe violations' do
|
|
15
|
+
visit '/legal/privacy'
|
|
16
|
+
expect(page).to be_axe_clean
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe 'GET /legal/cookies' do
|
|
21
|
+
it 'has no axe violations' do
|
|
22
|
+
visit '/legal/cookies'
|
|
23
|
+
expect(page).to be_axe_clean
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe 'GET /legal/disclaimer' do
|
|
28
|
+
it 'has no axe violations' do
|
|
29
|
+
visit '/legal/disclaimer'
|
|
30
|
+
expect(page).to be_axe_clean
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require_relative '../../lib/daemon/base'
|
|
5
|
+
|
|
6
|
+
RSpec.describe Daemons::Base do
|
|
7
|
+
let(:logger) { instance_double(Logger, info: nil) }
|
|
8
|
+
|
|
9
|
+
# stub_const names the anonymous class, #tag reads self.class.name
|
|
10
|
+
let(:daemon_class) do
|
|
11
|
+
stub_const('Daemons::TestDaemon', Class.new(Daemons::Base) do
|
|
12
|
+
def initialize(**opts)
|
|
13
|
+
super
|
|
14
|
+
@ticks = 0
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
attr_reader :ticks
|
|
18
|
+
|
|
19
|
+
def tick
|
|
20
|
+
@ticks += 1
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def handle_demo(payload)
|
|
24
|
+
@last_payload = payload
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
attr_reader :last_payload
|
|
28
|
+
end)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe '#run_polling' do
|
|
32
|
+
it 'calls tick on each iteration until @stop is set, bookending with start/stop log lines' do
|
|
33
|
+
daemon = daemon_class.new(logger: logger)
|
|
34
|
+
# Don't clobber INT/TERM in the test process, stop the loop from inside the first tick
|
|
35
|
+
allow(daemon).to receive(:trap_signals!)
|
|
36
|
+
allow(daemon).to receive(:sleep) # don't actually wait 5s in tests
|
|
37
|
+
allow(daemon).to receive(:tick).and_wrap_original do |original|
|
|
38
|
+
original.call
|
|
39
|
+
daemon.instance_variable_set(:@stop, true)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
daemon.run_polling(interval: 0.01)
|
|
43
|
+
|
|
44
|
+
expect(daemon).to have_received(:tick).once
|
|
45
|
+
expect(logger).to have_received(:info).with(/starting/)
|
|
46
|
+
expect(logger).to have_received(:info).with(/stopping/)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe '#run_listening' do
|
|
51
|
+
# listen_job yields (channel, pid, payload) per notification and (nil, nil, nil) on timeout. The
|
|
52
|
+
# sequel-listen_job extension adds it at runtime, so the verified-double cop can't see it on Sequel::Database
|
|
53
|
+
let(:db_double) { double('DB') } # rubocop:disable RSpec/VerifiedDoubles
|
|
54
|
+
|
|
55
|
+
it 'dispatches a notification through #handle and ticks on the (nil, _, _) timeout event' do
|
|
56
|
+
daemon = daemon_class.new(logger: logger)
|
|
57
|
+
allow(daemon).to receive(:trap_signals!)
|
|
58
|
+
allow(db_double).to receive(:listen_job) do |_channels, **_opts, &block|
|
|
59
|
+
block.call(nil, 0, nil) # timeout → tick
|
|
60
|
+
block.call('demo', 0, 'hello') # notification → handle('demo', 'hello')
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
daemon.run_listening(db_double, %w[demo])
|
|
64
|
+
|
|
65
|
+
expect(daemon.ticks).to eq(1)
|
|
66
|
+
expect(daemon.last_payload).to eq('hello')
|
|
67
|
+
expect(logger).to have_received(:info).with(/listening on demo/)
|
|
68
|
+
expect(logger).to have_received(:info).with(/stopping/)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'breaks out of the listen loop when @stop is set before a yield' do
|
|
72
|
+
daemon = daemon_class.new(logger: logger)
|
|
73
|
+
allow(daemon).to receive(:trap_signals!)
|
|
74
|
+
daemon.instance_variable_set(:@stop, true)
|
|
75
|
+
allow(db_double).to receive(:listen_job) do |_channels, **_opts, &block|
|
|
76
|
+
block.call('demo', 0, 'ignored') # the break should fire first
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
daemon.run_listening(db_double, %w[demo])
|
|
80
|
+
|
|
81
|
+
expect(daemon.last_payload).to be_nil
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe '#handle' do
|
|
86
|
+
it 'silently ignores a channel with no matching handler method' do
|
|
87
|
+
daemon = daemon_class.new(logger: logger)
|
|
88
|
+
expect { daemon.handle('no_such_channel', 'payload') }.not_to raise_error
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe '#trap_signals!' do
|
|
93
|
+
it 'installs INT + TERM handlers that flip @stop to true' do
|
|
94
|
+
daemon = daemon_class.new(logger: logger)
|
|
95
|
+
captured = {}
|
|
96
|
+
# Kernel#trap is called via implicit self, so stubbing it on the daemon intercepts it
|
|
97
|
+
allow(daemon).to receive(:trap) { |sig, &blk| captured[sig] = blk }
|
|
98
|
+
|
|
99
|
+
daemon.send(:trap_signals!)
|
|
100
|
+
|
|
101
|
+
expect(captured.keys).to contain_exactly('INT', 'TERM')
|
|
102
|
+
captured['INT'].call
|
|
103
|
+
expect(daemon.instance_variable_get(:@stop)).to be true
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require_relative '../../lib/daemon/gdpr_worker'
|
|
5
|
+
|
|
6
|
+
RSpec.describe Daemons::GdprWorker do
|
|
7
|
+
let(:logger) { instance_double(Logger, info: nil, error: nil) }
|
|
8
|
+
let(:daemon) { described_class.new(db: DB, logger: logger) }
|
|
9
|
+
|
|
10
|
+
# The worker drains every pending request by design; under rake test:all
|
|
11
|
+
# earlier tiers share the database, so clear their leftovers or the
|
|
12
|
+
# erasure example fulfills strangers' requests too
|
|
13
|
+
before { GdprRequest.dataset.delete }
|
|
14
|
+
|
|
15
|
+
def create_subject
|
|
16
|
+
account = Account.create(email: Faker::Internet.email(name: "gdpr-#{SecureRandom.hex(4)}"), status_id: 2)
|
|
17
|
+
AccountProfile.create(
|
|
18
|
+
account_id: account.id,
|
|
19
|
+
first_name: Faker::Name.first_name, last_name: Faker::Name.last_name,
|
|
20
|
+
address: Faker::Address.street_address, postal_code: Faker::Address.zip_code,
|
|
21
|
+
city: Faker::Address.city, country: 'SE', language: 'sv',
|
|
22
|
+
time_zone: 'Europe/Stockholm', mobile_number: Faker::PhoneNumber.cell_phone,
|
|
23
|
+
personal_identity_number: Faker::IDNumber.swedish_personal_identity_number
|
|
24
|
+
)
|
|
25
|
+
account
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'exports an account without a profile using the default locale' do
|
|
29
|
+
account = Account.create(email: Faker::Internet.email(name: "gdpr-#{SecureRandom.hex(4)}"), status_id: 2)
|
|
30
|
+
request = GdprRequest.create(account_id: account.id, type: 'export')
|
|
31
|
+
|
|
32
|
+
daemon.handle_gdpr_request(request.pk.to_s)
|
|
33
|
+
|
|
34
|
+
mail = Mail::TestMailer.deliveries.last
|
|
35
|
+
expect(JSON.parse(mail.attachments.first.decoded)['profile']).to be_nil
|
|
36
|
+
expect(request.refresh.status).to eq('done')
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'fulfills an export by emailing the data as a JSON attachment' do
|
|
40
|
+
account = create_subject
|
|
41
|
+
request = GdprRequest.create(account_id: account.id, type: 'export')
|
|
42
|
+
|
|
43
|
+
daemon.handle_gdpr_request(request.pk.to_s)
|
|
44
|
+
|
|
45
|
+
mail = Mail::TestMailer.deliveries.last
|
|
46
|
+
expect(mail.attachments.first.filename).to end_with('.json')
|
|
47
|
+
expect(JSON.parse(mail.attachments.first.decoded)['account']['email']).to eq(account.email)
|
|
48
|
+
expect(request.refresh.status).to eq('done')
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'fulfills an erasure, strips the profile, and emails a confirmation' do
|
|
52
|
+
account = create_subject
|
|
53
|
+
request = GdprRequest.create(account_id: account.id, type: 'erase')
|
|
54
|
+
|
|
55
|
+
daemon.handle_gdpr_request(nil)
|
|
56
|
+
|
|
57
|
+
expect(AccountProfile.where(account_id: account.id).count).to eq(0)
|
|
58
|
+
expect(Mail::TestMailer.deliveries.size).to eq(1)
|
|
59
|
+
expect(request.refresh.status).to eq('done')
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'marks a request failed when fulfillment raises' do
|
|
63
|
+
account = create_subject
|
|
64
|
+
request = GdprRequest.create(account_id: account.id, type: 'export')
|
|
65
|
+
allow(Gdpr).to receive(:export).and_raise('boom')
|
|
66
|
+
|
|
67
|
+
daemon.handle_gdpr_request(nil)
|
|
68
|
+
|
|
69
|
+
expect(request.refresh.status).to eq('failed')
|
|
70
|
+
expect(request.refresh.error).to include('boom')
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require_relative '../../lib/daemon/push_sender'
|
|
5
|
+
|
|
6
|
+
RSpec.describe Daemons::PushSender do
|
|
7
|
+
let(:logger) { instance_double(Logger, info: nil) }
|
|
8
|
+
let(:daemon) { described_class.new(db: DB, logger: logger) }
|
|
9
|
+
|
|
10
|
+
describe '#handle_send_push' do
|
|
11
|
+
it 'delivers to each of the account subscriptions, VAPID-signed' do
|
|
12
|
+
account = create_account_with_profile(language: 'sv')
|
|
13
|
+
sub = create_subscription(account)
|
|
14
|
+
allow(WebPush).to receive(:payload_send)
|
|
15
|
+
|
|
16
|
+
daemon.handle_send_push(account.id.to_s)
|
|
17
|
+
|
|
18
|
+
expect(WebPush).to have_received(:payload_send).with(
|
|
19
|
+
hash_including(endpoint: sub[:endpoint], p256dh: sub[:p256dh],
|
|
20
|
+
auth: sub[:auth_key], vapid: <%= @app.camel %>::VAPID_OPTIONS)
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'is a no-op when no account matches the payload' do
|
|
25
|
+
allow(WebPush).to receive(:payload_send)
|
|
26
|
+
daemon.handle_send_push('0')
|
|
27
|
+
expect(WebPush).not_to have_received(:payload_send)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'falls back to the default locale for an account with no profile' do
|
|
31
|
+
account = Account.create(email: Faker::Internet.email(name: "push-#{SecureRandom.hex(4)}"), status_id: 2)
|
|
32
|
+
create_subscription(account)
|
|
33
|
+
allow(WebPush).to receive(:payload_send)
|
|
34
|
+
daemon.handle_send_push(account.id.to_s)
|
|
35
|
+
expect(WebPush).to have_received(:payload_send)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'prunes a subscription the push service reports as gone' do
|
|
39
|
+
account = create_account_with_profile(language: 'en')
|
|
40
|
+
create_subscription(account)
|
|
41
|
+
# ResponseError#initialize reads response.body, so it needs a stub response
|
|
42
|
+
gone = WebPush::ExpiredSubscription.new(instance_double(Net::HTTPGone, body: ''), 'push.example.com')
|
|
43
|
+
allow(WebPush).to receive(:payload_send).and_raise(gone)
|
|
44
|
+
|
|
45
|
+
expect { daemon.handle_send_push(account.id.to_s) }
|
|
46
|
+
.to change { PushSubscription.where(account_id: account.id).count }.from(1).to(0)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def create_subscription(account)
|
|
50
|
+
row = { account_id: account.id, endpoint: Faker::Internet.url,
|
|
51
|
+
p256dh: SecureRandom.base64(32), auth_key: SecureRandom.base64(16) }
|
|
52
|
+
PushSubscription.create(row)
|
|
53
|
+
row
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def create_account_with_profile(language:)
|
|
57
|
+
account = Account.create(email: Faker::Internet.email(name: "push-#{SecureRandom.hex(4)}"), status_id: 2)
|
|
58
|
+
AccountProfile.create(
|
|
59
|
+
account_id: account.id,
|
|
60
|
+
first_name: Faker::Name.first_name,
|
|
61
|
+
last_name: Faker::Name.last_name,
|
|
62
|
+
address: Faker::Address.street_address,
|
|
63
|
+
postal_code: Faker::Address.zip_code,
|
|
64
|
+
city: Faker::Address.city,
|
|
65
|
+
country: 'SE',
|
|
66
|
+
language: language,
|
|
67
|
+
time_zone: 'Europe/Stockholm',
|
|
68
|
+
mobile_number: Faker::PhoneNumber.cell_phone,
|
|
69
|
+
personal_identity_number: Faker::IDNumber.swedish_personal_identity_number
|
|
70
|
+
)
|
|
71
|
+
account
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'yaml'
|
|
5
|
+
|
|
6
|
+
# locales/rodauth/ only checks OVERRIDE_LANGS (de/en/es/fr/it), sv/tru are full translations
|
|
7
|
+
# on rodauth-i18n's shape, not overrides
|
|
8
|
+
module LocaleParityHelpers
|
|
9
|
+
# Not LOCALES_DIR, 30_i18n.rb defines that in the same process at test:all
|
|
10
|
+
LOCALES_ROOT = File.expand_path('../locales', __dir__)
|
|
11
|
+
|
|
12
|
+
OVERRIDE_LANGS = %i[de en es fr it].freeze
|
|
13
|
+
|
|
14
|
+
module_function
|
|
15
|
+
|
|
16
|
+
def flatten_keys(hash, prefix = '')
|
|
17
|
+
hash.flat_map do |k, v|
|
|
18
|
+
path = prefix.empty? ? k.to_s : "#{prefix}.#{k}"
|
|
19
|
+
v.is_a?(Hash) ? flatten_keys(v, path) : [path]
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def keys_at(yaml_path, locale)
|
|
24
|
+
data = YAML.safe_load_file(yaml_path)
|
|
25
|
+
flatten_keys(data.fetch(locale.to_s)).sort
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# RSpec/DescribeClass: a YAML-file invariant across files, not a class
|
|
30
|
+
RSpec.describe 'locale parity' do # rubocop:disable RSpec/DescribeClass
|
|
31
|
+
describe 'locales/*.yml (app strings)' do
|
|
32
|
+
# An empty glob would produce zero examples and pass, so raise instead
|
|
33
|
+
locales = Dir["#{LocaleParityHelpers::LOCALES_ROOT}/*.yml"]
|
|
34
|
+
.map { File.basename(it, '.yml').to_sym }
|
|
35
|
+
.reject { it == :en }
|
|
36
|
+
raise "no locale files found under #{LocaleParityHelpers::LOCALES_ROOT} — path probably wrong" if locales.empty?
|
|
37
|
+
|
|
38
|
+
locales.each do |locale|
|
|
39
|
+
it "#{locale}.yml has every key present in en.yml" do
|
|
40
|
+
en_keys = LocaleParityHelpers.keys_at("#{LocaleParityHelpers::LOCALES_ROOT}/en.yml", :en)
|
|
41
|
+
actual = LocaleParityHelpers.keys_at("#{LocaleParityHelpers::LOCALES_ROOT}/#{locale}.yml", locale)
|
|
42
|
+
missing = en_keys - actual
|
|
43
|
+
expect(missing).to be_empty, "#{locale}.yml is missing #{missing.size} key(s): #{missing.join(', ')}"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe 'locales/rodauth/*.yml (scaffold rodauth overrides)' do
|
|
49
|
+
(LocaleParityHelpers::OVERRIDE_LANGS - %i[en]).each do |locale|
|
|
50
|
+
it "rodauth/#{locale}.yml has every override key present in rodauth/en.yml" do
|
|
51
|
+
en_keys = LocaleParityHelpers.keys_at("#{LocaleParityHelpers::LOCALES_ROOT}/rodauth/en.yml", :en)
|
|
52
|
+
actual = LocaleParityHelpers.keys_at("#{LocaleParityHelpers::LOCALES_ROOT}/rodauth/#{locale}.yml", locale)
|
|
53
|
+
missing = en_keys - actual
|
|
54
|
+
expect(missing).to be_empty, "rodauth/#{locale}.yml is missing #{missing.size} key(s): #{missing.join(', ')}"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|