And also update the UI code to get the Wok configuration.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
docs/API/config.md | 1 +
src/wok/model/config.py | 11 ++++-------
tests/test_api.py | 2 +-
ui/js/src/wok.api.js | 17 +++++++++++++++--
ui/js/src/wok.main.js | 9 ++++++++-
5 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/docs/API/config.md b/docs/API/config.md
index c18b605..bdf5c16 100644
--- a/docs/API/config.md
+++ b/docs/API/config.md
@@ -11,6 +11,7 @@ Contains information about the application environment and
configuration.
* **GET**: Retrieve configuration information
* ssl_port: SSL port to list on
* websockets_port: Port for websocket proxy to listen on
+ * auth: Authentication method used to log in to Wok
* version: Wok version
* **POST**: *See Task Actions*
diff --git a/src/wok/model/config.py b/src/wok/model/config.py
index d39222a..3b5619f 100644
--- a/src/wok/model/config.py
+++ b/src/wok/model/config.py
@@ -17,8 +17,7 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-from wok.config import config as kconfig
-from wok.config import get_version
+from wok.config import config, get_version
class ConfigModel(object):
@@ -26,9 +25,7 @@ class ConfigModel(object):
pass
def lookup(self, name):
- ssl_port = kconfig.get('server', 'ssl_port')
- websockets_port = kconfig.get('server', 'websockets_port')
-
- return {'ssl_port': ssl_port,
- 'websockets_port': websockets_port,
+ return {'ssl_port': config.get('server', 'ssl_port'),
+ 'websockets_port': config.get('server',
'websockets_port'),
+ 'auth': config.get('authentication', 'method'),
'version': get_version()}
diff --git a/tests/test_api.py b/tests/test_api.py
index 39888c8..3150c1e 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -53,5 +53,5 @@ class APITests(unittest.TestCase):
def test_config(self):
resp = self.request('/config').read()
conf = json.loads(resp)
- keys = ["ssl_port", "websockets_port", "version"]
+ keys = ["auth", "ssl_port", "websockets_port",
"version"]
self.assertEquals(sorted(keys), sorted(conf.keys()))
diff --git a/ui/js/src/wok.api.js b/ui/js/src/wok.api.js
index bc73cdd..c97dba8 100644
--- a/ui/js/src/wok.api.js
+++ b/ui/js/src/wok.api.js
@@ -1,7 +1,7 @@
/*
* Project Wok
*
- * Copyright IBM, Corp. 2013-2015
+ * Copyright IBM, Corp. 2013-2016
*
* Code derived from Project Kimchi
*
@@ -89,5 +89,18 @@ var wok = {
success : suc,
error : err
});
- },
+ },
+
+ getConfig: function(suc, err, sync) {
+ wok.requestJSON({
+ url : 'config',
+ type : 'GET',
+ contentType : 'application/json',
+ dataType : 'json',
+ resend: true,
+ async : !sync,
+ success : suc,
+ error : err
+ });
+ },
};
diff --git a/ui/js/src/wok.main.js b/ui/js/src/wok.main.js
index 2a41bc5..736001f 100644
--- a/ui/js/src/wok.main.js
+++ b/ui/js/src/wok.main.js
@@ -1,7 +1,7 @@
/*
* Project Wok
*
- * Copyright IBM, Corp. 2013-2015
+ * Copyright IBM, Corp. 2013-2016
*
* Code derived from Project Kimchi
*
@@ -20,6 +20,13 @@
wok.tabMode = {};
+wok.config = undefined;
+wok.getConfig(function(result) {
+ wok.config = result;
+}, function() {
+ wok.config = {};
+});
+
wok.main = function() {
wok.isLoggingOut = false;
wok.popable();
--
2.5.0