From 30f14ff3b0f653eb011f8f2558d69b440e5d9326 Mon Sep 17 00:00:00 2001 From: Nelson Date: Fri, 14 Oct 2022 11:43:03 -0400 Subject: [PATCH] Localhost by default - remove `https://` assumption throughout codebase (#1518) * use ShopifyAPI::Context.host instead of assume https:// * use host scheme correctly * use ShopifyAPI::Context.host instead of composition * restore domain_host pattern * always tls with current_shopify_domain * typo + revert to tls default with cookies * 12.0 shopify_api dependency * update 12.1.0 API * rubocop updates * docs, readme, and changelog for localhost --- .rubocop.yml | 2 + CHANGELOG.md | 1 + Gemfile.lock | 192 ++++++++++-------- README.md | 11 +- .../shopify_app/ensure_authenticated_links.rb | 2 +- .../shopify_app/callback_controller.rb | 4 +- .../shopify_app/sessions_controller.rb | 2 +- .../shopify_app/webhooks_controller.rb | 2 +- docs/Quickstart.md | 8 +- .../add_after_authenticate_job_generator.rb | 2 +- ..._marketing_activity_extension_generator.rb | 2 +- .../add_webhook/add_webhook_generator.rb | 4 +- .../app_proxy_controller_generator.rb | 2 +- .../shopify_app/install/install_generator.rb | 4 +- .../install/templates/shopify_app.rb.tt | 2 +- .../templates/rotate_shopify_token.rake | 2 +- .../shopify_app/routes/routes_generator.rb | 2 +- .../shop_model/shop_model_generator.rb | 2 +- .../user_model/user_model_generator.rb | 2 +- .../app_proxy_verification.rb | 4 +- .../controller_concerns/ensure_billing.rb | 6 +- .../controller_concerns/frame_ancestors.rb | 2 +- .../controller_concerns/login_protection.rb | 2 +- .../payload_verification.rb | 2 +- .../redirect_for_embedded.rb | 2 +- .../controller_concerns/sanitized_params.rb | 1 + .../managers/scripttags_manager.rb | 2 +- lib/shopify_app/managers/webhooks_manager.rb | 4 +- lib/shopify_app/session/jwt.rb | 1 + .../session/shop_session_storage.rb | 2 +- .../shop_session_storage_with_scopes.rb | 2 +- .../session/user_session_storage.rb | 4 +- .../user_session_storage_with_scopes.rb | 4 +- shopify_app.gemspec | 3 +- .../concerns/ensure_billing_test.rb | 2 +- test/generators/install_generator_test.rb | 2 +- test/integration/webhooks_controller_test.rb | 2 +- test/routes/webhooks_routes_test.rb | 2 +- .../access_scopes/shop_strategy_test.rb | 2 +- .../access_scopes/user_strategy_test.rb | 2 +- .../login_protection_test.rb | 22 +- .../session/session_repository_test.rb | 4 +- .../session/shop_session_storage_test.rb | 2 +- .../shop_session_storage_with_scopes_test.rb | 8 +- .../session/user_session_storage_test.rb | 8 +- .../user_session_storage_with_scopes_test.rb | 14 +- test/utils/rails_generator_runtime.rb | 4 +- 47 files changed, 193 insertions(+), 170 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 37f576427..c640f7065 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -16,3 +16,5 @@ Style/ClassAndModuleChildren: Exclude: - 'test/**/*' +Style/ClassMethodsDefinitions: + Enabled: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 66a411e93..ebcdb4db4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ Unreleased ---------- +* Removes assumed `https` required to run locally. Support both `http` and `https` in backward compatible way. [#1518](https://github.com/Shopify/shopify_app/pull/1518) 21.0.0 (Oct 3, 2022) ---------- diff --git a/Gemfile.lock b/Gemfile.lock index 96cace086..2c36458ed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,81 +7,87 @@ PATH jwt (>= 2.2.3) rails (> 5.2.1) redirect_safely (~> 1.0) - shopify_api (~> 12.0.0) + shopify_api (~> 12.1) sprockets-rails (>= 2.0.0) GEM remote: https://rubygems.org/ specs: - actioncable (6.1.5) - actionpack (= 6.1.5) - activesupport (= 6.1.5) + actioncable (7.0.4) + actionpack (= 7.0.4) + activesupport (= 7.0.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.5) - actionpack (= 6.1.5) - activejob (= 6.1.5) - activerecord (= 6.1.5) - activestorage (= 6.1.5) - activesupport (= 6.1.5) + actionmailbox (7.0.4) + actionpack (= 7.0.4) + activejob (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) mail (>= 2.7.1) - actionmailer (6.1.5) - actionpack (= 6.1.5) - actionview (= 6.1.5) - activejob (= 6.1.5) - activesupport (= 6.1.5) + net-imap + net-pop + net-smtp + actionmailer (7.0.4) + actionpack (= 7.0.4) + actionview (= 7.0.4) + activejob (= 7.0.4) + activesupport (= 7.0.4) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.5) - actionview (= 6.1.5) - activesupport (= 6.1.5) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.4) + actionview (= 7.0.4) + activesupport (= 7.0.4) + rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.5) - actionpack (= 6.1.5) - activerecord (= 6.1.5) - activestorage (= 6.1.5) - activesupport (= 6.1.5) + actiontext (7.0.4) + actionpack (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.5) - activesupport (= 6.1.5) + actionview (7.0.4) + activesupport (= 7.0.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.5) - activesupport (= 6.1.5) + activejob (7.0.4) + activesupport (= 7.0.4) globalid (>= 0.3.6) - activemodel (6.1.5) - activesupport (= 6.1.5) + activemodel (7.0.4) + activesupport (= 7.0.4) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (6.1.5) - activemodel (= 6.1.5) - activesupport (= 6.1.5) + activerecord (7.0.4) + activemodel (= 7.0.4) + activesupport (= 7.0.4) activeresource (6.0.0) activemodel (>= 6.0) activemodel-serializers-xml (~> 1.0) activesupport (>= 6.0) - activestorage (6.1.5) - actionpack (= 6.1.5) - activejob (= 6.1.5) - activerecord (= 6.1.5) - activesupport (= 6.1.5) + activestorage (7.0.4) + actionpack (= 7.0.4) + activejob (= 7.0.4) + activerecord (= 7.0.4) + activesupport (= 7.0.4) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.5) + activesupport (7.0.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) binding_of_caller (1.0.0) debug_inspector (>= 0.0.1) @@ -94,7 +100,7 @@ GEM rexml crass (1.0.6) debug_inspector (1.1.0) - erubi (1.10.0) + erubi (1.11.0) globalid (1.0.0) activesupport (>= 5.0) hash_diff (1.1.1) @@ -102,10 +108,11 @@ GEM httparty (0.20.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.10.0) + i18n (1.12.0) concurrent-ruby (~> 1.0) + json (2.6.2) jwt (2.5.0) - loofah (2.15.0) + loofah (2.19.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -117,17 +124,25 @@ GEM mime-types-data (3.2022.0105) mini_mime (1.1.2) mini_portile2 (2.8.0) - minitest (5.15.0) - mocha (1.13.0) + minitest (5.16.3) + mocha (1.15.0) multi_xml (0.6.0) + net-imap (0.3.1) + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.1.3) + timeout + net-smtp (0.3.2) + net-protocol nio4r (2.5.8) - nokogiri (1.13.4) + nokogiri (1.13.8) mini_portile2 (~> 2.8.0) racc (~> 1.4) oj (3.13.21) openssl (3.0.1) - parallel (1.21.0) - parser (3.1.0.0) + parallel (1.22.1) + parser (3.1.2.1) ast (~> 2.4.1) pry (0.14.1) coderay (~> 1.1) @@ -137,26 +152,25 @@ GEM pry-stack_explorer (0.6.1) binding_of_caller (~> 1.0) pry (~> 0.13) - public_suffix (4.0.6) + public_suffix (5.0.0) racc (1.6.0) - rack (2.2.3) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (6.1.5) - actioncable (= 6.1.5) - actionmailbox (= 6.1.5) - actionmailer (= 6.1.5) - actionpack (= 6.1.5) - actiontext (= 6.1.5) - actionview (= 6.1.5) - activejob (= 6.1.5) - activemodel (= 6.1.5) - activerecord (= 6.1.5) - activestorage (= 6.1.5) - activesupport (= 6.1.5) + rack (2.2.4) + rack-test (2.0.2) + rack (>= 1.3) + rails (7.0.4) + actioncable (= 7.0.4) + actionmailbox (= 7.0.4) + actionmailer (= 7.0.4) + actionpack (= 7.0.4) + actiontext (= 7.0.4) + actionview (= 7.0.4) + activejob (= 7.0.4) + activemodel (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) bundler (>= 1.15.0) - railties (= 6.1.5) - sprockets-rails (>= 2.0.0) + railties (= 7.0.4) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -164,37 +178,39 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.4.2) + rails-html-sanitizer (1.4.3) loofah (~> 2.3) - railties (6.1.5) - actionpack (= 6.1.5) - activesupport (= 6.1.5) + railties (7.0.4) + actionpack (= 7.0.4) + activesupport (= 7.0.4) method_source rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) rb-readline (0.5.5) redirect_safely (1.0.0) activemodel - regexp_parser (2.2.0) + regexp_parser (2.6.0) rexml (3.2.5) - rubocop (1.25.1) + rubocop (1.36.0) + json (~> 2.3) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.15.1, < 2.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.20.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.15.1) - parser (>= 3.0.1.1) - rubocop-shopify (2.4.0) - rubocop (~> 1.24) + rubocop-ast (1.21.0) + parser (>= 3.1.1.0) + rubocop-shopify (2.10.1) + rubocop (~> 1.35) ruby-progressbar (1.11.0) securerandom (0.2.0) - shopify_api (12.0.0) + shopify_api (12.1.0) concurrent-ruby hash_diff httparty @@ -204,7 +220,7 @@ GEM securerandom sorbet-runtime zeitwerk (~> 2.5) - sorbet-runtime (0.5.10477) + sorbet-runtime (0.5.10486) sprockets (4.1.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -212,12 +228,14 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.4.2) + sqlite3 (1.5.3) + mini_portile2 (~> 2.8.0) thor (1.2.1) - tzinfo (2.0.4) + timeout (0.3.0) + tzinfo (2.0.5) concurrent-ruby (~> 1.0) - unicode-display_width (2.1.0) - webmock (3.14.0) + unicode-display_width (2.3.0) + webmock (3.18.1) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) diff --git a/README.md b/README.md index ee3455551..32cbac934 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,10 @@ rails new my_shopify_app bundle add shopify_app ``` -3. Create a `.env` file in the root of `my_shopify_app` to specify your Shopify API credentials: +3. Create a `.env` file in the root of `my_shopify_app` to specify your full host and Shopify API credentials: ```sh +HOST=http://localhost:3000 SHOPIFY_API_KEY= SHOPIFY_API_SECRET= ``` @@ -67,17 +68,15 @@ rails generate shopify_app rails db:migrate ``` -6. Setup a SSH tunnel to allow the OAuth redirect to work. See how in the [Setup SSH tunnel for development](/docs/Quickstart.md#setup-ssh-tunnel-for-development) section in [Quickstart](/docs/Quickstart.md) - -7. Run the app: +6. Run the app: ```sh rails server ``` -8. Install the app by visiting the server's URL (e.g. http://127.0.0.1:3000) and specifying the subdomain of the shop where you want it to be installed to. +7. Install the app by visiting the server's URL (e.g. http://127.0.0.1:3000) and specifying the subdomain of the shop where you want it to be installed to. -9. After the app is installed, you're redirected to the embedded app. +8. After the app is installed, you're redirected to the embedded app. This app implements [OAuth 2.0](https://shopify.dev/tutorials/authenticate-with-oauth) with Shopify to authenticate requests made to Shopify APIs. By default, this app is configured to use [session tokens](https://shopify.dev/concepts/apps/building-embedded-apps-using-session-tokens) to authenticate merchants when embedded in the Shopify Admin. diff --git a/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb b/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb index 7fba59de1..be6934475 100644 --- a/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb +++ b/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb @@ -14,7 +14,7 @@ def splash_page splash_page_with_params( return_to: request.fullpath, shop: current_shopify_domain, - host: params[:host] + host: params[:host], ) end diff --git a/app/controllers/shopify_app/callback_controller.rb b/app/controllers/shopify_app/callback_controller.rb index 3db77d3e2..b27e2f6b9 100644 --- a/app/controllers/shopify_app/callback_controller.rb +++ b/app/controllers/shopify_app/callback_controller.rb @@ -15,7 +15,7 @@ def callback ShopifyAPI::Auth::Oauth::SessionCookie::SESSION_COOKIE_NAME => cookies.encrypted[ShopifyAPI::Auth::Oauth::SessionCookie::SESSION_COOKIE_NAME], }, - auth_query: ShopifyAPI::Auth::Oauth::AuthQuery.new(**filtered_params) + auth_query: ShopifyAPI::Auth::Oauth::AuthQuery.new(**filtered_params), ) rescue return respond_with_error @@ -95,7 +95,7 @@ def install_scripttags(session) ScripttagsManager.queue( session.shop, session.access_token, - ShopifyApp.configuration.scripttags + ShopifyApp.configuration.scripttags, ) end diff --git a/app/controllers/shopify_app/sessions_controller.rb b/app/controllers/shopify_app/sessions_controller.rb index 2fb30e46a..87acf161a 100644 --- a/app/controllers/shopify_app/sessions_controller.rb +++ b/app/controllers/shopify_app/sessions_controller.rb @@ -56,7 +56,7 @@ def start_oauth auth_attributes = ShopifyAPI::Auth::Oauth.begin_auth( shop: sanitized_shop_name, redirect_path: "/#{callback_url}", - is_online: user_session_expected? + is_online: user_session_expected?, ) cookies.encrypted[auth_attributes[:cookie].name] = { expires: auth_attributes[:cookie].expires, diff --git a/app/controllers/shopify_app/webhooks_controller.rb b/app/controllers/shopify_app/webhooks_controller.rb index 033fd064a..35939f583 100644 --- a/app/controllers/shopify_app/webhooks_controller.rb +++ b/app/controllers/shopify_app/webhooks_controller.rb @@ -8,7 +8,7 @@ def receive params.permit! ShopifyAPI::Webhooks::Registry.process( - ShopifyAPI::Webhooks::Request.new(raw_body: request.raw_post, headers: request.headers.to_h) + ShopifyAPI::Webhooks::Request.new(raw_body: request.raw_post, headers: request.headers.to_h), ) head(:ok) end diff --git a/docs/Quickstart.md b/docs/Quickstart.md index 1b052dfae..5b6e3f14c 100644 --- a/docs/Quickstart.md +++ b/docs/Quickstart.md @@ -4,13 +4,15 @@ This guide assumes you have completed the steps to create a new Rails app using #### Table of contents -[Setup SSH tunnel for development](#setup-ssh-tunnel-for-development) +[Optionally Setup SSH tunnel for development](#setup-ssh-tunnel-for-development) [Use Shopify App Bridge to embed your app in the Shopify Admin](#use-shopify-app-bridge-to-embed-your-app-in-the-shopify-admin) -## Setup SSH tunnel for development +## Optionally Setup SSH tunnel for development -Your local app needs to be accessible from the public Internet in order to install it on a Shopify store, to use the [App Proxy Controller](/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_controller.rb) or receive [webhooks](/docs/shopify_app/webhooks.md). +Local development supports both `http` and `https` schemes. By default `http` and localhost are used. + +To use `https`, your local app needs to be accessible from the public Internet in order to install it on a Shopify store to use the [App Proxy Controller](/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_controller.rb) or receive [webhooks](/docs/shopify_app/webhooks.md). In order to receive requests securely, you'll need to setup a tunnel from the internet to localhost. You can use [Cloudflare](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/run-tunnel/trycloudflare/) for this. diff --git a/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb b/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb index 62fa3adc0..aa2aa21ee 100644 --- a/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +++ b/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb @@ -21,7 +21,7 @@ def init_after_authenticate_config inject_into_file( "config/initializers/shopify_app.rb", after_authenticate_job_config, - before: "end" + before: "end", ) unless initializer.include?(after_authenticate_job_config) diff --git a/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb b/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb index c3b573110..6b1b4f95f 100644 --- a/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb +++ b/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb @@ -18,7 +18,7 @@ def generate_routes inject_into_file( "config/routes.rb", optimize_indentation(routes, 2), - after: "root :to => 'home#index'\n" + after: "root :to => 'home#index'\n", ) end diff --git a/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb b/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb index 3d85c431f..26697fe37 100644 --- a/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb +++ b/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb @@ -20,7 +20,7 @@ def init_webhook_config inject_into_file( "config/initializers/shopify_app.rb", " config.webhooks = [\n ]\n", - after: /ShopifyApp\.configure.*\n/ + after: /ShopifyApp\.configure.*\n/, ) end @@ -28,7 +28,7 @@ def inject_webhook_to_shopify_app_initializer inject_into_file( "config/initializers/shopify_app.rb", webhook_config, - after: "config.webhooks = [" + after: "config.webhooks = [", ) initializer = load_initializer diff --git a/lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb b/lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb index 7bf31c5e7..e9110cfcf 100644 --- a/lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb +++ b/lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb @@ -19,7 +19,7 @@ def add_app_proxy_route inject_into_file( "config/routes.rb", File.read(File.expand_path(find_in_source_paths("app_proxy_route.rb"))), - after: "mount ShopifyApp::Engine, at: '/'\n" + after: "mount ShopifyApp::Engine, at: '/'\n", ) end end diff --git a/lib/generators/shopify_app/install/install_generator.rb b/lib/generators/shopify_app/install/install_generator.rb index 57e0d5b2c..da16c0527 100644 --- a/lib/generators/shopify_app/install/install_generator.rb +++ b/lib/generators/shopify_app/install/install_generator.rb @@ -66,7 +66,7 @@ def add_comment_explaining_tunnel_host(provider_name, insert_after_line) inject_into_file( "config/environments/development.rb", comment, - after: insert_after_line + after: insert_after_line, ) comment end @@ -78,7 +78,7 @@ def insert_tunnel_host_rules(provider_name, insert_after_line, provider_host_dom inject_into_file( "config/environments/development.rb", host_line, - after: explaination_comment + after: explaination_comment, ) host_line end diff --git a/lib/generators/shopify_app/install/templates/shopify_app.rb.tt b/lib/generators/shopify_app/install/templates/shopify_app.rb.tt index 1539420b1..c3193a1b0 100644 --- a/lib/generators/shopify_app/install/templates/shopify_app.rb.tt +++ b/lib/generators/shopify_app/install/templates/shopify_app.rb.tt @@ -38,7 +38,7 @@ Rails.application.config.after_initialize do api_key: ShopifyApp.configuration.api_key, api_secret_key: ShopifyApp.configuration.secret, api_version: ShopifyApp.configuration.api_version, - host_name: URI(ENV.fetch('HOST', '')).host || '', + host: ENV['HOST'], scope: ShopifyApp.configuration.scope, is_private: !ENV.fetch('SHOPIFY_APP_PRIVATE_SHOP', '').empty?, is_embedded: ShopifyApp.configuration.embedded_app, diff --git a/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token.rake b/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token.rake index 1e9710e79..c8cca7d50 100644 --- a/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token.rake +++ b/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token.rake @@ -6,7 +6,7 @@ namespace :shopify do all_active_shops.find_each do |shop| Shopify::RotateShopifyTokenJob.perform_later( shop_domain: shop.shopify_domain, - refresh_token: args[:refresh_token] + refresh_token: args[:refresh_token], ) end end diff --git a/lib/generators/shopify_app/routes/routes_generator.rb b/lib/generators/shopify_app/routes/routes_generator.rb index 676db8bfd..3444b8014 100644 --- a/lib/generators/shopify_app/routes/routes_generator.rb +++ b/lib/generators/shopify_app/routes/routes_generator.rb @@ -15,7 +15,7 @@ def disable_engine_routes gsub_file( "config/routes.rb", "mount ShopifyApp::Engine, at: '/'", - "" + "", ) end diff --git a/lib/generators/shopify_app/shop_model/shop_model_generator.rb b/lib/generators/shopify_app/shop_model/shop_model_generator.rb index afc76a154..f3caacf31 100644 --- a/lib/generators/shopify_app/shop_model/shop_model_generator.rb +++ b/lib/generators/shopify_app/shop_model/shop_model_generator.rb @@ -35,7 +35,7 @@ def create_shop_with_access_scopes_migration if new_shopify_cli_app? || Rails.env.test? || yes?(scopes_column_prompt) migration_template( "db/migrate/add_shop_access_scopes_column.erb", - "db/migrate/add_shop_access_scopes_column.rb" + "db/migrate/add_shop_access_scopes_column.rb", ) end end diff --git a/lib/generators/shopify_app/user_model/user_model_generator.rb b/lib/generators/shopify_app/user_model/user_model_generator.rb index add0a800e..9b6ab5c43 100644 --- a/lib/generators/shopify_app/user_model/user_model_generator.rb +++ b/lib/generators/shopify_app/user_model/user_model_generator.rb @@ -35,7 +35,7 @@ def create_scopes_storage_in_user_model if new_shopify_cli_app? || Rails.env.test? || yes?(scopes_column_prompt) migration_template( "db/migrate/add_user_access_scopes_column.erb", - "db/migrate/add_user_access_scopes_column.rb" + "db/migrate/add_user_access_scopes_column.rb", ) end end diff --git a/lib/shopify_app/controller_concerns/app_proxy_verification.rb b/lib/shopify_app/controller_concerns/app_proxy_verification.rb index 9000f16d7..1f0741700 100644 --- a/lib/shopify_app/controller_concerns/app_proxy_verification.rb +++ b/lib/shopify_app/controller_concerns/app_proxy_verification.rb @@ -22,7 +22,7 @@ def query_string_valid?(query_string) ActiveSupport::SecurityUtils.secure_compare( calculated_signature(query_hash), - signature + signature, ) end @@ -32,7 +32,7 @@ def calculated_signature(query_hash_without_signature) OpenSSL::HMAC.hexdigest( OpenSSL::Digest.new("sha256"), ShopifyApp.configuration.secret, - sorted_params + sorted_params, ) end end diff --git a/lib/shopify_app/controller_concerns/ensure_billing.rb b/lib/shopify_app/controller_concerns/ensure_billing.rb index a0a5d19e3..a3a7fa27f 100644 --- a/lib/shopify_app/controller_concerns/ensure_billing.rb +++ b/lib/shopify_app/controller_concerns/ensure_billing.rb @@ -98,7 +98,7 @@ def has_one_time_payment?(session) def request_payment(session) shop = session.shop host = Base64.encode64("#{shop}/admin") - return_url = "https://#{ShopifyAPI::Context.host_name}?shop=#{shop}&host=#{host}" + return_url = "#{ShopifyAPI::Context.host}?shop=#{shop}&host=#{host}" if recurring? data = request_recurring_payment(session: session, return_url: return_url) @@ -132,7 +132,7 @@ def request_recurring_payment(session:, return_url:) }, returnUrl: return_url, test: !Rails.env.production?, - } + }, ) response.body @@ -150,7 +150,7 @@ def request_one_time_payment(session:, return_url:) }, returnUrl: return_url, test: !Rails.env.production?, - } + }, ) response.body diff --git a/lib/shopify_app/controller_concerns/frame_ancestors.rb b/lib/shopify_app/controller_concerns/frame_ancestors.rb index b7701a4c6..d3dd7dd0d 100644 --- a/lib/shopify_app/controller_concerns/frame_ancestors.rb +++ b/lib/shopify_app/controller_concerns/frame_ancestors.rb @@ -8,7 +8,7 @@ module FrameAncestors content_security_policy do |policy| policy.frame_ancestors(-> do domain_host = current_shopify_domain || "*.#{::ShopifyApp.configuration.myshopify_domain}" - "https://#{domain_host} https://admin.shopify.com" + "#{ShopifyAPI::Context.host_scheme}://#{domain_host} https://admin.shopify.com" end) end end diff --git a/lib/shopify_app/controller_concerns/login_protection.rb b/lib/shopify_app/controller_concerns/login_protection.rb index 4f7f367ee..77399cb1e 100644 --- a/lib/shopify_app/controller_concerns/login_protection.rb +++ b/lib/shopify_app/controller_concerns/login_protection.rb @@ -42,7 +42,7 @@ def current_shopify_session ShopifyAPI::Utils::SessionUtils.load_current_session( auth_header: request.headers["HTTP_AUTHORIZATION"], cookies: { cookie_name => cookies.encrypted[cookie_name] }, - is_online: user_session_expected? + is_online: user_session_expected?, ) rescue ShopifyAPI::Errors::CookieNotFoundError nil diff --git a/lib/shopify_app/controller_concerns/payload_verification.rb b/lib/shopify_app/controller_concerns/payload_verification.rb index 743caf9e4..c14128055 100644 --- a/lib/shopify_app/controller_concerns/payload_verification.rb +++ b/lib/shopify_app/controller_concerns/payload_verification.rb @@ -17,7 +17,7 @@ def hmac_valid?(data) digest = OpenSSL::Digest.new("sha256") ActiveSupport::SecurityUtils.secure_compare( shopify_hmac, - Base64.strict_encode64(OpenSSL::HMAC.digest(digest, secret, data)) + Base64.strict_encode64(OpenSSL::HMAC.digest(digest, secret, data)), ) end end diff --git a/lib/shopify_app/controller_concerns/redirect_for_embedded.rb b/lib/shopify_app/controller_concerns/redirect_for_embedded.rb index 88704f79d..169431c5c 100644 --- a/lib/shopify_app/controller_concerns/redirect_for_embedded.rb +++ b/lib/shopify_app/controller_concerns/redirect_for_embedded.rb @@ -21,7 +21,7 @@ def redirect_for_embedded def redirect_uri_for_embedded redirect_query_params = {} - redirect_uri = "https://#{ShopifyAPI::Context.host_name}#{ShopifyApp.configuration.login_url}" + redirect_uri = "#{ShopifyAPI::Context.host}#{ShopifyApp.configuration.login_url}" redirect_query_params[:shop] = sanitized_shop_name redirect_query_params[:shop] ||= referer_sanitized_shop_name if referer_sanitized_shop_name.present? redirect_query_params[:host] ||= params[:host] if params[:host].present? diff --git a/lib/shopify_app/controller_concerns/sanitized_params.rb b/lib/shopify_app/controller_concerns/sanitized_params.rb index 6b01b8d18..2e5dc178d 100644 --- a/lib/shopify_app/controller_concerns/sanitized_params.rb +++ b/lib/shopify_app/controller_concerns/sanitized_params.rb @@ -21,6 +21,7 @@ def referer_sanitized_shop_name def sanitize_shop_param(params) return unless params[:shop].present? + ShopifyApp::Utils.sanitize_shop_domain(params[:shop]) end diff --git a/lib/shopify_app/managers/scripttags_manager.rb b/lib/shopify_app/managers/scripttags_manager.rb index 130548215..fd6240efe 100644 --- a/lib/shopify_app/managers/scripttags_manager.rb +++ b/lib/shopify_app/managers/scripttags_manager.rb @@ -7,7 +7,7 @@ def self.queue(shop_domain, shop_token, scripttags) shop_domain: shop_domain, shop_token: shop_token, # Procs cannot be serialized so we interpolate now, if necessary - scripttags: build_src(scripttags, shop_domain) + scripttags: build_src(scripttags, shop_domain), ) end diff --git a/lib/shopify_app/managers/webhooks_manager.rb b/lib/shopify_app/managers/webhooks_manager.rb index 5581e9a51..ebc90fea9 100644 --- a/lib/shopify_app/managers/webhooks_manager.rb +++ b/lib/shopify_app/managers/webhooks_manager.rb @@ -8,7 +8,7 @@ class << self def queue(shop_domain, shop_token) ShopifyApp::WebhooksManagerJob.perform_later( shop_domain: shop_domain, - shop_token: shop_token + shop_token: shop_token, ) end @@ -45,7 +45,7 @@ def add_registrations delivery_method: attributes[:delivery_method] || :http, path: webhook_path, handler: webhook_job_klass(webhook_path), - fields: attributes[:fields] + fields: attributes[:fields], ) end end diff --git a/lib/shopify_app/session/jwt.rb b/lib/shopify_app/session/jwt.rb index 91c096366..658aaf2d7 100644 --- a/lib/shopify_app/session/jwt.rb +++ b/lib/shopify_app/session/jwt.rb @@ -55,6 +55,7 @@ def validate_payload(payload) raise ::ShopifyApp::InvalidAudienceError, "'aud' claim does not match api_key" unless payload["aud"] == api_key raise ::ShopifyApp::InvalidDestinationError, "'dest' claim host not a valid shopify host" unless dest_host + raise ::ShopifyApp::MismatchedHostsError, "'dest' claim host does not match 'iss' claim host" unless dest_host == iss_host diff --git a/lib/shopify_app/session/shop_session_storage.rb b/lib/shopify_app/session/shop_session_storage.rb index f26de55dc..a1cc27ef7 100644 --- a/lib/shopify_app/session/shop_session_storage.rb +++ b/lib/shopify_app/session/shop_session_storage.rb @@ -34,7 +34,7 @@ def construct_session(shop) ShopifyAPI::Auth::Session.new( shop: shop.shopify_domain, - access_token: shop.shopify_token + access_token: shop.shopify_token, ) end end diff --git a/lib/shopify_app/session/shop_session_storage_with_scopes.rb b/lib/shopify_app/session/shop_session_storage_with_scopes.rb index b51295161..5312608e5 100644 --- a/lib/shopify_app/session/shop_session_storage_with_scopes.rb +++ b/lib/shopify_app/session/shop_session_storage_with_scopes.rb @@ -37,7 +37,7 @@ def construct_session(shop) ShopifyAPI::Auth::Session.new( shop: shop.shopify_domain, access_token: shop.shopify_token, - scope: shop.access_scopes + scope: shop.access_scopes, ) end end diff --git a/lib/shopify_app/session/user_session_storage.rb b/lib/shopify_app/session/user_session_storage.rb index 8c0094f16..78a77d1af 100644 --- a/lib/shopify_app/session/user_session_storage.rb +++ b/lib/shopify_app/session/user_session_storage.rb @@ -41,13 +41,13 @@ def construct_session(user) email_verified: false, account_owner: false, locale: "", - collaborator: false + collaborator: false, ) ShopifyAPI::Auth::Session.new( shop: user.shopify_domain, access_token: user.shopify_token, - associated_user: associated_user + associated_user: associated_user, ) end end diff --git a/lib/shopify_app/session/user_session_storage_with_scopes.rb b/lib/shopify_app/session/user_session_storage_with_scopes.rb index 1b69681ac..440226862 100644 --- a/lib/shopify_app/session/user_session_storage_with_scopes.rb +++ b/lib/shopify_app/session/user_session_storage_with_scopes.rb @@ -43,7 +43,7 @@ def construct_session(user) email_verified: false, account_owner: false, locale: "", - collaborator: false + collaborator: false, ) ShopifyAPI::Auth::Session.new( @@ -51,7 +51,7 @@ def construct_session(user) access_token: user.shopify_token, scope: user.access_scopes, associated_user_scope: user.access_scopes, - associated_user: associated_user + associated_user: associated_user, ) end end diff --git a/shopify_app.gemspec b/shopify_app.gemspec index 8bf43d0be..dc8f51f00 100644 --- a/shopify_app.gemspec +++ b/shopify_app.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency("jwt", ">= 2.2.3") s.add_runtime_dependency("rails", "> 5.2.1") s.add_runtime_dependency("redirect_safely", "~> 1.0") - s.add_runtime_dependency("shopify_api", "~> 12.0.0") + s.add_runtime_dependency("shopify_api", "~> 12.1") s.add_runtime_dependency("sprockets-rails", ">= 2.0.0") s.add_development_dependency("byebug") @@ -34,6 +34,5 @@ Gem::Specification.new do |s| s.add_development_dependency("webmock") s.files = %x(git ls-files).split("\n").reject { |f| f.match(%r{^(test|example)/}) } - s.test_files = %x(git ls-files -- {test}/*).split("\n") s.require_paths = ["lib"] end diff --git a/test/controllers/concerns/ensure_billing_test.rb b/test/controllers/concerns/ensure_billing_test.rb index 9b038a37d..07424feed 100644 --- a/test/controllers/concerns/ensure_billing_test.rb +++ b/test/controllers/concerns/ensure_billing_test.rb @@ -212,7 +212,7 @@ def stub_graphql_requests(*requests) stub_request(:post, "https://my-shop.myshopify.com/admin/api/#{@api_version}/graphql.json") .with( body: request[:request_body], - headers: { "X-Shopify-Access-Token": "access-token" } + headers: { "X-Shopify-Access-Token": "access-token" }, ) .to_return( status: 200, diff --git a/test/generators/install_generator_test.rb b/test/generators/install_generator_test.rb index 19dc79592..06ffa08d4 100644 --- a/test/generators/install_generator_test.rb +++ b/test/generators/install_generator_test.rb @@ -32,7 +32,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase api_key: ShopifyApp.configuration.api_key, api_secret_key: ShopifyApp.configuration.secret, api_version: ShopifyApp.configuration.api_version, - host_name: URI(ENV.fetch('HOST', '')).host || '', + host: ENV['HOST'], scope: ShopifyApp.configuration.scope, is_private: !ENV.fetch('SHOPIFY_APP_PRIVATE_SHOP', '').empty?, is_embedded: ShopifyApp.configuration.embedded_app, diff --git a/test/integration/webhooks_controller_test.rb b/test/integration/webhooks_controller_test.rb index bca0d4b9e..700aac283 100644 --- a/test/integration/webhooks_controller_test.rb +++ b/test/integration/webhooks_controller_test.rb @@ -46,7 +46,7 @@ def headers(name) hmac = OpenSSL::HMAC.digest( OpenSSL::Digest.new("sha256"), "API_SECRET_KEY", - "{}" + "{}", ) headers = { "x-shopify-topic" => name, diff --git a/test/routes/webhooks_routes_test.rb b/test/routes/webhooks_routes_test.rb index 4e498150c..0f053f6ab 100644 --- a/test/routes/webhooks_routes_test.rb +++ b/test/routes/webhooks_routes_test.rb @@ -10,7 +10,7 @@ class WebhooksRoutingTest < ActionController::TestCase test "webhooks routing" do assert_routing( { method: "post", path: "webhooks/test" }, - { controller: "shopify_app/webhooks", action: "receive", type: "test" } + { controller: "shopify_app/webhooks", action: "receive", type: "test" }, ) end end diff --git a/test/shopify_app/access_scopes/shop_strategy_test.rb b/test/shopify_app/access_scopes/shop_strategy_test.rb index cbd80deed..f5c777a55 100644 --- a/test/shopify_app/access_scopes/shop_strategy_test.rb +++ b/test/shopify_app/access_scopes/shop_strategy_test.rb @@ -37,7 +37,7 @@ def mock_shop_session(scopes) ShopifyAPI::Auth::Session.new( shop: shopify_domain, access_token: "access_token", - scope: scopes + scope: scopes, ) end end diff --git a/test/shopify_app/access_scopes/user_strategy_test.rb b/test/shopify_app/access_scopes/user_strategy_test.rb index da78c374d..771ce9764 100644 --- a/test/shopify_app/access_scopes/user_strategy_test.rb +++ b/test/shopify_app/access_scopes/user_strategy_test.rb @@ -65,7 +65,7 @@ def mock_user_session(scopes) ShopifyAPI::Auth::Session.new( shop: shopify_domain, access_token: "access_token", - scope: scopes + scope: scopes, ) end end diff --git a/test/shopify_app/controller_concerns/login_protection_test.rb b/test/shopify_app/controller_concerns/login_protection_test.rb index e3c5fd1a0..186b94faa 100644 --- a/test/shopify_app/controller_concerns/login_protection_test.rb +++ b/test/shopify_app/controller_concerns/login_protection_test.rb @@ -89,7 +89,7 @@ class LoginProtectionControllerTest < ActionController::TestCase .with( auth_header: "Bearer token", cookies: { ShopifyAPI::Auth::Oauth::SessionCookie::SESSION_COOKIE_NAME => nil }, - is_online: true + is_online: true, ) .returns(nil) @@ -107,7 +107,7 @@ class LoginProtectionControllerTest < ActionController::TestCase .with( auth_header: "Bearer token", cookies: { ShopifyAPI::Auth::Oauth::SessionCookie::SESSION_COOKIE_NAME => nil }, - is_online: false + is_online: false, ) .returns(nil) @@ -124,7 +124,7 @@ class LoginProtectionControllerTest < ActionController::TestCase .with( auth_header: "Bearer #{token}", cookies: { ShopifyAPI::Auth::Oauth::SessionCookie::SESSION_COOKIE_NAME => nil }, - is_online: false + is_online: false, ) .returns(@session) @@ -142,7 +142,7 @@ class LoginProtectionControllerTest < ActionController::TestCase .with( auth_header: "Bearer #{token}", cookies: { ShopifyAPI::Auth::Oauth::SessionCookie::SESSION_COOKIE_NAME => nil }, - is_online: false + is_online: false, ) .returns(@session) @@ -191,7 +191,7 @@ class LoginProtectionControllerTest < ActionController::TestCase cookies.encrypted[ShopifyAPI::Auth::Oauth::SessionCookie::SESSION_COOKIE_NAME] = "old-cookie" ShopifyAPI::Utils::SessionUtils.expects(:load_current_session).returns( - ShopifyAPI::Auth::Session.new(shop: "some-shop") + ShopifyAPI::Auth::Session.new(shop: "some-shop"), ).once get :second_login @@ -205,7 +205,7 @@ class LoginProtectionControllerTest < ActionController::TestCase cookies.encrypted[ShopifyAPI::Auth::Oauth::SessionCookie::SESSION_COOKIE_NAME] = "old-cookie" ShopifyAPI::Utils::SessionUtils.expects(:load_current_session).returns( - ShopifyAPI::Auth::Session.new(shop: "some-shop") + ShopifyAPI::Auth::Session.new(shop: "some-shop"), ).once get :second_login, params: { shop: "other-shop" } @@ -229,10 +229,10 @@ class LoginProtectionControllerTest < ActionController::TestCase .with( auth_header: "Bearer token", cookies: { ShopifyAPI::Auth::Oauth::SessionCookie::SESSION_COOKIE_NAME => "cookie" }, - is_online: true + is_online: true, ) .returns( - ShopifyAPI::Auth::Session.new(shop: @shop, scope: ["scope1"]) + ShopifyAPI::Auth::Session.new(shop: @shop, scope: ["scope1"]), ) with_application_test_routes do @@ -256,10 +256,10 @@ class LoginProtectionControllerTest < ActionController::TestCase .with( auth_header: "Bearer token", cookies: { ShopifyAPI::Auth::Oauth::SessionCookie::SESSION_COOKIE_NAME => "cookie" }, - is_online: true + is_online: true, ) .returns( - ShopifyAPI::Auth::Session.new(shop: "some-shop", scope: ["scope1", "scope2"]) + ShopifyAPI::Auth::Session.new(shop: "some-shop", scope: ["scope1", "scope2"]), ) with_application_test_routes do @@ -274,7 +274,7 @@ class LoginProtectionControllerTest < ActionController::TestCase cookies.encrypted[ShopifyAPI::Auth::Oauth::SessionCookie::SESSION_COOKIE_NAME] = "old-cookie" ShopifyAPI::Utils::SessionUtils.expects(:load_current_session).returns( - ShopifyAPI::Auth::Session.new(shop: "some-shop") + ShopifyAPI::Auth::Session.new(shop: "some-shop"), ).once get :second_login, params: { shop: { id: 123, disabled: true } } diff --git a/test/shopify_app/session/session_repository_test.rb b/test/shopify_app/session/session_repository_test.rb index 832c65ac9..cb4b1cee6 100644 --- a/test/shopify_app/session/session_repository_test.rb +++ b/test/shopify_app/session/session_repository_test.rb @@ -171,7 +171,7 @@ def mock_shopify_session ShopifyAPI::Auth::Session.new( shop: mock_shopify_domain, access_token: "abracadabra", - scope: "read_products" + scope: "read_products", ) end @@ -184,7 +184,7 @@ def mock_associated_user email_verified: true, account_owner: false, locale: "en", - collaborator: true + collaborator: true, ) end end diff --git a/test/shopify_app/session/shop_session_storage_test.rb b/test/shopify_app/session/shop_session_storage_test.rb index 6b71ef77a..cecad0696 100644 --- a/test/shopify_app/session/shop_session_storage_test.rb +++ b/test/shopify_app/session/shop_session_storage_test.rb @@ -14,7 +14,7 @@ class ShopSessionStorageTest < ActiveSupport::TestCase test ".retrieve can retrieve shop session records by ID" do ShopMockSessionStore.stubs(:find_by).returns(MockShopInstance.new( shopify_domain: TEST_SHOPIFY_DOMAIN, - shopify_token: TEST_SHOPIFY_TOKEN + shopify_token: TEST_SHOPIFY_TOKEN, )) session = ShopMockSessionStore.retrieve(1) diff --git a/test/shopify_app/session/shop_session_storage_with_scopes_test.rb b/test/shopify_app/session/shop_session_storage_with_scopes_test.rb index 4d9c87d25..87f1e08a2 100644 --- a/test/shopify_app/session/shop_session_storage_with_scopes_test.rb +++ b/test/shopify_app/session/shop_session_storage_with_scopes_test.rb @@ -16,7 +16,7 @@ class ShopSessionStorageWithScopesTest < ActiveSupport::TestCase ShopMockSessionStoreWithScopes.stubs(:find_by).returns(MockShopInstance.new( shopify_domain: TEST_SHOPIFY_DOMAIN, shopify_token: TEST_SHOPIFY_TOKEN, - scopes: TEST_MERCHANT_SCOPES + scopes: TEST_MERCHANT_SCOPES, )) session = ShopMockSessionStoreWithScopes.retrieve(1) @@ -29,14 +29,14 @@ class ShopSessionStorageWithScopesTest < ActiveSupport::TestCase instance = MockShopInstance.new( shopify_domain: TEST_SHOPIFY_DOMAIN, shopify_token: TEST_SHOPIFY_TOKEN, - scopes: TEST_MERCHANT_SCOPES + scopes: TEST_MERCHANT_SCOPES, ) ShopMockSessionStoreWithScopes.stubs(:find_by).with(shopify_domain: TEST_SHOPIFY_DOMAIN).returns(instance) expected_session = ShopifyAPI::Auth::Session.new( shop: instance.shopify_domain, access_token: instance.shopify_token, - scope: instance.access_scopes + scope: instance.access_scopes, ) shopify_domain = TEST_SHOPIFY_DOMAIN @@ -80,7 +80,7 @@ class ShopSessionStorageWithScopesTest < ActiveSupport::TestCase test ".retrieve throws NotImplementedError when access_scopes getter is not implemented" do mock_shop = MockShopInstance.new( shopify_domain: TEST_SHOPIFY_DOMAIN, - shopify_token: TEST_SHOPIFY_TOKEN + shopify_token: TEST_SHOPIFY_TOKEN, ) mock_shop.stubs(:access_scopes).raises(NotImplementedError) ShopMockSessionStoreWithScopes.stubs(:find_by).returns(mock_shop) diff --git a/test/shopify_app/session/user_session_storage_test.rb b/test/shopify_app/session/user_session_storage_test.rb index a2b4f736d..7f399f361 100644 --- a/test/shopify_app/session/user_session_storage_test.rb +++ b/test/shopify_app/session/user_session_storage_test.rb @@ -17,7 +17,7 @@ class UserSessionStorageTest < ActiveSupport::TestCase UserMockSessionStore.stubs(:find_by).returns(MockUserInstance.new( shopify_user_id: TEST_SHOPIFY_USER_ID, shopify_domain: TEST_SHOPIFY_DOMAIN, - shopify_token: TEST_SHOPIFY_USER_TOKEN + shopify_token: TEST_SHOPIFY_USER_TOKEN, )) session = UserMockSessionStore.retrieve(shopify_user_id: TEST_SHOPIFY_USER_ID) @@ -55,9 +55,9 @@ class UserSessionStorageTest < ActiveSupport::TestCase saved_id = UserMockSessionStore.store( mock_session( shop: mock_user_instance.shopify_domain, - scope: TEST_MERCHANT_SCOPES + scope: TEST_MERCHANT_SCOPES, ), - mock_associated_user + mock_associated_user, ) assert_equal "a-new-user_token!", mock_user_instance.shopify_token @@ -89,7 +89,7 @@ def mock_associated_user email_verified: true, account_owner: false, locale: "en", - collaborator: true + collaborator: true, ) end end diff --git a/test/shopify_app/session/user_session_storage_with_scopes_test.rb b/test/shopify_app/session/user_session_storage_with_scopes_test.rb index b401e2c8b..1bb47188b 100644 --- a/test/shopify_app/session/user_session_storage_with_scopes_test.rb +++ b/test/shopify_app/session/user_session_storage_with_scopes_test.rb @@ -18,7 +18,7 @@ class UserSessionStorageWithScopesTest < ActiveSupport::TestCase shopify_user_id: TEST_SHOPIFY_USER_ID, shopify_domain: TEST_SHOPIFY_DOMAIN, shopify_token: TEST_SHOPIFY_USER_TOKEN, - scopes: TEST_MERCHANT_SCOPES + scopes: TEST_MERCHANT_SCOPES, )) session = UserMockSessionStoreWithScopes.retrieve(shopify_user_id: TEST_SHOPIFY_USER_ID) @@ -34,14 +34,14 @@ class UserSessionStorageWithScopesTest < ActiveSupport::TestCase shopify_domain: TEST_SHOPIFY_DOMAIN, shopify_token: TEST_SHOPIFY_USER_TOKEN, api_version: ShopifyApp.configuration.api_version, - scopes: TEST_MERCHANT_SCOPES + scopes: TEST_MERCHANT_SCOPES, ) UserMockSessionStoreWithScopes.stubs(:find_by).with(shopify_user_id: TEST_SHOPIFY_USER_ID).returns(instance) expected_session = ShopifyAPI::Auth::Session.new( shop: instance.shopify_domain, access_token: instance.shopify_token, - scope: TEST_MERCHANT_SCOPES + scope: TEST_MERCHANT_SCOPES, ) user_id = TEST_SHOPIFY_USER_ID @@ -60,9 +60,9 @@ class UserSessionStorageWithScopesTest < ActiveSupport::TestCase saved_id = UserMockSessionStoreWithScopes.store( mock_session( shop: mock_user_instance.shopify_domain, - scope: TEST_MERCHANT_SCOPES + scope: TEST_MERCHANT_SCOPES, ), - mock_associated_user + mock_associated_user, ) assert_equal "a-new-user_token!", mock_user_instance.shopify_token @@ -87,7 +87,7 @@ class UserSessionStorageWithScopesTest < ActiveSupport::TestCase mock_user = MockUserInstance.new( shopify_user_id: TEST_SHOPIFY_USER_ID, shopify_domain: TEST_SHOPIFY_DOMAIN, - shopify_token: TEST_SHOPIFY_USER_TOKEN + shopify_token: TEST_SHOPIFY_USER_TOKEN, ) mock_user.stubs(:access_scopes).raises(NotImplementedError) UserMockSessionStoreWithScopes.stubs(:find_by).returns(mock_user) @@ -108,7 +108,7 @@ def mock_associated_user email_verified: true, account_owner: false, locale: "en", - collaborator: true + collaborator: true, ) end end diff --git a/test/utils/rails_generator_runtime.rb b/test/utils/rails_generator_runtime.rb index 3de12e525..31c519d91 100644 --- a/test/utils/rails_generator_runtime.rb +++ b/test/utils/rails_generator_runtime.rb @@ -20,7 +20,7 @@ def run_generator(generator_class, additional_args = []) suppress_output do generator_class.start( additional_args + ["--skip-bundle", "--skip-bootsnap"], - { destination_root: destination } + { destination_root: destination }, ) end end @@ -87,7 +87,7 @@ def with_session(test_class, is_embedded: false, is_private: false, &block) is_private: is_private, is_embedded: is_embedded, session_storage: TestHelpers::FakeSessionStorage.new, - user_agent_prefix: nil + user_agent_prefix: nil, ) ShopifyAPI::Context.activate_session(ShopifyAPI::Auth::Session.new(shop: "my-shop"))