[X2Go-Commits] x2gobroker.git - build-main (branch) updated: 26bbbeff46c29c039dd9574d1c1b57284c360d61
X2Go dev team
git-admin at x2go.org
Sun May 19 13:03:03 CEST 2013
The branch, build-main has been updated
via 26bbbeff46c29c039dd9574d1c1b57284c360d61 (commit)
from b52e51c2d66eb72980f93efafe27d64d58597c32 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
x2gobroker/backends/base.py | 60 +++++++++++++++++++++++++--
x2gobroker/tests/test_backend_base.py | 33 +++++++++++++++
x2gobroker/tests/test_web_plain_zeroconf.py | 2 -
3 files changed, 89 insertions(+), 6 deletions(-)
The diff of changes is:
diff --git a/x2gobroker/backends/base.py b/x2gobroker/backends/base.py
index 9c2e5b7..1bde0e7 100644
--- a/x2gobroker/backends/base.py
+++ b/x2gobroker/backends/base.py
@@ -297,10 +297,7 @@ class X2GoBroker(object):
def _do_authenticate(self, username='', password=''):
- if self.config.has_value(self.backend_name, 'auth-mech'):
- _auth_mech = self.config.get_value(self.backend_name, 'auth-mech').lower()
- else:
- _auth_mech = "pam"
+ _auth_mech = self.get_authentication_mechanism()
if _auth_mech == 'pam':
return self._auth_mech_pam(username=username, password=password)
@@ -313,6 +310,61 @@ class X2GoBroker(object):
return False
+ def get_authentication_mechanism(self):
+ """\
+ Get the name of the authentication mechanism that is configured for this
+ X2Go Session Broker instance.
+
+ @return: auth-mech name
+ @rtype: C{unicode}
+
+ """
+ _default_auth_mech = "pam"
+ _auth_mech = ""
+ if self.config.has_value('global', 'default-auth-mech'):
+ _default_auth_mech = self.config.get_value('global', 'default-auth-mech').lower()
+
+ if self.config.has_value(self.backend_name, 'auth-mech'):
+ _auth_mech = self.config.get_value(self.backend_name, 'auth-mech').lower()
+
+ return unicode(_auth_mech) or unicode(_default_auth_mech)
+
+ def get_userdb_backend(self):
+ """\
+ Get the name of the backend being used for retrieving user information from the
+ system.
+
+ @return: user database backend name
+ @rtype: C{unicode}
+
+ """
+ _user_db = "libnss"
+ if self.config.has_value('global', 'default-user-db'):
+ _user_db = self.config.get_value('global', 'default-user-db').lower()
+
+ if self.config.has_value(self.backend_name, 'user-db'):
+ _user_db = self.config.get_value(self.backend_name, 'user-db').lower()
+
+ return unicode(_user_db)
+
+ def get_groupdb_backend(self):
+ """\
+ Get the name of the backend being used for retrieving group information from the
+ system.
+
+ @return: group database backend name
+ @rtype: C{unicode}
+
+ """
+ _group_db = "libnss"
+ if self.config.has_value('global', 'default-group-db'):
+ _group_db = self.config.get_value('global', 'default-group-db').lower()
+
+ if self.config.has_value(self.backend_name, 'group-db'):
+ _group_db = self.config.get_value(self.backend_name, 'group-db').lower()
+
+ return unicode(_group_db)
+
def check_access(self, username='', password='', authid=None, ):
"""\
Check if a given user with a given password may gain access to the
diff --git a/x2gobroker/tests/test_backend_base.py b/x2gobroker/tests/test_backend_base.py
index b629156..33f5efe 100644
--- a/x2gobroker/tests/test_backend_base.py
+++ b/x2gobroker/tests/test_backend_base.py
@@ -61,6 +61,39 @@ enable = true
self.assertEqual(base_backend.is_enabled(), True)
tf.close()
+ ### TEST CONFIGURATION: <backend> >> enable = true|false
+
+ def test_globalandbackendoptions(self):
+ _config_defaults = copy.deepcopy(x2gobroker.defaults.X2GOBROKER_CONFIG_DEFAULTS)
+ _config_defaults.update({'base': {'enable': True, }, })
+ _config = """
+[global]
+default-auth-mech = foo-auth-mech
+
+[base]
+enable = true
+"""
+ tf = tempfile.NamedTemporaryFile()
+ print >> tf, _config
+ tf.seek(0)
+ base_backend = x2gobroker.backends.base.X2GoBroker(config_file=tf.name)
+ self.assertEqual(base_backend.get_authentication_mechanism(), 'foo-auth-mech')
+ _config = """
+[global]
+default-auth-mech = foo-auth-mech
+
+[base]
+enable = true
+auth-mech = bar-auth-mech
+"""
+ tf = tempfile.NamedTemporaryFile()
+ print >> tf, _config
+ tf.seek(0)
+ base_backend = x2gobroker.backends.base.X2GoBroker(config_file=tf.name, config_defaults=_config_defaults)
+ self.assertEqual(base_backend.get_authentication_mechanism(), 'bar-auth-mech')
+ tf.close()
+
+
### TEST CONFIGURATION: global >> check-credentials = false
def test_check_access_nocreds(self):
diff --git a/x2gobroker/tests/test_web_plain_zeroconf.py b/x2gobroker/tests/test_web_plain_zeroconf.py
index 287ab89..4d6020e 100644
--- a/x2gobroker/tests/test_web_plain_zeroconf.py
+++ b/x2gobroker/tests/test_web_plain_zeroconf.py
@@ -31,8 +31,6 @@ from x2gobroker.web.plain import *
urls = ( '/plain/(.*)', 'X2GoBrokerWebPlain',)
app = web.application(urls, globals())
-x2gobroker.defaults.X2GOBROKER_CONFIG_DEFAULTS.update({'base': {'enable': True, 'auth-mech': 'pam', }, })
-
class TestX2GoBrokerWebPlainZeroconf(unittest.TestCase):
### TEST TASK: listsessions (you can influence the session command via the X2Go Broker's configurationfile)
hooks/post-receive
--
x2gobroker.git (HTTP(S) Session broker for X2Go)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).
More information about the x2go-commits
mailing list