Skip to content

Commit 4323218

Browse files
committed
Add test to ensure other users cannot list credentials
1 parent 9ce668b commit 4323218

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/integration/test_credentials.py

+17
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ def test_list_user_credentials(self):
3939
assert len(list_user_credentials) == 1
4040
assert list_user_credentials[0]["source_id"] == source_id
4141

42+
def test_other_users_cannot_list_credentials(self):
43+
source_id = f"test_others_cant_list_credentials_{uuid4()}"
44+
payload = self._build_credentials_payload(source_id=source_id)
45+
self._provide_user_credentials(payload)
46+
47+
response = self._get(f"/api/users/current/credentials?source_type=tool&source_id={source_id}")
48+
self._assert_status_code_is(response, 200)
49+
list_user_credentials = response.json()
50+
assert len(list_user_credentials) == 1
51+
assert list_user_credentials[0]["source_id"] == source_id
52+
53+
with self._different_user():
54+
response = self._get(f"/api/users/current/credentials?source_type=tool&source_id={source_id}")
55+
self._assert_status_code_is(response, 200)
56+
list_user_credentials = response.json()
57+
assert len(list_user_credentials) == 0
58+
4259
def test_list_by_source_id_requires_source_type(self):
4360
response = self._get("/api/users/current/credentials?source_id=test_tool")
4461
self._assert_status_code_is(response, 400)

0 commit comments

Comments
 (0)