tests: group invitation
This commit is contained in:
parent
da6bd22199
commit
2b4c875da3
1 changed files with 74 additions and 0 deletions
|
|
@ -675,3 +675,77 @@ async def test_delete_group_users_success(default_client: AsyncClient):
|
|||
assert "group" in data
|
||||
assert data["group"]["id"] == 1
|
||||
assert data["group"]["name"] == "Org One Group"
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_put_group_user_invitation_success(default_client: AsyncClient):
|
||||
body = {"user_email": "admin@test.com", "organisation_id": 1, "group_id": 1}
|
||||
resp = await default_client.put("/iam/group/user/invitation", json=body)
|
||||
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert "organisation" in data
|
||||
assert isinstance(data["organisation"], dict)
|
||||
assert data["organisation"]["id"] == 1
|
||||
assert data["organisation"]["name"] == "Org One"
|
||||
|
||||
assert "invited_email" in data
|
||||
assert isinstance(data["invited_email"], str)
|
||||
assert data["invited_email"] == "admin@test.com"
|
||||
|
||||
assert "group" in data
|
||||
assert isinstance(data["group"], dict)
|
||||
assert data["group"]["name"] == "Org One Group"
|
||||
assert data["group"]["id"] == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"body, expected_status",
|
||||
[
|
||||
({"organisation_id": 42, "user_email": "admin@test.com", "group_id": 1}, 404),
|
||||
(
|
||||
{
|
||||
"organisation_id": "Test Org",
|
||||
"user_email": "admin@test.com",
|
||||
"group_id": 1,
|
||||
},
|
||||
422,
|
||||
),
|
||||
({"organisation_id": "", "user_email": "admin@test.com", "group_id": 1}, 422),
|
||||
({}, 422),
|
||||
({"user_email": 42, "group_id": 1}, 422),
|
||||
({"organisation_id": 1, "user_email": "Test User", "group_id": 1}, 422),
|
||||
({"organisation_id": 1, "user_email": "admin@test.com", "group_id": 42}, 404),
|
||||
({"organisation_id": "Test Org", "user_email": "admin@test.com"}, 422),
|
||||
({"organisation_id": "", "user_email": "admin@test.com"}, 422),
|
||||
({"user_email": 42}, 422),
|
||||
],
|
||||
)
|
||||
@pytest.mark.anyio
|
||||
async def test_put_group_user_invitation_status_checks(
|
||||
default_client: AsyncClient, body, expected_status
|
||||
):
|
||||
resp = await default_client.put("/iam/group/user/invitation", json=body)
|
||||
|
||||
assert resp.status_code == expected_status
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"body, expected_status",
|
||||
[
|
||||
({"jwt": "invalid"}, 401),
|
||||
({"jwt": ""}, 401),
|
||||
({"jwt": None}, 422),
|
||||
({"jwt": 42}, 422),
|
||||
],
|
||||
)
|
||||
@pytest.mark.anyio
|
||||
async def test_put_group_user_invitation_accept_status_checks(
|
||||
default_client: AsyncClient, body, expected_status
|
||||
):
|
||||
resp = await default_client.put("/iam/group/user/invitation/accept", json=body)
|
||||
|
||||
assert resp.status_code == expected_status
|
||||
|
||||
if resp.status_code == 401:
|
||||
assert resp.json()["detail"] == "Invalid JWS"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue