Files
odoo_source/addons/mail/tests/test_mail_channel_as_guest.py
T
Zelong Lin d57c64f95b [IMP] mail, *: remove 'public' field in channel
*: im_livechat, website_livechat

Access right should be based on channel type and membership instead.
Chat always private, group always private, channel private should
disapear and be a group instead (migration needed), and other channel
always public (but they can still be further restricted with
the "allowed groups" feature)

task-2632861

closes odoo/odoo#90415

Related: odoo/enterprise#30980
Related: odoo/upgrade#3850
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-09-06 10:57:59 +02:00

37 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import odoo
from odoo.tests import HttpCase
@odoo.tests.tagged('-at_install', 'post_install')
class TestMailPublicPage(HttpCase):
"""Checks that the invite page redirects to the channel and that all
modules load correctly on the welcome and channel page when authenticated as various users"""
def setUp(self):
super().setUp()
self.channel = self.env['mail.channel'].browse(self.env['mail.channel'].channel_create(group_id=None, name='Test channel')['id'])
self.tour = "mail/static/tests/tours/discuss_public_tour.js"
def _open_channel_page_as_user(self, login):
self.start_tour(self.channel.invitation_url, self.tour, login=login)
# Second run of the tour as the first call has side effects, like creating user settings or adding members to
# the channel, so we need to run it again to test different parts of the code.
self.start_tour(self.channel.invitation_url, self.tour, login=login)
def test_mail_channel_public_page_as_admin(self):
self._open_channel_page_as_user('admin')
def test_mail_channel_public_page_as_guest(self):
self.start_tour(self.channel.invitation_url, "mail/static/tests/tours/mail_channel_as_guest_tour.js")
guest = self.env['mail.guest'].search([('channel_ids', 'in', self.channel.id)], limit=1, order='id desc')
self.start_tour(self.channel.invitation_url, self.tour, cookies={guest._cookie_name: f"{guest.id}{guest._cookie_separator}{guest.access_token}"})
def test_mail_channel_public_page_as_internal(self):
self._open_channel_page_as_user('demo')
def test_mail_channel_public_page_as_portal(self):
self._open_channel_page_as_user('portal')