Skip to content

Commit

Permalink
Implement fetching consumer_secret from Salesforce connection (apache…
Browse files Browse the repository at this point in the history
…#45954)

This PR introduces a new feature that allows users to retrieve the consumer_secret directly from the Connections service.

---------

Co-authored-by: k0d04mr <[email protected]>
  • Loading branch information
2 people authored and got686-yandex committed Jan 30, 2025
1 parent 7711a83 commit 375322d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ Consumer Key (optional)

Use for OAuth 2.0 JWT authentication.

Consumer Secret (optional)
the consumer secret generated for the user.

Use for OAuth 2.0 JWT authentication.

Private Key (optional)
The private key to use for signing the JWT. Provide this or a Private Key File Path (both are not necessary).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def get_connection_form_widgets(cls) -> dict[str, Any]:
"security_token": PasswordField(lazy_gettext("Security Token"), widget=BS3PasswordFieldWidget()),
"domain": StringField(lazy_gettext("Domain"), widget=BS3TextFieldWidget()),
"consumer_key": StringField(lazy_gettext("Consumer Key"), widget=BS3TextFieldWidget()),
"consumer_secret": PasswordField(
lazy_gettext("Consumer Secret"), widget=BS3PasswordFieldWidget()
),
"private_key_file_path": PasswordField(
lazy_gettext("Private Key File Path"), widget=BS3PasswordFieldWidget()
),
Expand Down Expand Up @@ -151,6 +154,7 @@ def conn(self) -> api.Salesforce:
session=self.session,
client_id=self._get_field(extras, "client_id") or None,
consumer_key=self._get_field(extras, "consumer_key") or None,
consumer_secret=self._get_field(extras, "consumer_secret") or None,
privatekey_file=self._get_field(extras, "private_key_file_path") or None,
privatekey=self._get_field(extras, "private_key") or None,
)
Expand Down
9 changes: 9 additions & 0 deletions providers/tests/salesforce/hooks/test_salesforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def test_get_conn_password_auth(self, mock_salesforce):
session=None,
client_id=extras["client_id"],
consumer_key=None,
consumer_secret=None,
privatekey_file=None,
privatekey=None,
)
Expand Down Expand Up @@ -146,6 +147,7 @@ def test_get_conn_direct_session_access(self, mock_salesforce):
session=self.salesforce_hook.session,
client_id=extras["client_id"],
consumer_key=None,
consumer_secret=None,
privatekey_file=None,
privatekey=None,
)
Expand All @@ -169,6 +171,7 @@ def test_get_conn_jwt_auth(self, mock_salesforce):
{
"client_id": "my_client3",
"consumer_key": "consumer_key",
"consumer_secret": "consumer_secret",
"domain": "login",
"private_key": "private_key",
"version": "34.0"
Expand All @@ -195,6 +198,7 @@ def test_get_conn_jwt_auth(self, mock_salesforce):
session=None,
client_id=extras["client_id"],
consumer_key=extras["consumer_key"],
consumer_secret=extras["consumer_secret"],
privatekey_file=None,
privatekey=extras["private_key"],
)
Expand Down Expand Up @@ -240,6 +244,7 @@ def test_get_conn_ip_filtering_auth(self, mock_salesforce):
session=None,
client_id=None,
consumer_key=None,
consumer_secret=None,
privatekey_file=None,
privatekey=None,
)
Expand All @@ -261,6 +266,7 @@ def test_get_conn_default_to_none(self, mock_salesforce):
{
"client_id": "",
"consumer_key": "",
"consumer_secret": "",
"domain": "",
"instance": "",
"instance_url": "",
Expand Down Expand Up @@ -291,6 +297,7 @@ def test_get_conn_default_to_none(self, mock_salesforce):
session=None,
client_id=None,
consumer_key=None,
consumer_secret=None,
privatekey_file=None,
privatekey=None,
)
Expand Down Expand Up @@ -480,6 +487,7 @@ def test_backcompat_prefix_works(self, mock_client, uri):
mock_client.assert_called_with(
client_id=None,
consumer_key=None,
consumer_secret=None,
domain="domain",
instance=None,
instance_url=None,
Expand Down Expand Up @@ -509,6 +517,7 @@ def test_backcompat_prefix_both_prefers_short(self, mock_client):
mock_client.assert_called_with(
client_id=None,
consumer_key=None,
consumer_secret=None,
domain=None,
instance=None,
instance_url=None,
Expand Down

0 comments on commit 375322d

Please sign in to comment.