Skip to content

Commit

Permalink
Add new configuration flag for token exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
zzooeeyy committed Jan 15, 2024
1 parent 9e8f95b commit 20e3f75
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_token_exchange

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_token_exchange?
wip_token_exchange && 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_token_exchange? is true when wip_token_exchange is on for embedded apps" do
ShopifyApp.configure do |config|
config.embedded_app = true
config.wip_token_exchange = true
end

assert ShopifyApp.configuration.use_token_exchange?
end

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

refute ShopifyApp.configuration.use_token_exchange?
end

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

refute ShopifyApp.configuration.use_token_exchange?
end
end

0 comments on commit 20e3f75

Please sign in to comment.