def test_explicit_base_url(self): self.update_settings({'jujugui.base_url': '/ignore/prefix'}) jujugui.make_application(self.config) response = views.config(self.request) config = self.check_response(response) self.assertEqual('sandbox', config['jujuEnvUUID']) self.assertEqual('/ignore/prefix', config['baseUrl'])
def test_included(self): jujugui.gui.includeme(self.config) self.request.matchdict['uuid'] = 'env-uuid' response = views.config(self.request) config = self.check_response(response) self.assertEqual('env-uuid', config['jujuEnvUUID']) self.assertEqual('/u/anonymous/env-uuid', config['baseUrl'])
def test_customized_options(self): self.update_settings({ 'jujugui.auth': 'blob', 'jujugui.charmstore_url': 'http://1.2.3.4/cs-api', 'jujugui.discharge_token': 'my_discharge_token', 'jujugui.gisf': 'true', 'jujugui.jujushellURL': 'https://shell.example.com', 'jujugui.gisflogout_url': '/logout', 'jujugui.GTM_enabled': 'true', 'jujugui.insecure': 'true', 'jujugui.password': '******', 'jujugui.plans_url': 'http://1.2.3.4/plans-api/', 'jujugui.stats_url': '/_stats', 'jujugui.terms_url': 'http://1.2.3.4/terms-api', 'jujugui.user': '******', }) jujugui.make_application(self.config) response = views.config(self.request) config = self.check_response(response) self.assertEqual('https://shell.example.com', config['jujushellURL']) self.assertEqual('http://1.2.3.4/cs-api/', config['charmstoreURL']) self.assertEqual('http://1.2.3.4/plans-api/', config['plansURL']) self.assertEqual('/_stats', config['statsURL']) self.assertEqual('http://1.2.3.4/terms-api/', config['termsURL']) self.assertTrue(config['GTM_enabled']) self.assertEqual('blob', config['auth']) # User/password values that are explitly set trump defaults. self.assertEqual('who', config['user']) self.assertEqual('secret', config['password']) self.assertEqual('my_discharge_token', config['dischargeToken']) self.assertEqual('/logout', config['gisfLogout'])
def test_customized_options(self): self.update_settings({ 'jujugui.charmstore_url': 'http://1.2.3.4/cs-api', 'jujugui.plans_url': 'http://1.2.3.4/plans-api', 'jujugui.terms_url': 'http://1.2.3.4/terms-api', 'jujugui.GTM_enabled': 'true', 'jujugui.sandbox': 'true', 'jujugui.auth': 'blob', 'jujugui.user': '******', 'jujugui.password': '******', 'jujugui.insecure': 'true', }) jujugui.make_application(self.config) response = views.config(self.request) config = self.check_response(response) self.assertEqual('http://1.2.3.4/cs-api', config['charmstoreURL']) self.assertEqual('http://1.2.3.4/plans-api', config['plansURL']) self.assertEqual('http://1.2.3.4/terms-api', config['termsURL']) self.assertTrue(config['GTM_enabled']) self.assertEqual('blob', config['auth']) # Note that here we are testing that the value is actually True or # False, not that it just evaluates to True/False(like in assertTrue). self.assertIs(True, config['sandbox']) # User/password values that are explitly set trump defaults. self.assertEqual('who', config['user']) self.assertEqual('secret', config['password'])
def test_customized_options(self): self.update_settings({ 'jujugui.auth': 'blob', 'jujugui.charmstore_url': 'http://1.2.3.4/cs-api', 'jujugui.discharge_token': 'my_discharge_token', 'jujugui.gisf': 'true', 'jujugui.GTM_enabled': 'true', 'jujugui.insecure': 'true', 'jujugui.password': '******', 'jujugui.plans_url': 'http://1.2.3.4/plans-api', 'jujugui.terms_url': 'http://1.2.3.4/terms-api', 'jujugui.user': '******', }) jujugui.make_application(self.config) response = views.config(self.request) config = self.check_response(response) self.assertEqual('http://1.2.3.4/cs-api', config['charmstoreURL']) self.assertEqual('http://1.2.3.4/plans-api', config['plansURL']) self.assertEqual('http://1.2.3.4/terms-api', config['termsURL']) self.assertTrue(config['GTM_enabled']) self.assertEqual('blob', config['auth']) # User/password values that are explitly set trump defaults. self.assertEqual('who', config['user']) self.assertEqual('secret', config['password']) self.assertEqual('my_discharge_token', config['dischargeToken']) self.assertEqual('/logout', config['gisfLogout'])
def test_credentials(self): self.update_settings({ 'jujugui.user': '******', 'jujugui.password': '******', }) jujugui.make_application(self.config) response = views.config(self.request) config = self.check_response(response) self.assertEqual('dalek', config['user']) self.assertEqual('exterminate!', config['password'])
def test_credentials(self): self.update_settings({ 'jujugui.user': '******', 'jujugui.password': '******', }) jujugui.make_application(self.config) response = views.config(self.request) config = self.check_response(response) # When sandbox mode is disabled, the real credentials are provided. self.assertIs(False, config['sandbox']) self.assertEqual('dalek', config['user']) self.assertEqual('exterminate!', config['password'])
def test_default_options(self): jujugui.make_application(self.config) response = views.config(self.request) config = self.check_response(response) self.assertEqual('wss', config['socket_protocol']) self.assertEqual( options.DEFAULT_CHARMSTORE_URL, config['charmstoreURL']) self.assertFalse(config['GTM_enabled']) # Note that here we are testing that the value is actually True or # False, not that it just evaluates to True/False(like in assertTrue). self.assertIs(True, config['consoleEnabled']) self.assertEqual('', config['jujuCoreVersion']) self.assertIs(False, config['sandbox']) self.assertEqual('', config['user']) self.assertIsNone(config['password']) self.assertEqual('', config['baseUrl']) self.assertIsNone(config['auth'])
def test_default_options(self): jujugui.make_application(self.config) response = views.config(self.request) config = self.check_response(response) self.assertEqual('wss', config['socket_protocol']) self.assertEqual(options.DEFAULT_CHARMSTORE_URL, config['charmstoreURL']) self.assertFalse(config['GTM_enabled']) # Note that here we are testing that the value is actually True or # False, not that it just evaluates to True/False(like in assertTrue). self.assertIs(True, config['consoleEnabled']) self.assertEqual('', config['jujuCoreVersion']) self.assertIs(False, config['sandbox']) self.assertIsNone(config['user']) self.assertIsNone(config['password']) self.assertEqual('', config['baseUrl']) self.assertIsNone(config['auth']) self.assertEqual('wss', config['socket_protocol'])
def test_customized_options(self): self.update_settings({ 'jujugui.charmstore_url': '1.2.3.4/api', 'jujugui.GTM_enabled': 'true', 'jujugui.sandbox': 'true', 'jujugui.auth': 'blob', 'jujugui.user': '******', 'jujugui.password': '******', }) jujugui.make_application(self.config) response = views.config(self.request) config = self.check_response(response) self.assertEqual('1.2.3.4/api', config['charmstoreURL']) self.assertTrue(config['GTM_enabled']) self.assertEqual('blob', config['auth']) # Note that here we are testing that the value is actually True or # False, not that it just evaluates to True/False(like in assertTrue). self.assertIs(True, config['sandbox']) # The hideLoginButton, user and password values reflect sandbox status. self.assertEqual('admin', config['user']) self.assertEqual('password', config['password'])
def test_standalone(self): jujugui.make_application(self.config) response = views.config(self.request) config = self.check_response(response) self.assertEqual('sandbox', config['jujuEnvUUID']) self.assertEqual('', config['baseUrl'])