We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm using shopify_app v22.2.1 with enabled token exchange.
I was trying to write a test for an app that upgraded to token exchange. But old way to stub session no longer works: https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/testing.md
require "test_helper" require 'shopify_app/test_helpers/shopify_session_helper' class HomeControllerTest < ActionDispatch::IntegrationTest include ShopifyApp::TestHelpers::ShopifySessionHelper def setup @shop = shops(:regular) setup_shopify_session(session_id: "1", shop_domain: @shop.shopify_domain) end test "renders home page" do get home_path assert_response :success end end
setup_shopify_session should stub the session and skip ID token check.
setup_shopify_session
I'm getting error ShopifyAPI::Errors::MissingJwtTokenError:
ShopifyAPI::Errors::MissingJwtTokenError
# Running: E Error: HomeControllerTest#test_renders_home_page: ShopifyAPI::Errors::MissingJwtTokenError: Missing Shopify ID Token test/controllers/home_controller_test.rb:14:in `block in <class:HomeControllerTest>' bin/rails test test/controllers/home_controller_test.rb:13 Finished in 0.104336s, 9.5844 runs/s, 0.0000 assertions/s. 1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
The text was updated successfully, but these errors were encountered:
@zzooeeyy it seems like test helpers and testing documentation require an update
Sorry, something went wrong.
Good call out! I'll add that to our backlog
I was able to fix it with a simple patch to helper:
def setup_shopify_session(session_id:, shop_domain:) ShopifyAPI::Auth::Session.new(id: session_id, shop: shop_domain).tap do |session| ShopifyApp::SessionRepository.stubs(:load_session).returns(session) ShopifyAPI::Utils::SessionUtils.stubs(:current_session_id).returns(session.id) + ShopifyAPI::Utils::SessionUtils.stubs(:session_id_from_shopify_id_token).returns(session.id) ShopifyAPI::Context.activate_session(session) end end
No branches or pull requests
Issue summary
I'm using shopify_app v22.2.1 with enabled token exchange.
I was trying to write a test for an app that upgraded to token exchange. But old way to stub session no longer works:
https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/testing.md
Expected behavior
setup_shopify_session
should stub the session and skip ID token check.Actual behavior
I'm getting error
ShopifyAPI::Errors::MissingJwtTokenError
:Steps to reproduce the problem
setup_shopify_session
helperThe text was updated successfully, but these errors were encountered: