diff options
author | Ernst Widerberg <ernst@sunet.se> | 2022-01-13 17:38:04 +0100 |
---|---|---|
committer | Ernst Widerberg <ernst@sunet.se> | 2022-01-13 18:08:24 +0100 |
commit | 386f3bd73383368facd9807f737e26478b0302f3 (patch) | |
tree | d9e49a16340a534d691704d2c7cfedaee9644a1c | |
parent | a3b5cde94981b9a98d367004b4c513c81e5870e4 (diff) |
Add convenience script do-as
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | do-as | 17 |
2 files changed, 19 insertions, 0 deletions
@@ -81,6 +81,8 @@ We can also limit the number of results and skip N results forward with the para curl -s -H "Authorization: Bearer $JWT" 'http://localhost:80/sc/v0/get?limit=5&skip=2' | json_pp -json_opt utf8,pretty +There is also a convenience script `do-as` which simplifies performing actions as a particular user. + ## Development There are two docker-compose files used for development: @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# Usage: +# ./do-as <username> <last part of URL> [<any additional curl args>] +# Example: +# ./do-as user1 get +# ./do-as user3 delete/1642091653617 -X DELETE + +set -e + +USER=$1 +CMD=$2 +shift +shift + +JWT=$(curl http://localhost:8000/api/v1.0/auth -X POST -p -u "$USER:pwd" | jq -r .access_token) +curl -s -H "Authorization: Bearer $JWT" http://localhost:80/sc/v0/$CMD "$@" |