|
35 | 35 | random_pre_registration_details, |
36 | 36 | ) |
37 | 37 | from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict |
38 | | -from pytest_simcore.helpers.webserver_login import NewUser, UserInfoDict |
| 38 | +from pytest_simcore.helpers.webserver_login import ( |
| 39 | + NewUser, |
| 40 | + UserInfoDict, |
| 41 | + switch_client_session_to, |
| 42 | +) |
39 | 43 | from servicelib.aiohttp import status |
40 | 44 | from servicelib.rest_constants import RESPONSE_MODEL_POLICY |
41 | 45 | from simcore_service_webserver.users._common.schemas import ( |
@@ -226,6 +230,8 @@ async def test_search_users_by_partial_username( |
226 | 230 | semi_private_user: UserInfoDict, |
227 | 231 | private_user: UserInfoDict, |
228 | 232 | ): |
| 233 | + assert client.app |
| 234 | + |
229 | 235 | # SEARCH by partial username |
230 | 236 | assert partial_username in private_user["name"] |
231 | 237 | assert partial_username in semi_private_user["name"] |
@@ -254,6 +260,32 @@ async def test_search_users_by_partial_username( |
254 | 260 | assert found[index].last_name == semi_private_user.get("last_name") |
255 | 261 |
|
256 | 262 |
|
| 263 | +async def test_search_myself( |
| 264 | + client: TestClient, |
| 265 | + public_user: UserInfoDict, |
| 266 | + semi_private_user: UserInfoDict, |
| 267 | + private_user: UserInfoDict, |
| 268 | +): |
| 269 | + assert client.app |
| 270 | + for user in [public_user, semi_private_user, private_user]: |
| 271 | + async with switch_client_session_to(client, user): |
| 272 | + |
| 273 | + # search me |
| 274 | + url = client.app.router["search_users"].url_for() |
| 275 | + resp = await client.post(f"{url}", json={"match": user["name"]}) |
| 276 | + data, _ = await assert_status(resp, status.HTTP_200_OK) |
| 277 | + |
| 278 | + found = TypeAdapter(list[UserGet]).validate_python(data) |
| 279 | + assert found |
| 280 | + assert len(found) == 1 |
| 281 | + |
| 282 | + # I can see my own data |
| 283 | + assert found[0].user_name == user["name"] |
| 284 | + assert found[0].email == user["email"] |
| 285 | + assert found[0].first_name == user.get("first_name") |
| 286 | + assert found[0].last_name == user.get("last_name") |
| 287 | + |
| 288 | + |
257 | 289 | @pytest.mark.acceptance_test( |
258 | 290 | "https://github.com/ITISFoundation/osparc-issues/issues/1779" |
259 | 291 | ) |
|
0 commit comments