Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why am I getting all invitations, incl. the ones not assigned to me? #482

Closed
bardram opened this issue Sep 8, 2024 · 9 comments · Fixed by #483
Closed

Why am I getting all invitations, incl. the ones not assigned to me? #482

bardram opened this issue Sep 8, 2024 · 9 comments · Fixed by #483
Assignees
Labels
enhancement Nice to have, non-functional requirements.

Comments

@bardram
Copy link
Collaborator

bardram commented Sep 8, 2024

I have made a family study with a father and a mother, and made a deployment with assignments to users like this:

image

So - Jakob is the "Mother" and Aamir is the "Father".

However, when I authenticate to CAWS as "Jakob" ([email protected]), I get the following invitations from the ParticipationService:

[
    {
        "participation": {
            "studyDeploymentId": "58ce18ff-40e3-4cd0-9fba-fc893d784891",
            "participantId": "264bf3dc-b6c8-4252-b44e-2c5e00262ce9",
            "assignedRoles": {
                "__type": "dk.cachet.carp.common.application.users.AssignedTo.Roles",
                "roleNames": [
                    "Mother"
                ]
            }
        },
        "invitation": {
            "name": "Family Study w. Participant Data",
            "applicationData": "d6d047d5-4cfd-479b-87ac-99f4b5fee172"
        },
        "assignedDevices": [
            {
                "device": {
                    "__type": "dk.cachet.carp.common.application.devices.Smartphone",
                    "roleName": "Mother's Phone",
                    "isPrimaryDevice": true
                }
            }
        ]
    },
    {
        "participation": {
            "studyDeploymentId": "58ce18ff-40e3-4cd0-9fba-fc893d784891",
            "participantId": "5b486d25-b75e-4116-9a4f-eea8105ceea0",
            "assignedRoles": {
                "__type": "dk.cachet.carp.common.application.users.AssignedTo.Roles",
                "roleNames": [
                    "Father"
                ]
            }
        },
        "invitation": {
            "name": "Family Study w. Participant Data",
            "applicationData": "d6d047d5-4cfd-479b-87ac-99f4b5fee172"
        },
        "assignedDevices": [
            {
                "device": {
                    "__type": "dk.cachet.carp.common.application.devices.Smartphone",
                    "roleName": "Father's Phone",
                    "isPrimaryDevice": true
                }
            }
        ]
    },
]

So - even though I autheticate as the "Mother" I get BOTH invitations????

This entails, that I (as a participant) could choose to be the Father, even though the researcher has assigned me the Mother role......

@bardram bardram added bug Something isn't working the way it was designed to. needs discussion This cannot yet be implemented since it requires further conversation. labels Sep 8, 2024
@bardram bardram changed the title Why am I getting all invitations, incl. the ones not for me? Why am I getting all invitations, incl. the ones not assigned to me? Sep 8, 2024
@Whathecode
Copy link
Member

Whathecode commented Sep 9, 2024

This could also be a CAWS bug. Let's have a look whether we have proper coverage of the Core part of this logic ...

Seemingly not. It should be worthwhile adding a more complex invitation test here similar to the scenario you describe.

Maybe a suitable small task for @yuanchen233 ? That way we can more easily determine whether it is CAWS or Core.

@bardram
Copy link
Collaborator Author

bardram commented Sep 19, 2024

@Whathecode - I'm a bit confused. Is this a bug in Core or CAWS? Above you point to a test case, but this doesn't reveal (at least to me) if something has to be "fixed" in Core.

@Whathecode
Copy link
Member

Whathecode commented Sep 19, 2024

The code was sufficiently complex I couldn't quickly/easily rule it out as a core bug. It's missing test coverage to do so. I haven't looked into more detail.

So best approach is adding such a test so we have future coverage, and we'll know whether it is core or CAWS. :)

@yuanchen233
Copy link
Collaborator

We don't have test case covering this scenario, thus can not tell if this is something need to be fixed in Core. I can look into this next.

But, the description for getActiveParticipationInvitations states 'all participations', so does this imply this result is expected?

@Whathecode
Copy link
Member

But, the description for getActiveParticipationInvitations states 'all participations', so does this imply this result is expected?

It does qualify:

.... the account with the given [accountId] has been invited to.

So, it shouldn't return participations from other account IDs. ;)

@yuanchen233
Copy link
Collaborator

I wrote a simple test case and Core implementation works as expected,
this bug is caused by CAWS implementation of ParticipationRepository.getParticipationInvitations.
More specifically, participations from all participantGroup should be flattened before filter by accountId, otherwise it will return all participations within a participant group which contains that accountId.

@Whathecode Whathecode added enhancement Nice to have, non-functional requirements. and removed needs discussion This cannot yet be implemented since it requires further conversation. bug Something isn't working the way it was designed to. labels Sep 19, 2024
@Whathecode
Copy link
Member

Thank you @yuanchen233 Feel free to create a PR for the test case. It would still be relevant for core.

Reassigned this as an "enhancement" (providing test coverage) rather than a bug.

@bardram
Copy link
Collaborator Author

bardram commented Sep 24, 2024

I just tested this on the new DEV deployment and now I only get the invitations I am supposed to get.

@yuanchen233
Copy link
Collaborator

Thank you @yuanchen233 Feel free to create a PR for the test case. It would still be relevant for core.

Sure and thanks, I wanted to see if there are other situations/test cases can benefit from a more complex participant group as well, but didn't find anything right away. If this scenario can be re-used for testing other modules, I'll add it to createTestObject.

Whathecode added a commit that referenced this issue Sep 26, 2024
…/devices

A question arose whether the `getActiveParticipationInvitation()` endpoint returning multiple invitations was a CARP core bug, or a bug in the CARP platform (webservices). This unit test shows this works properly in CARP core.

An exception to the detekt rule `DestructuringDeclarationWithTooManyEntries` for test sources was added, as overall it can help clean up otherwise distracting repetitive parts of test setup.

Closes #482 

---------

Co-authored-by: Steven Jeuris <[email protected]>
Whathecode added a commit that referenced this issue Oct 5, 2024
…/devices

A question arose whether the `getActiveParticipationInvitation()` endpoint returning multiple invitations was a CARP core bug, or a bug in the CARP platform (webservices). This unit test shows this works properly in CARP core.

An exception to the detekt rule `DestructuringDeclarationWithTooManyEntries` for test sources was added, as overall it can help clean up otherwise distracting repetitive parts of test setup.

Closes #482 

---------

Co-authored-by: Steven Jeuris <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Nice to have, non-functional requirements.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants