Skip to content

Commit

Permalink
Rename new_embedded_auth_strategy configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
zzooeeyy committed Apr 30, 2024
1 parent caf2dad commit b2ff7ad
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ authenticated API access.
ShopifyApp.configure do |config|
#.....
config.embedded_app = true
config.unstable_new_embedded_auth_strategy = true
config.new_embedded_auth_strategy = true

# If your app is configured to use online sessions, you can enable session expiry date check so a new access token
# is fetched automatically when the session expires.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ShopifyApp.configure do |config|
config.scope = "<%= @scope %>" # Consult this page for more scope options:
# https://help.shopify.com/en/api/getting-started/authentication/oauth/scopes
config.embedded_app = <%= embedded_app? %>
config.unstable_new_embedded_auth_strategy = <%= embedded_app? %>
config.new_embedded_auth_strategy = <%= embedded_app? %>

config.after_authenticate_job = false
config.api_version = "<%= @api_version %>"
Expand Down
4 changes: 2 additions & 2 deletions lib/shopify_app/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Configuration
attr_accessor :billing

# Enables new authorization flow using token exchange
attr_accessor :unstable_new_embedded_auth_strategy
attr_accessor :new_embedded_auth_strategy

def initialize
@root_url = "/"
Expand Down Expand Up @@ -129,7 +129,7 @@ def user_access_scopes
end

def use_new_embedded_auth_strategy?
unstable_new_embedded_auth_strategy && embedded_app?
new_embedded_auth_strategy && embedded_app?
end

def online_token_configured?
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/sessions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SessionsControllerTest < ActionController::TestCase
ShopifyApp.configuration.api_version = ShopifyAPI::LATEST_SUPPORTED_ADMIN_VERSION
ShopifyApp::SessionRepository.shop_storage = ShopifyApp::InMemoryShopSessionStore
ShopifyApp::SessionRepository.user_storage = nil
ShopifyApp.configuration.unstable_new_embedded_auth_strategy = false
ShopifyApp.configuration.new_embedded_auth_strategy = false
ShopifyApp.configuration.api_key = APP_API_KEY
ShopifyAppConfigurer.setup_context # need to reset context after config changes

Expand Down Expand Up @@ -394,7 +394,7 @@ class SessionsControllerTest < ActionController::TestCase
"https://admin.shopify.com/store/my-shop",
].each do |good_url|
test "#create redirects to Shopify managed install path instead if use_new_embedded_auth_strategy is enabled - #{good_url}" do
ShopifyApp.configuration.unstable_new_embedded_auth_strategy = true
ShopifyApp.configuration.new_embedded_auth_strategy = true

post :create, params: { shop: good_url }

Expand Down
2 changes: 1 addition & 1 deletion test/dummy/config/initializers/shopify_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.call
config.after_authenticate_job = false
config.reauth_on_access_scope_changes = true
config.root_url = "/"
config.unstable_new_embedded_auth_strategy = false
config.new_embedded_auth_strategy = false
config.check_session_expiry_date = false
config.custom_post_authenticate_tasks = nil
end
Expand Down
8 changes: 4 additions & 4 deletions test/generators/install_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase
assert_match "config.secret = ENV.fetch('SHOPIFY_API_SECRET', '')", shopify_app
assert_match 'config.scope = "read_products"', shopify_app
assert_match "config.embedded_app = true", shopify_app
assert_match "config.unstable_new_embedded_auth_strategy = true", shopify_app
assert_match "config.new_embedded_auth_strategy = true", shopify_app
assert_match "config.api_version = \"#{ShopifyAPI::LATEST_SUPPORTED_ADMIN_VERSION}\"", shopify_app
assert_match "config.after_authenticate_job = false", shopify_app

Expand Down Expand Up @@ -66,7 +66,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase
assert_match "config.secret = ENV.fetch('SHOPIFY_API_SECRET', '')", shopify_app
assert_match 'config.scope = "read_orders write_products"', shopify_app
assert_match "config.embedded_app = true", shopify_app
assert_match "config.unstable_new_embedded_auth_strategy = true", shopify_app
assert_match "config.new_embedded_auth_strategy = true", shopify_app
assert_match 'config.api_version = "unstable"', shopify_app
assert_match "config.shop_session_repository = 'Shop'", shopify_app
end
Expand All @@ -80,7 +80,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase
assert_match "config.secret = ENV.fetch('SHOPIFY_API_SECRET', '')", shopify_app
assert_match 'config.scope = "read_orders write_products"', shopify_app
assert_match "config.embedded_app = true", shopify_app
assert_match "config.unstable_new_embedded_auth_strategy = true", shopify_app
assert_match "config.new_embedded_auth_strategy = true", shopify_app
assert_match "config.shop_session_repository = 'Shop'", shopify_app
end
end
Expand All @@ -89,7 +89,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase
run_generator ["--embedded", "false"]
assert_file "config/initializers/shopify_app.rb" do |shopify_app|
assert_match "config.embedded_app = false", shopify_app
assert_match "config.unstable_new_embedded_auth_strategy = false", shopify_app
assert_match "config.new_embedded_auth_strategy = false", shopify_app
end
end

Expand Down
12 changes: 6 additions & 6 deletions test/shopify_app/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,27 +241,27 @@ class ConfigurationTest < ActiveSupport::TestCase
assert_equal "Invalid user access scopes strategy - expected a string", error.message
end

test "#use_new_embedded_auth_strategy? is true when unstable_new_embedded_auth_strategy is on for embedded apps" do
test "#use_new_embedded_auth_strategy? is true when new_embedded_auth_strategy is on for embedded apps" do
ShopifyApp.configure do |config|
config.embedded_app = true
config.unstable_new_embedded_auth_strategy = true
config.new_embedded_auth_strategy = true
end

assert ShopifyApp.configuration.use_new_embedded_auth_strategy?
end

test "#use_new_embedded_auth_strategy? is false for non-embedded apps even if unstable_new_embedded_auth_strategy is configured" do
test "#use_new_embedded_auth_strategy? is false for non-embedded apps even if new_embedded_auth_strategy is configured" do
ShopifyApp.configure do |config|
config.embedded_app = false
config.unstable_new_embedded_auth_strategy = true
config.new_embedded_auth_strategy = true
end

refute ShopifyApp.configuration.use_new_embedded_auth_strategy?
end

test "#use_new_embedded_auth_strategy? is false when unstable_new_embedded_auth_strategy is off" do
test "#use_new_embedded_auth_strategy? is false when new_embedded_auth_strategy is off" do
ShopifyApp.configure do |config|
config.unstable_new_embedded_auth_strategy = false
config.new_embedded_auth_strategy = false
end

refute ShopifyApp.configuration.use_new_embedded_auth_strategy?
Expand Down

0 comments on commit b2ff7ad

Please sign in to comment.