OLD | NEW |
1 # This file is part of the Juju GUI, which lets users view and manage Juju | 1 # This file is part of the Juju GUI, which lets users view and manage Juju |
2 # environments within a graphical interface (https://launchpad.net/juju-gui). | 2 # environments within a graphical interface (https://launchpad.net/juju-gui). |
3 # Copyright (C) 2013 Canonical Ltd. | 3 # Copyright (C) 2013 Canonical Ltd. |
4 # | 4 # |
5 # This program is free software: you can redistribute it and/or modify it under | 5 # This program is free software: you can redistribute it and/or modify it under |
6 # the terms of the GNU Affero General Public License version 3, as published by | 6 # the terms of the GNU Affero General Public License version 3, as published by |
7 # the Free Software Foundation. | 7 # the Free Software Foundation. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, but WITHOUT | 9 # This program is distributed in the hope that it will be useful, but WITHOUT |
10 # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | 10 # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 deployer = self.assert_in_spec(spec, 'deployer') | 103 deployer = self.assert_in_spec(spec, 'deployer') |
104 self.assertIsInstance(deployer, base.Deployer) | 104 self.assertIsInstance(deployer, base.Deployer) |
105 | 105 |
106 def test_tokens(self): | 106 def test_tokens(self): |
107 # The tokens instance is correctly passed to the WebSocket handler. | 107 # The tokens instance is correctly passed to the WebSocket handler. |
108 app = self.get_app() | 108 app = self.get_app() |
109 spec = self.get_url_spec(app, r'^/ws$') | 109 spec = self.get_url_spec(app, r'^/ws$') |
110 tokens = self.assert_in_spec(spec, 'tokens') | 110 tokens = self.assert_in_spec(spec, 'tokens') |
111 self.assertIsInstance(tokens, auth.AuthenticationTokenHandler) | 111 self.assertIsInstance(tokens, auth.AuthenticationTokenHandler) |
112 | 112 |
113 def test_sandbox(self): | 113 def test_websocket_excluded_in_sandbox_mode(self): |
114 # The WebSocket handler is excluded if sandbox mode is enabled. | 114 # The WebSocket handler is excluded if sandbox mode is enabled. |
115 app = self.get_app(sandbox=True) | 115 app = self.get_app(sandbox=True) |
116 spec = self.get_url_spec(app, r'^/ws$') | 116 spec = self.get_url_spec(app, r'^/ws$') |
117 self.assertIsNone(spec) | 117 self.assertIsNone(spec) |
118 | 118 |
| 119 def test_proxy_excluded_in_sandbox_mode(self): |
| 120 # The juju-core HTTPS proxy is excluded if sandbox mode is enabled. |
| 121 app = self.get_app(sandbox=True) |
| 122 spec = self.get_url_spec(app, r'^/juju-core/(.*)$') |
| 123 self.assertIsNone(spec) |
| 124 |
119 def test_static_files(self): | 125 def test_static_files(self): |
120 # The Juju GUI static files are correctly served. | 126 # The Juju GUI static files are correctly served. |
121 app = self.get_app() | 127 app = self.get_app() |
122 spec = self.get_url_spec(app, r'^/juju-ui/(.*)$') | 128 spec = self.get_url_spec(app, r'^/juju-ui/(.*)$') |
123 self.assert_in_spec(spec, 'path', value='/my/guiroot/juju-ui') | 129 self.assert_in_spec(spec, 'path', value='/my/guiroot/juju-ui') |
124 | 130 |
125 def test_core_http_proxy(self): | 131 def test_core_http_proxy(self): |
126 # The juju-core HTTPS proxy handler is properly set up. | 132 # The juju-core HTTPS proxy handler is properly set up. |
127 app = self.get_app() | 133 app = self.get_app() |
128 spec = self.get_url_spec(app, r'^/juju-core/(.*)$') | 134 spec = self.get_url_spec(app, r'^/juju-core/(.*)$') |
(...skipping 23 matching lines...) Expand all Loading... |
152 options = mock.Mock(**kwargs) | 158 options = mock.Mock(**kwargs) |
153 with mock.patch('guiserver.apps.options', options): | 159 with mock.patch('guiserver.apps.options', options): |
154 return apps.redirector() | 160 return apps.redirector() |
155 | 161 |
156 def test_redirect_all(self): | 162 def test_redirect_all(self): |
157 # Ensure all paths are handled by HttpsRedirectHandler. | 163 # Ensure all paths are handled by HttpsRedirectHandler. |
158 app = self.get_app() | 164 app = self.get_app() |
159 spec = self.get_url_spec(app, r'.*$') | 165 spec = self.get_url_spec(app, r'.*$') |
160 self.assertIsNotNone(spec) | 166 self.assertIsNotNone(spec) |
161 self.assertEqual(spec.handler_class, handlers.HttpsRedirectHandler) | 167 self.assertEqual(spec.handler_class, handlers.HttpsRedirectHandler) |
OLD | NEW |