def get_refreshed_org_config(self): org_config = OrgConfig(self.config, "dev") info = jwt_session( settings.SF_CLIENT_ID, settings.SF_CLIENT_KEY, org_config.username, org_config.instance_url, ) org_config.config.update(info) org_config._load_userinfo() org_config._load_orginfo() return org_config
def test_refresh_oauth_token(self, SalesforceOAuth2): config = OrgConfig({"refresh_token": mock.sentinel.refresh_token}, "test") config._load_userinfo = mock.Mock() keychain = mock.Mock() SalesforceOAuth2.return_value = oauth = mock.Mock() oauth.refresh_token.return_value = resp = mock.Mock() resp.json.return_value = {} config.refresh_oauth_token(keychain) oauth.refresh_token.assert_called_once_with(mock.sentinel.refresh_token)
def test_refresh_oauth_token(self, SalesforceOAuth2): config = OrgConfig({"refresh_token": mock.sentinel.refresh_token}, "test") config._load_userinfo = mock.Mock() config._load_orginfo = mock.Mock() keychain = mock.Mock() SalesforceOAuth2.return_value = oauth = mock.Mock() oauth.refresh_token.return_value = resp = mock.Mock(status_code=200) resp.json.return_value = {} config.refresh_oauth_token(keychain) oauth.refresh_token.assert_called_once_with(mock.sentinel.refresh_token)
def test_refresh_oauth_token_jwt_sandbox(self): responses.add( "POST", "https://cs00.salesforce.com/services/oauth2/token", json={ "access_token": "TOKEN", "instance_url": "https://cs00.salesforce.com", }, ) with mock.patch.dict( os.environ, {"SFDX_CLIENT_ID": "some client id", "SFDX_HUB_KEY": "some private key"}, ): config = OrgConfig({"instance_url": "https://cs00.salesforce.com"}, "test") config._load_userinfo = mock.Mock() config._load_orginfo = mock.Mock() config.refresh_oauth_token(None) assert config.access_token == "TOKEN"