From 386f3bd73383368facd9807f737e26478b0302f3 Mon Sep 17 00:00:00 2001 From: Ernst Widerberg Date: Thu, 13 Jan 2022 17:38:04 +0100 Subject: Add convenience script do-as --- README.md | 2 ++ do-as | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100755 do-as diff --git a/README.md b/README.md index 1e4ecbb..907d566 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/do-as b/do-as new file mode 100755 index 0000000..8d5cdaa --- /dev/null +++ b/do-as @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# Usage: +# ./do-as [] +# 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 "$@" -- cgit v1.1