summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-11-05 12:57:22 +0100
committerLars Wirzenius <liw@liw.fi>2017-11-05 12:57:22 +0100
commit89cc8f3239f824755d9d19b3b5877ff62900b787 (patch)
tree846ebdd4ead54782034c5576c06924c58e953706
parent9eed0d65ba6ff39aa41a0bfbc3926605416b2dfe (diff)
downloadick2-89cc8f3239f824755d9d19b3b5877ff62900b787.tar.gz
Refactor: change token generation to name the user
-rw-r--r--yarns/100-projects.yarn2
-rw-r--r--yarns/200-version.yarn2
-rw-r--r--yarns/300-workers.yarn2
-rw-r--r--yarns/400-build.yarn10
-rw-r--r--yarns/900-local.yarn15
-rw-r--r--yarns/900-remote.yarn8
6 files changed, 12 insertions, 27 deletions
diff --git a/yarns/100-projects.yarn b/yarns/100-projects.yarn
index 1291f5e..a4793b3 100644
--- a/yarns/100-projects.yarn
+++ b/yarns/100-projects.yarn
@@ -62,7 +62,7 @@ building them. We start by starting an instance of the controller.
SCENARIO managing projects
GIVEN an RSA key pair for token signing
- AND an access token for scopes
+ AND an access token for user with scopes
... uapi_projects_get
... uapi_projects_post
... uapi_projects_id_get
diff --git a/yarns/200-version.yarn b/yarns/200-version.yarn
index 183ade9..fe92b34 100644
--- a/yarns/200-version.yarn
+++ b/yarns/200-version.yarn
@@ -23,7 +23,7 @@ The Ick controller reports is version upon request.
SCENARIO checking controller version
GIVEN an RSA key pair for token signing
- AND an access token for scopes
+ AND an access token for user with scopes
... uapi_version_get
AND controller config uses statedir at the state directory
AND a running ick controller
diff --git a/yarns/300-workers.yarn b/yarns/300-workers.yarn
index 6386ae9..16bd108 100644
--- a/yarns/300-workers.yarn
+++ b/yarns/300-workers.yarn
@@ -53,7 +53,7 @@ controller API. It doesn't actually talk to the worker itself.
SCENARIO managing workers
GIVEN an RSA key pair for token signing
- AND an access token for scopes
+ AND an access token for user with scopes
... uapi_workers_get
... uapi_workers_post
... uapi_workers_id_get
diff --git a/yarns/400-build.yarn b/yarns/400-build.yarn
index 0e030fd..31d0377 100644
--- a/yarns/400-build.yarn
+++ b/yarns/400-build.yarn
@@ -27,15 +27,15 @@ Set up the controller.
GIVEN an RSA key pair for token signing
AND controller config uses statedir at the state directory
- AND a running ick controller
-
-Add up a project.
-
- GIVEN an access token for user with scopes
+ AND an access token for user with scopes
... uapi_projects_post
... uapi_projects_id_pipeline_id_put
... uapi_projects_id_pipeline_id_get
... uapi_projects_id_builds_get
+ AND a running ick controller
+
+Add up a project.
+
WHEN user makes request POST /projects
... {
... "project": "rome",
diff --git a/yarns/900-local.yarn b/yarns/900-local.yarn
index 43f710c..409a8e6 100644
--- a/yarns/900-local.yarn
+++ b/yarns/900-local.yarn
@@ -28,18 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
]
cliapp.runcmd(argv, stdout=None, stderr=None)
- IMPLEMENTS GIVEN an access token for scopes (.+)
- scopes = get_next_match()
- key = open('token.key').read()
- argv = [
- os.path.join(srcdir, 'create-token'),
- scopes,
- ]
- token = cliapp.runcmd(argv, feed_stdin=key)
- write('token.jwt', token)
- vars['issuer'] = 'localhost'
- vars['audience'] = 'localhost'
-
IMPLEMENTS GIVEN an access token for (\S+) with scopes (.+)
user = get_next_match()
scopes = get_next_match()
@@ -49,8 +37,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
scopes,
]
token = cliapp.runcmd(argv, feed_stdin=key)
- filename = '{}.jwt'.format(user)
- write(filename, token)
+ store_token(user, token)
vars['issuer'] = 'localhost'
vars['audience'] = 'localhost'
diff --git a/yarns/900-remote.yarn b/yarns/900-remote.yarn
index 2d013a6..2875d27 100644
--- a/yarns/900-remote.yarn
+++ b/yarns/900-remote.yarn
@@ -25,7 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
vars['private_key_file'] = os.environ['ICK_PRIVATE_KEY']
assertTrue(os.path.exists(vars['private_key_file']))
- IMPLEMENTS GIVEN an access token for scopes (.+)
+ IMPLEMENTS GIVEN an access token for (\S+) with scopes (.+)
+ user = get_next_match()
scopes = get_next_match()
key = open(vars['private_key_file']).read()
argv = [
@@ -33,13 +34,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
scopes,
]
token = cliapp.runcmd(argv, feed_stdin=key)
- write('token.jwt', token)
+ store_token(user, token)
vars['issuer'] = 'localhost'
vars['audience'] = 'localhost'
- IMPLEMENTS GIVEN an access token for (\S+) with scopes (.+)
- assert 0
-
## Controller configuration
IMPLEMENTS GIVEN controller config uses (\S+) at the state directory