示例#1
0
    def test_check_bot_get_acl_no_pool_cfg(self):
        # mock
        self.mock(acl, 'can_view_bot', lambda: False)
        self._mock_bot(['pool:pool1', 'pool:pool2'])
        self.mock(pools_config, 'get_pool_config', lambda _: None)

        # call
        with self.assertRaises(auth.AuthorizationError):
            realms.check_bot_get_acl('bot1')
        self._has_permission_mock.assert_not_called()
示例#2
0
    def test_check_bot_get_acl_allowed(self):
        # mock
        self.mock(acl, 'can_view_bot', lambda: False)
        self._mock_bot(['pool:pool1', 'pool:pool2'])
        get_pool_config = lambda p: _gen_pool_config(realm='test:' + p)
        self.mock(pools_config, 'get_pool_config', get_pool_config)

        # call
        realms.check_bot_get_acl('bot1')
        self._has_permission_mock.assert_called_once_with(
            _PERM_POOLS_LIST_BOTS, ['test:pool1', 'test:pool2'],
            identity=auth.get_current_identity())
示例#3
0
 def test_check_bot_get_acl_no_bot(self):
     self.mock(acl, 'can_view_bot', lambda: False)
     with self.assertRaises(endpoints.NotFoundException):
         realms.check_bot_get_acl('bot1')
     self._has_permission_mock.assert_not_called()
示例#4
0
    def test_check_bot_get_acl_with_global_permission(self):
        self.mock(acl, 'can_view_bot', lambda: True)

        realms.check_bot_get_acl('bot1')
        self._has_permission_mock.assert_not_called()