Skip to content

Commit ef978ae

Browse files
authored
Additional ACL Tests + Slackbot fix (#4430)
* try turning drive perm sync on * try passing in env var * add some logs * Update pr-integration-tests.yml * revert "Update pr-integration-tests.yml" This reverts commit 76a44ad. * Revert "add some logs" This reverts commit ab9e6bc. * Revert "try passing in env var" This reverts commit 9c0b616. * Revert "try turning drive perm sync on" This reverts commit 2d35f61. * try slack connector * k * update * remove logs * remove more logs * nit * k * k * address nits * run test with additional logs * Revert "run test with additional logs" This reverts commit 1397a2c. * Revert "address nits" This reverts commit d5e24b0.
1 parent 15ab058 commit ef978ae

File tree

7 files changed

+17
-9
lines changed

7 files changed

+17
-9
lines changed

backend/ee/onyx/external_permissions/slack/doc_sync.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
from ee.onyx.external_permissions.slack.utils import fetch_user_id_to_email_map
66
from onyx.access.models import DocExternalAccess
77
from onyx.access.models import ExternalAccess
8+
from onyx.connectors.credentials_provider import OnyxDBCredentialsProvider
89
from onyx.connectors.slack.connector import get_channels
910
from onyx.connectors.slack.connector import make_paginated_slack_api_call_w_retries
1011
from onyx.connectors.slack.connector import SlackConnector
1112
from onyx.db.models import ConnectorCredentialPair
1213
from onyx.indexing.indexing_heartbeat import IndexingHeartbeatInterface
1314
from onyx.utils.logger import setup_logger
15+
from shared_configs.contextvars import get_current_tenant_id
1416

1517

1618
logger = setup_logger()
@@ -101,7 +103,12 @@ def _get_slack_document_access(
101103
callback: IndexingHeartbeatInterface | None,
102104
) -> Generator[DocExternalAccess, None, None]:
103105
slack_connector = SlackConnector(**cc_pair.connector.connector_specific_config)
104-
slack_connector.load_credentials(cc_pair.credential.credential_json)
106+
107+
# Use credentials provider instead of directly loading credentials
108+
provider = OnyxDBCredentialsProvider(
109+
get_current_tenant_id(), "slack", cc_pair.credential.id
110+
)
111+
slack_connector.set_credentials_provider(provider)
105112

106113
slim_doc_generator = slack_connector.retrieve_all_slim_documents(callback=callback)
107114

backend/ee/onyx/external_permissions/slack/group_sync.py

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def _get_slack_group_members_email(
5151

5252

5353
def slack_group_sync(
54+
tenant_id: str,
5455
cc_pair: ConnectorCredentialPair,
5556
) -> list[ExternalUserGroup]:
5657
slack_client = WebClient(

backend/ee/onyx/external_permissions/sync_params.py

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
DOC_SOURCE_TO_CHUNK_CENSORING_FUNCTION,
1616
)
1717
from ee.onyx.external_permissions.slack.doc_sync import slack_doc_sync
18+
from ee.onyx.external_permissions.slack.group_sync import slack_group_sync
1819
from onyx.access.models import DocExternalAccess
1920
from onyx.configs.constants import DocumentSource
2021
from onyx.db.models import ConnectorCredentialPair
@@ -56,6 +57,7 @@
5657
GROUP_PERMISSIONS_FUNC_MAP: dict[DocumentSource, GroupSyncFuncType] = {
5758
DocumentSource.GOOGLE_DRIVE: gdrive_group_sync,
5859
DocumentSource.CONFLUENCE: confluence_group_sync,
60+
DocumentSource.SLACK: slack_group_sync,
5961
}
6062

6163

backend/onyx/connectors/slack/connector.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ def thread_to_doc(
255255
def default_msg_filter(message: MessageType) -> bool:
256256
# Don't keep messages from bots
257257
if message.get("bot_id") or message.get("app_id"):
258-
if message.get("bot_profile", {}).get("name") == "OnyxConnector":
258+
bot_profile_name = message.get("bot_profile", {}).get("name")
259+
print(f"bot_profile_name: {bot_profile_name}")
260+
if bot_profile_name == "DanswerBot Testing":
259261
return False
260262
return True
261263

backend/tests/integration/common_utils/managers/cc_pair.py

+1
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ def sync(
444444
)
445445
if group_sync_result.status_code != 409:
446446
group_sync_result.raise_for_status()
447+
time.sleep(2)
447448

448449
@staticmethod
449450
def get_doc_sync_task(

backend/tests/integration/connector_job_tests/slack/conftest.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
@pytest.fixture()
1515
def slack_test_setup() -> Generator[tuple[dict[str, Any], dict[str, Any]], None, None]:
1616
slack_client = SlackManager.get_slack_client(os.environ["SLACK_BOT_TOKEN"])
17-
admin_user_id = SlackManager.build_slack_user_email_id_map(slack_client)[
18-
19-
]
17+
user_map = SlackManager.build_slack_user_email_id_map(slack_client)
18+
admin_user_id = user_map["[email protected]"]
2019

2120
(
2221
public_channel,

backend/tests/integration/connector_job_tests/slack/test_permission_sync.py

-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from datetime import timezone
44
from typing import Any
55

6-
import pytest
7-
86
from onyx.connectors.models import InputType
97
from onyx.db.enums import AccessType
108
from onyx.server.documents.models import DocumentSource
@@ -25,7 +23,6 @@
2523
from tests.integration.connector_job_tests.slack.slack_api_utils import SlackManager
2624

2725

28-
@pytest.mark.xfail(reason="flaky - see DAN-789 for example", strict=False)
2926
def test_slack_permission_sync(
3027
reset: None,
3128
vespa_client: vespa_fixture,
@@ -221,7 +218,6 @@ def test_slack_permission_sync(
221218
assert private_message not in onyx_doc_message_strings
222219

223220

224-
@pytest.mark.xfail(reason="flaky", strict=False)
225221
def test_slack_group_permission_sync(
226222
reset: None,
227223
vespa_client: vespa_fixture,

0 commit comments

Comments
 (0)