Skip to content

Commit

Permalink
[FIX] runbot: allow a runbot admin to create runbot batch log
Browse files Browse the repository at this point in the history
When a runbot admin creates a cron for e.g. nightly builds, the cron may
fails if a runbot.batch.log is written.

With this commit, a runbot admin can create such a log.
  • Loading branch information
d-fence committed Sep 10, 2021
1 parent 2604d96 commit a6a931d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions runbot/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,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,3 +14,4 @@
from . import test_commit
from . import test_upgrade
from . import test_dockerfile
from . import test_batch
29 changes: 29 additions & 0 deletions runbot/tests/test_batch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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):
test_batch_log = 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'
})

0 comments on commit a6a931d

Please sign in to comment.