示例#1
0
    def test_board_membership_permissions_for_admin(self):
        organization_membership = OrganizationMembershipFactory(role=OrganizationMemberRole.ADMIN)
        board_membership = BoardMembershipFactory(organization_membership=organization_membership)
        target_board_membership = BoardMembershipFactory(
            organization_membership=OrganizationMembershipFactory(organization=organization_membership.organization),
            board_id=board_membership.board_id,
        )
        target_owner_board_membership = BoardMembershipFactory(
            organization_membership=OrganizationMembershipFactory(
                organization=organization_membership.organization,
                role=OrganizationMemberRole.OWNER,
            ),
            board_id=board_membership.board_id,
        )

        permissions = PermissionsService.get_board_membership_permissions(
            board_membership_id=target_board_membership.id,
            user_id=organization_membership.user_id,
        )
        self._assert_has_all_permissions(permissions)

        permissions = PermissionsService.get_board_membership_permissions(
            board_membership_id=target_owner_board_membership.id,
            user_id=organization_membership.user_id,
        )
        self._assert_has_read_permissions(permissions)

        permissions = PermissionsService.get_board_membership_permissions(
            board_membership_id=board_membership.id,
            user_id=organization_membership.user_id,
        )
        self._assert_has_all_permissions(permissions)
示例#2
0
    def test_board_membership_permissions_for_not_a_board_member(self):
        organization_membership = OrganizationMembershipFactory(role=OrganizationMemberRole.MEMBER)
        target_board_membership = BoardMembershipFactory(
            organization_membership=OrganizationMembershipFactory(organization=organization_membership.organization),
        )

        permissions = PermissionsService.get_board_membership_permissions(
            board_membership_id=target_board_membership.id,
            user_id=organization_membership.user_id,
        )
        self._assert_has_no_permissions(permissions)
示例#3
0
 def test_board_membership_permissions_board_membership_not_found(self):
     permissions = PermissionsService.get_board_membership_permissions(
         board_membership_id=-1,
         user_id=UserFactory().id,
     )
     self._assert_has_no_permissions(permissions)
示例#4
0
 def test_board_membership_permissions_for_a_random_user(self):
     permissions = PermissionsService.get_board_membership_permissions(
         board_membership_id=BoardMembershipFactory().id,
         user_id=UserFactory().id,
     )
     self._assert_has_no_permissions(permissions)