From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
As test model includes test against pam user/group listing,
using pam authentication instead of fake authentication.
Also change test cases which used fake user/group update
to use pam user validation and update.
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/mockmodel.py | 4 ++++
tests/test_authorization.py | 3 ++-
tests/test_model.py | 3 ++-
tests/utils.py | 3 ++-
4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index 9089ef6..5f91d7d 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -33,6 +33,8 @@ from kimchi.model.host import DeviceModel
from kimchi.model.model import Model
from kimchi.model.storagevolumes import StorageVolumesModel
from kimchi.model.templates import LibvirtVMTemplate
+from kimchi.model.users import PAMUsersModel
+from kimchi.model.groups import PAMGroupsModel
from kimchi.objectstore import ObjectStore
from kimchi.utils import add_task, get_next_clone_name
from kimchi.vmtemplate import VMTemplate
@@ -99,6 +101,8 @@ class MockModel(Model):
LibvirtVMTemplate._get_volume_path = self._get_volume_path
VMTemplate.get_iso_info = self._probe_image
imageinfo.probe_image = self._probe_image
+ PAMUsersModel.auth_type = 'fake'
+ PAMGroupsModel.auth_type = 'fake'
def reset(self):
MockModel._mock_vms = {}
diff --git a/tests/test_authorization.py b/tests/test_authorization.py
index a8a94fe..4fcc496 100644
--- a/tests/test_authorization.py
+++ b/tests/test_authorization.py
@@ -131,7 +131,8 @@ class AuthorizationTests(unittest.TestCase):
model.vms_create({'name': u'test-groupa',
'template': '/templates/test'})
- model.vm_update(u'test-groupa', {'groups': ['wheel']})
+ a_group = model.groups_get_list()[0]
+ model.vm_update(u'test-groupa', {'groups': [a_group]})
resp = self.request('/vms', '{}', 'GET')
self.assertEquals(200, resp.status)
diff --git a/tests/test_model.py b/tests/test_model.py
index c68b01f..0b91edc 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -38,7 +38,7 @@ import iso_gen
import kimchi.objectstore
import utils
from kimchi import netinfo
-from kimchi.config import paths
+from kimchi.config import config, paths
from kimchi.exception import ImageFormatError, InvalidOperation
from kimchi.exception import InvalidParameter, NotFoundError, OperationFailed
from kimchi.iscsi import TargetClient
@@ -934,6 +934,7 @@ class ModelTests(unittest.TestCase):
'new-test', params)
def test_vm_edit(self):
+ config.set("authentication", "method", "pam")
inst = model.Model(None,
objstore_loc=self.tmp_store)
diff --git a/tests/utils.py b/tests/utils.py
index f846d48..c692041 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -20,6 +20,7 @@
import base64
import cherrypy
+import grp
import httplib
import json
import os
@@ -181,7 +182,7 @@ class FakeUser(User):
self.user[USER_ROLES] = dict.fromkeys(tabs, 'user')
def get_groups(self):
- return ['groupA', 'groupB', 'wheel']
+ return sorted([group.gr_name for group in grp.getgrall()])[0:3]
def get_roles(self):
if self.sudo:
--
1.8.3.2