Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1273 from Shopify/stub_partners_when_bypassing
Browse files Browse the repository at this point in the history
Stub partners call when bypass flag is set
  • Loading branch information
DuncanUszkay1 authored Jun 10, 2021
2 parents af3e125 + 053493c commit d3060df
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/project_types/script/tasks/ensure_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def call(ctx)
private

def ask_org
return stubbed_org if partner_proxy_bypass

if ShopifyCli::Shopifolk.check && wants_to_run_against_shopify_org?
ShopifyCli::Shopifolk.act_as_shopify_organization
end
Expand All @@ -47,6 +49,23 @@ def ask_org
end
end

def stubbed_org
{
"apps" => [
{
"appType" => "custom",
"apiKey" => "stubbed-api-key",
"apiSecretKeys" => [{ "secret" => "stubbed-api-secret" }],
"title" => "Fake App (Not connected to Partners)",
},
],
}
end

def partner_proxy_bypass
!ENV["BYPASS_PARTNERS_PROXY"].nil?
end

def ask_app(apps)
unless ShopifyCli::Shopifolk.acting_as_shopify_organization?
apps = apps.select { |app| app["appType"] == "custom" }
Expand Down
13 changes: 13 additions & 0 deletions test/project_types/script/tasks/ensure_env_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ def self.it_prompts_user_and_update_env
end
end

describe("when the partners bypass flag is set") do
before do
Script::Tasks::EnsureEnv.any_instance.stubs(:partner_proxy_bypass).returns(true)
end

it("should not call partners to query for apps") do
ShopifyCli::PartnersAPI.expects(:query).never
Script::Layers::Infrastructure::ScriptService.any_instance.expects(:get_app_scripts).returns([])

subject
end
end

describe("when asking app connection") do
describe("when number of apps == 0") do
let(:apps) { [] }
Expand Down

0 comments on commit d3060df

Please sign in to comment.