pin-http 583 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash -x
  2. function on_exit() {
  3. [ "$PID" ] && kill $PID && ! wait $PID
  4. [ -d "$TMP" ] && rm -rf $TMP
  5. }
  6. trap 'on_exit' EXIT
  7. trap 'exit' ERR
  8. export TMP=`mktemp -d`
  9. PORT=`shuf -i 1024-65535 -n 1`
  10. $SD_ACTIVATE -l 127.0.0.1:$PORT -a ${0%/*}/pin-httpd "$TMP" &
  11. export PID=$!
  12. sleep 0.25
  13. cfg="{\"url\":\"http://localhost:${PORT}/foo\"}"
  14. ! clevis encrypt http "$cfg" <<< "hi"
  15. cfg=`jose fmt -j "$cfg" -Oj true -s http -U -Oo-`
  16. e=`echo -n hi | clevis encrypt http "$cfg"`
  17. d=`echo -n "$e" | clevis decrypt`
  18. test "$d" == "hi"
  19. kill $PID
  20. ! wait $PID
  21. ! echo "$e" | clevis decrypt