summaryrefslogtreecommitdiff
path: root/ick2
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-04-06 21:38:43 +0300
committerLars Wirzenius <liw@liw.fi>2018-04-06 21:38:43 +0300
commit5aeef33219103eb5f39bfc0a79ed462f46a12420 (patch)
tree7fd5f2deb719a8c4ff68bf7eda7ee024006cf986 /ick2
parent63a8c15a46b73232fc2162807eced80e5e2c7296 (diff)
downloadick2-5aeef33219103eb5f39bfc0a79ed462f46a12420.tar.gz
Add: authentication URL to controller /version
Diffstat (limited to 'ick2')
-rw-r--r--ick2/controllerapi.py18
-rw-r--r--ick2/versionapi.py6
-rw-r--r--ick2/versionapi_tests.py3
3 files changed, 23 insertions, 4 deletions
diff --git a/ick2/controllerapi.py b/ick2/controllerapi.py
index f7c71f6..9785384 100644
--- a/ick2/controllerapi.py
+++ b/ick2/controllerapi.py
@@ -23,14 +23,24 @@ class ControllerAPI:
self._apis = {}
def set_artifact_store_url(self, url): # pragma: no cover
- self.find_missing_route('/version')
- api = self._apis.get('/version')
+ self._set_url('set_artifact_store_url', url)
+
+ def set_auth_url(self, url): # pragma: no cover
+ self._set_url('set_auth_url', url)
+
+ def _set_url(self, what, url): # pragma: no cover
+ api = self._get_version_api()
if api:
- api.set_artifact_store_url(url)
+ method = getattr(api, what)
+ method(url)
ick2.log.log(
- 'info', msg_text='Set artifact store url', url=url,
+ 'info', msg_text='Set url', what=what, url=url,
version=api.get_version())
+ def _get_version_api(self): # pragma: no cover
+ self.find_missing_route('/version')
+ return self._apis.get('/version')
+
def find_missing_route(self, missing_path): # pragma: no cover
apis = {
'/version': ick2.VersionAPI,
diff --git a/ick2/versionapi.py b/ick2/versionapi.py
index cc7e169..c688c1b 100644
--- a/ick2/versionapi.py
+++ b/ick2/versionapi.py
@@ -21,16 +21,21 @@ class VersionAPI(ick2.APIbase):
def __init__(self, state):
super().__init__(state)
self._artifact_store_url = None
+ self._auth_url = None
def set_artifact_store_url(self, url):
self._artifact_store_url = url
+ def set_auth_url(self, url):
+ self._auth_url = url
+
def get_routes(self, path): # pragma: no cover
return [
{
'method': 'GET',
'path': path,
'callback': self.GET(self.get_version),
+ 'needs-authorization': False,
}
]
@@ -38,6 +43,7 @@ class VersionAPI(ick2.APIbase):
return {
'version': ick2.__version__,
'artifact_store': self._artifact_store_url,
+ 'auth_url': self._auth_url,
}
def create(self, body, **kwargs): # pragma: no cover
diff --git a/ick2/versionapi_tests.py b/ick2/versionapi_tests.py
index b8d59d5..32f9808 100644
--- a/ick2/versionapi_tests.py
+++ b/ick2/versionapi_tests.py
@@ -23,13 +23,16 @@ class VersionAPITests(unittest.TestCase):
def test_returns_version_correcly(self):
bloburl = 'https://blobs.example.com'
+ idpurl = 'https://idp.example.com'
api = ick2.VersionAPI(None)
api.set_artifact_store_url(bloburl)
+ api.set_auth_url(idpurl)
response = api.get_version()
self.assertEqual(
response,
{
'version': ick2.__version__,
'artifact_store': bloburl,
+ 'auth_url': idpurl,
}
)