Skip to content

Commit

Permalink
Merge pull request #1778 from Shopify/add-token-exchange-config
Browse files Browse the repository at this point in the history
Add new configuration flag for token exchange
  • Loading branch information
zzooeeyy authored Jan 18, 2024
2 parents fea9240 + 1bd9bb0 commit 80db41e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/shopify_app/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class Configuration
# takes a ShopifyApp::BillingConfiguration object
attr_accessor :billing

# Work in Progress: enables token exchange authentication flow
attr_accessor :wip_new_embedded_auth_strategy

def initialize
@root_url = "/"
@myshopify_domain = "myshopify.com"
Expand Down Expand Up @@ -118,6 +121,10 @@ def shop_access_scopes
def user_access_scopes
@user_access_scopes || scope
end

def use_new_embedded_auth_strategy?
wip_new_embedded_auth_strategy && embedded_app?
end
end

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

test "#use_new_embedded_auth_strategy? is true when wip_new_embedded_auth_strategy is on for embedded apps" do
ShopifyApp.configure do |config|
config.embedded_app = true
config.wip_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 wip_new_embedded_auth_strategy is configured" do
ShopifyApp.configure do |config|
config.embedded_app = false
config.wip_new_embedded_auth_strategy = true
end

refute ShopifyApp.configuration.use_new_embedded_auth_strategy?
end

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

refute ShopifyApp.configuration.use_new_embedded_auth_strategy?
end
end

0 comments on commit 80db41e

Please sign in to comment.