Skip to content

Commit

Permalink
Fix patch_auth() call according to Wok changes
Browse files Browse the repository at this point in the history
Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
  • Loading branch information
alinefm committed Feb 16, 2017
1 parent 2c98a2b commit 7e91dd2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 0 additions & 2 deletions mockmodel.py
Expand Up @@ -56,8 +56,6 @@
from wok.plugins.kimchi.utils import get_next_clone_name, pool_name_from_uri
from wok.plugins.kimchi.vmtemplate import VMTemplate


fake_user = {'root': 'letmein!'}
mockmodel_defaults = {
'domain': 'test', 'arch': 'i686'
}
Expand Down
19 changes: 10 additions & 9 deletions tests/test_authorization.py
Expand Up @@ -19,16 +19,16 @@

import cherrypy
import json
import mock
import os
import unittest
from functools import partial

from tests.utils import get_fake_user, patch_auth
from tests.utils import patch_auth
from tests.utils import request, run_server, wait_task

from iso_gen import construct_fake_iso


test_server = None
model = None
fake_iso = '/tmp/fake.iso'
Expand All @@ -37,7 +37,7 @@
def setUpModule():
global test_server, model

patch_auth(sudo=False)
patch_auth()
test_server = run_server(test_mode=True)
model = cherrypy.tree.apps['/plugins/kimchi'].root.model

Expand All @@ -52,10 +52,13 @@ def tearDownModule():

class AuthorizationTests(unittest.TestCase):
def setUp(self):
self.request = partial(request)
self.request = partial(request, user='user')
model.reset()

def test_nonroot_access(self):
@mock.patch('wok.plugins.kimchi.model.users.PAMUsersModel._validate')
def test_nonroot_access(self, validate_users):
validate_users.return_value = True

# Non-root users can not create or delete network (only get)
resp = self.request('/plugins/kimchi/networks', '{}', 'GET')
self.assertEquals(200, resp.status)
Expand Down Expand Up @@ -102,10 +105,8 @@ def test_nonroot_access(self):
})
wait_task(model.task_lookup, task_info['id'])

fake_user = get_fake_user()

model.vm_update(u'test-me',
{'users': [fake_user.keys()[0]],
{'users': ['user'],
'groups': []})

task_info = model.vms_create({
Expand All @@ -114,7 +115,7 @@ def test_nonroot_access(self):
})
wait_task(model.task_lookup, task_info['id'])

non_root = list(set(model.users_get_list()) - set(['root']))[0]
non_root = list(set(model.users_get_list()) - set(['admin']))[0]
model.vm_update(u'test-usera', {'users': [non_root], 'groups': []})

task_info = model.vms_create({
Expand Down

0 comments on commit 7e91dd2

Please sign in to comment.