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

[FIX] runbot: allow a runbot admin to create runbot batch log #532

Open
wants to merge 2 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions runbot/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ access_runbot_category_runbot_user,access_runbot_category_runbot_user,runbot.mod
access_runbot_category_runbot_admin,access_runbot_category_runbot_admin,runbot.model_runbot_category,runbot.group_runbot_admin,1,1,1,1

access_runbot_batch_log_runbot_user,access_runbot_batch_log_runbot_user,runbot.model_runbot_batch_log,runbot.group_user,1,0,0,0
access_runbot_batch_log_runbot_admin,access_runbot_batch_log_runbot_admin,runbot.model_runbot_batch_log,runbot.group_runbot_admin,1,1,1,1

access_runbot_warning_user,access_runbot_warning_user,runbot.model_runbot_warning,runbot.group_user,1,0,0,0
access_runbot_warning_admin,access_runbot_warning_admin,runbot.model_runbot_warning,runbot.group_runbot_admin,1,1,1,1
Expand Down
1 change: 1 addition & 0 deletions runbot/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
from . import test_commit
from . import test_upgrade
from . import test_dockerfile
from . import test_batch
from . import test_host
31 changes: 31 additions & 0 deletions runbot/tests/test_batch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from odoo.exceptions import AccessError
from odoo.tests.common import new_test_user

from .common import RunbotCase


class TestBatchLog(RunbotCase):

def test_batch_log_write(self):
""" test that a runbot manager can write a batch log """
self.additionnal_setup()

create_context = {'no_reset_password': True, 'mail_create_nolog': True, 'mail_create_nosubscribe': True, 'mail_notrack': True}
simple_user = new_test_user(self.env, login='simple', name='simple', password='simple', context=create_context)
runbot_admin = new_test_user(self.env, groups='runbot.group_runbot_admin,base.group_user', login='runbot_admin', name='runbot_admin', password='admin', context=create_context)

# Ensure that a simple user cannot interfere in batch logs
with self.assertRaises(AccessError):
self.env['runbot.batch.log'].with_user(simple_user).create({
'batch_id': self.branch_server.bundle_id.last_batch.id,
'message': 'test_message',
'level': 'INFO'
})

test_batch_log = self.env['runbot.batch.log'].with_user(runbot_admin).create({
'batch_id': self.branch_server.bundle_id.last_batch.id,
'message': 'test_message',
'level': 'INFO'
})

self.assertEqual(test_batch_log.message, 'test_message')