This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch master in repository x2gobroker. from 46784d1 Transliterate commands in session profiles to uppercase when checking if the command is supposed to launch a desktop session. new 9fcb404 improvements for last commit, add unittests for the uppercase desktop session cmd checks The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: x2gobroker/brokers/base_broker.py | 3 ++ x2gobroker/brokers/zeroconf_broker.py | 2 +- x2gobroker/tests/test_broker_inifile.py | 21 ++++++++++++++ x2gobroker/tests/test_broker_zeroconf.py | 18 ++++++++++++ x2gobroker/tests/test_web_uccs_zeroconf.py | 42 ++++++++++++++++++++++++++++ x2gobroker/web/uccs.py | 5 +++- 6 files changed, 89 insertions(+), 2 deletions(-) -- Alioth's /srv/git/code.x2go.org/x2gobroker.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2gobroker. commit 9fcb404070c352dd34f09f5e078c8970c3b236b8 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Tue May 19 09:58:43 2015 +0200 improvements for last commit, add unittests for the uppercase desktop session cmd checks --- x2gobroker/brokers/base_broker.py | 3 ++ x2gobroker/brokers/zeroconf_broker.py | 2 +- x2gobroker/tests/test_broker_inifile.py | 21 ++++++++++++++ x2gobroker/tests/test_broker_zeroconf.py | 18 ++++++++++++ x2gobroker/tests/test_web_uccs_zeroconf.py | 42 ++++++++++++++++++++++++++++ x2gobroker/web/uccs.py | 5 +++- 6 files changed, 89 insertions(+), 2 deletions(-) diff --git a/x2gobroker/brokers/base_broker.py b/x2gobroker/brokers/base_broker.py index a618c24..6c16a34 100644 --- a/x2gobroker/brokers/base_broker.py +++ b/x2gobroker/brokers/base_broker.py @@ -1249,8 +1249,11 @@ class X2GoBroker(object): profile['key'] = u'<will-be-exchanged-during-session-selection>' # make sure that desktop sessions (that we know by name) do run with rootless=false + # and that the command string is always upper case (otherwise x2goruncommand might + # stumble over it...) if profile['command'].upper() in x2gobroker.defaults.X2GO_DESKTOP_SESSIONS: profile['rootless'] = False + profile['command'] = profile['command'].upper() remote_agent = self.get_remote_agent(profile_id) if self.check_for_sessions(profile_id): diff --git a/x2gobroker/brokers/zeroconf_broker.py b/x2gobroker/brokers/zeroconf_broker.py index a71fca9..b2179ab 100644 --- a/x2gobroker/brokers/zeroconf_broker.py +++ b/x2gobroker/brokers/zeroconf_broker.py @@ -66,7 +66,7 @@ class X2GoBroker(base.X2GoBroker): u'name': u'LOCALHOST', u'iconvto': u'UTF-8', u'soundtunnel': True, - u'command': self.get_backend_value('broker_{backend}'.format(backend=self.backend_name), u'desktop-shell'), + u'command': self.get_backend_value('broker_{backend}'.format(backend=self.backend_name), u'desktop-shell').upper(), u'dpi': 96, u'sshport': 22, u'setdpi': 0, diff --git a/x2gobroker/tests/test_broker_inifile.py b/x2gobroker/tests/test_broker_inifile.py index 6cdff67..7f08129 100644 --- a/x2gobroker/tests/test_broker_inifile.py +++ b/x2gobroker/tests/test_broker_inifile.py @@ -132,6 +132,10 @@ fullscreen = true acl-users-deny = ALL acl-users-allow = foo,bar acl-users-order = deny-allow + +[testprofile4] +user = bar +command = gnomE """ tf = tempfile.NamedTemporaryFile() print >> tf, _session_profiles @@ -165,6 +169,11 @@ acl-users-order = deny-allow u'command': 'KDE', u'fullscreen': True, }) + _expected_profile4 = copy.deepcopy(_expected_defaults) + _expected_profile4.update({ + u'user': 'bar', + u'command': 'gnomE', # mixture of lower and uppercase in get_profile() + }) _profile1 = inifile_backend.get_profile('testprofile1') for key in _expected_profile1.keys(): self.assertTrue( ( key in _profile1.keys() ) ) @@ -183,6 +192,12 @@ acl-users-order = deny-allow for key in _profile3.keys(): self.assertTrue( ( key in _expected_profile3.keys() ) and ( _profile3[key] == _expected_profile3[key] ) ) + _profile4 = inifile_backend.get_profile('testprofile4') + for key in _expected_profile4.keys(): + self.assertTrue( ( key in _profile4.keys() ) ) + for key in _profile4.keys(): + self.assertTrue( ( key in _expected_profile4.keys() ) and ( _profile4[key] == _expected_profile4[key] ) ) + ### TEST SESSION PROFILES: get_profile_acls(profile_id) def test_getprofileacls(self): @@ -308,6 +323,10 @@ command = XFCE user = command = KDE rootless = false + +[testprofile4] +user = +command = gnomE """ tf = tempfile.NamedTemporaryFile() print >> tf, _session_profiles @@ -320,6 +339,8 @@ rootless = false self.assertEqual(profiles['testprofile2']['rootless'], False) self.assertEqual(profiles['testprofile3']['command'], 'KDE') self.assertEqual(profiles['testprofile3']['rootless'], False) + self.assertEqual(profiles['testprofile4']['command'], 'GNOME') # uppercase! + self.assertEqual(profiles['testprofile4']['rootless'], False) ### TEST: list_profiles() method check acl capability diff --git a/x2gobroker/tests/test_broker_zeroconf.py b/x2gobroker/tests/test_broker_zeroconf.py index bbdfc34..3ca4934 100644 --- a/x2gobroker/tests/test_broker_zeroconf.py +++ b/x2gobroker/tests/test_broker_zeroconf.py @@ -18,6 +18,8 @@ # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. import unittest +import copy +import tempfile # Python X2GoBroker modules import x2gobroker.brokers.zeroconf_broker @@ -82,6 +84,22 @@ class TestX2GoBrokerBackendZeroconf(unittest.TestCase): ### TEST: select_profile() method + def test_desktopshell_uppercase(self): + _config_defaults = copy.deepcopy(x2gobroker.defaults.X2GOBROKER_CONFIG_DEFAULTS) + _config = """ +[broker_zeroconf] +enable = true +desktop-shell = kDe +""" + tf = tempfile.NamedTemporaryFile() + print >> tf, _config + tf.seek(0) + zeroconf_backend = x2gobroker.brokers.zeroconf_broker.X2GoBroker(config_file=tf.name, config_defaults=_config_defaults) + _profiles = zeroconf_backend.list_profiles('user_foo') + self.assertEqual(len(_profiles.keys()), 1) + _key = _profiles.keys()[0] + self.assertEqual(_profiles[_key]['command'], 'KDE') + def test_sessionselection(self): _output = { 'server': 'localhost', diff --git a/x2gobroker/tests/test_web_uccs_zeroconf.py b/x2gobroker/tests/test_web_uccs_zeroconf.py index 5492ef7..23783d2 100644 --- a/x2gobroker/tests/test_web_uccs_zeroconf.py +++ b/x2gobroker/tests/test_web_uccs_zeroconf.py @@ -87,6 +87,48 @@ desktop-shell = KDE self.assertEqual(_expected_result, result) tf.close() + def test_listsessions_uppercase_desktopcommands(self): + _expected_result = { + u'URL': u'http://localhost:8080/uccs/zeroconf', + u'AdditionalManagementServers': [], + u'Name': u'X2Go Session Broker', + u'DefaultServer': u'LOCALHOST', + u'RemoteDesktopServers': [ + { + u'Username': u'', + u'Protocol': u'x2go', + u'Name': u'LOCALHOST', + u'URL': u'http://localhost:22/', + u'SessionType': u'KDE', + u'SessionTypeRequired': True, + u'Password': u'', + }, + ], + u'URL': u'http://localhost:8080/uccs/zeroconf/', + } + _config = """ +[global] +enable-uccs-output=true +check-credentials=false + +[zeroconf] +enable = true +auth-mech = testsuite +desktop-shell = kdE +""" + tf = tempfile.NamedTemporaryFile() + print >> tf, _config + tf.seek(0) + x2gobroker.defaults.X2GOBROKER_CONFIG = tf.name + testApp = TestApp(application) + + r = testApp.get('/uccs/zeroconf/api/4', headers=headers, expect_errors=True) + assert_equal(r.status, 200) + body = r.normal_body + result = json.loads(body) + self.assertEqual(_expected_result, result) + tf.close() + def test_suite(): from unittest import TestSuite#, makeSuite diff --git a/x2gobroker/web/uccs.py b/x2gobroker/web/uccs.py index 1b228c5..c1ab032 100644 --- a/x2gobroker/web/uccs.py +++ b/x2gobroker/web/uccs.py @@ -171,7 +171,10 @@ class X2GoBrokerWebAPI(tornado.web.RequestHandler): name=profile[u'name'], username=profile[u'user'], ) - ts.set_session_type(profile['command']) + _cmd = profile['command'] + if _cmd.upper() in x2gobroker.defaults.X2GO_DESKTOP_SESSIONS: + _cmd = _cmd.upper() + ts.set_session_type(_cmd) ms.add_terminalserver(ts) ms.set_default(ts.Name) -- Alioth's /srv/git/code.x2go.org/x2gobroker.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git