From dd2d1b3a187767814a4cdf336e7890d5f67c8d03 Mon Sep 17 00:00:00 2001 From: lakshmi2506 Date: Tue, 26 Mar 2024 16:26:29 +0530 Subject: [PATCH] Test case modified --- cumulusci/oauth/salesforce.py | 12 ++++++++++-- cumulusci/oauth/tests/test_salesforce.py | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cumulusci/oauth/salesforce.py b/cumulusci/oauth/salesforce.py index 33fa484385..48b2e3e0e2 100644 --- a/cumulusci/oauth/salesforce.py +++ b/cumulusci/oauth/salesforce.py @@ -22,9 +22,17 @@ def update_login_urls(): + """ + Updating to setup the environment variables dynamically + """ global PROD_LOGIN_URL, SANDBOX_LOGIN_URL - PROD_LOGIN_URL = os.environ.get("SF_PROD_LOGIN_URL") or "https://login.salesforce.com" - SANDBOX_LOGIN_URL = os.environ.get("SF_SANDBOX_LOGIN_URL") or "https://test.salesforce.com" + PROD_LOGIN_URL = ( + os.environ.get("SF_PROD_LOGIN_URL") or "https://login.salesforce.com" + ) + SANDBOX_LOGIN_URL = ( + os.environ.get("SF_SANDBOX_LOGIN_URL") or "https://test.salesforce.com" + ) + def jwt_session( client_id, private_key, username, url=None, auth_url=None, is_sandbox=False diff --git a/cumulusci/oauth/tests/test_salesforce.py b/cumulusci/oauth/tests/test_salesforce.py index 6ef9c11e84..091227900f 100644 --- a/cumulusci/oauth/tests/test_salesforce.py +++ b/cumulusci/oauth/tests/test_salesforce.py @@ -1,3 +1,4 @@ +import os from unittest import mock import pytest @@ -28,10 +29,12 @@ def test_jwt_session(encode): @mock.patch("cumulusci.oauth.salesforce.jwt.encode") def test_jwt_session__enhanced_domains_enabled(encode): # raise an assertion error if the registered url was not accessed + os.environ["SF_PROD_LOGIN_URL"] = "https://login.test1.salesforce.com" + os.environ["SF_SANDBOX_LOGIN_URL"] = "https://test.test1.salesforce.com" with responses.RequestsMock(assert_all_requests_are_fired=True) as rsps: rsps.add( responses.POST, - "https://test.salesforce.com/services/oauth2/token", + "https://test.test1.salesforce.com/services/oauth2/token", body='{"message":"well done mate!"}', status=200, )