Skip to content

Commit 770ca65

Browse files
WilliamBergaminClaude
andauthored
fix(oauth): add async delete methods to the sqlite3 installation store (#2065)
Co-authored-by: Claude <svc-devxp-claude@slack-corp.com>
1 parent b041c02 commit 770ca65

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

‎slack_sdk/oauth/installation_store/sqlite3/__init__.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,9 @@ def find_installation(
536536
self.logger.warning(message)
537537
return None
538538

539+
async def async_delete_bot(self, *, enterprise_id: Optional[str], team_id: Optional[str]) -> None:
540+
return self.delete_bot(enterprise_id=enterprise_id, team_id=team_id)
541+
539542
def delete_bot(self, *, enterprise_id: Optional[str], team_id: Optional[str]) -> None:
540543
try:
541544
with self.connect() as conn:
@@ -561,6 +564,15 @@ def delete_bot(self, *, enterprise_id: Optional[str], team_id: Optional[str]) ->
561564
else:
562565
self.logger.warning(message)
563566

567+
async def async_delete_installation(
568+
self,
569+
*,
570+
enterprise_id: Optional[str],
571+
team_id: Optional[str],
572+
user_id: Optional[str] = None,
573+
) -> None:
574+
return self.delete_installation(enterprise_id=enterprise_id, team_id=team_id, user_id=user_id)
575+
564576
def delete_installation(
565577
self,
566578
*,

‎tests/slack_sdk/oauth/installation_store/test_sqlite3.py‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from slack_sdk.oauth.installation_store import Installation
44
from slack_sdk.oauth.installation_store.sqlite3 import SQLite3InstallationStore
5+
from tests.helpers import async_test
56

67

78
class TestSQLite3(unittest.TestCase):
@@ -158,6 +159,40 @@ def test_org_installation(self):
158159
bot = store.find_bot(enterprise_id="EO111", team_id=None)
159160
self.assertIsNone(bot)
160161

162+
@async_test
163+
async def test_async_delete(self):
164+
store = SQLite3InstallationStore(database="logs/test.db", client_id="111.222")
165+
installation = Installation(
166+
app_id="A111",
167+
enterprise_id="E111",
168+
team_id="T111",
169+
user_id="U111",
170+
bot_id="B111",
171+
bot_token="xoxb-111",
172+
bot_scopes=["chat:write"],
173+
bot_user_id="U222",
174+
)
175+
await store.async_save(installation)
176+
177+
# delete installations
178+
await store.async_delete_installation(enterprise_id="E111", team_id="T111", user_id="U111")
179+
i = await store.async_find_installation(enterprise_id="E111", team_id="T111", user_id="U111")
180+
self.assertIsNone(i)
181+
182+
# delete bots
183+
await store.async_delete_bot(enterprise_id="E111", team_id="T111")
184+
bot = await store.async_find_bot(enterprise_id="E111", team_id="T111")
185+
self.assertIsNone(bot)
186+
187+
# delete all
188+
await store.async_save(installation)
189+
await store.async_delete_all(enterprise_id="E111", team_id="T111")
190+
191+
i = await store.async_find_installation(enterprise_id="E111", team_id="T111")
192+
self.assertIsNone(i)
193+
bot = await store.async_find_bot(enterprise_id="E111", team_id="T111")
194+
self.assertIsNone(bot)
195+
161196
def test_save_and_find_token_rotation(self):
162197
store = SQLite3InstallationStore(database="logs/test.db", client_id="111.222")
163198

0 commit comments

Comments
 (0)