From 80b0c591f321bbfc5073f0de833ddc03d7819a20 Mon Sep 17 00:00:00 2001 From: Rachel Tublitz Date: Thu, 5 Dec 2019 17:04:46 -0500 Subject: [PATCH] chore: adjust sample script so it works and adding docs to link to it --- .gitignore | 1 + Makefile | 2 +- README.md | 2 +- config/local.example.toml | 2 +- tools/examples/README.md | 3 +++ tools/{poster/post.bash => examples/put.bash} | 4 +++- tools/hawk/README.md | 7 ++++++- tools/poster/README.md | 4 ---- 8 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 tools/examples/README.md rename tools/{poster/post.bash => examples/put.bash} (74%) mode change 100644 => 100755 delete mode 100644 tools/poster/README.md diff --git a/.gitignore b/.gitignore index dbc044dc..8668c15e 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ service-account.json config/local.toml +venv diff --git a/Makefile b/Makefile index 4ddf03cb..9bd8bac8 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,2 @@ -run-local: +run_local: RUST_LOG=debug RUST_BACKTRACE=1 cargo run -- --config config/local.toml diff --git a/README.md b/README.md index 53e1606b..ba61a0fd 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Depending on your OS, you may also need to install `libgrpcdev`, and `protobuf-c 1. Follow the instructions below to use either MySQL or Spanner as your DB. 2. Now `cp config/local.example.toml config/local.toml`. Open `config/local.toml` and make sure you have the desired settings configured. For a complete list of available configuration options, check out [docs/config.md](docs/config.md). -3. `make run-local` starts the server in debug mode, using your new `local.toml` file for config options. Or, simply `cargo run` with your own config options provided as env vars. +3. `make run_local` starts the server in debug mode, using your new `local.toml` file for config options. Or, simply `cargo run` with your own config options provided as env vars. 4. Visit `http://localhost:8000/__heartbeat__` to make sure the server is running. ### MySQL diff --git a/config/local.example.toml b/config/local.example.toml index 24338b82..cdc48320 100644 --- a/config/local.example.toml +++ b/config/local.example.toml @@ -1,4 +1,4 @@ database_url = "mysql://sample_user:sample_password@localhost/syncstorage_rs" -master_secret = "some_secret_here" +master_secret = "INSERT_SECRET_KEY_HERE" # removing this line will default to moz_json formatted logs (which is preferred for production envs) human_logs = 1 diff --git a/tools/examples/README.md b/tools/examples/README.md new file mode 100644 index 00000000..6ed7a906 --- /dev/null +++ b/tools/examples/README.md @@ -0,0 +1,3 @@ +# Example scripts for working with syncstorage-rs + +* `put.bash` - First `chmod +x put.bash` then `./put.bash` to simulate a PUT. diff --git a/tools/poster/post.bash b/tools/examples/put.bash old mode 100644 new mode 100755 similarity index 74% rename from tools/poster/post.bash rename to tools/examples/put.bash index fa4a56f4..88369b6e --- a/tools/poster/post.bash +++ b/tools/examples/put.bash @@ -1,7 +1,9 @@ #!/bin/bash NODE="http://localhost:8000" URI="/1.5/1/storage/col2/DEADBEEF" -AUTH=`../hawk/venv/bin/python ../hawk/make_hawk_token.py --node $NODE --uri $URI --as_header` +METHOD="PUT" +SYNC_MASTER_SECRET="INSERT_SECRET_KEY_HERE" +AUTH=`../hawk/venv/bin/python ../hawk/make_hawk_token.py --node $NODE --uri $URI --method $METHOD --secret=$SYNC_MASTER_SECRET --as_header` curl -vv -X PUT "$NODE$URI" \ -H "Authorization: $AUTH" \ -H 'Content-Type: application/json' \ diff --git a/tools/hawk/README.md b/tools/hawk/README.md index 7b0bf853..56d4c081 100644 --- a/tools/hawk/README.md +++ b/tools/hawk/README.md @@ -19,6 +19,11 @@ virutal environment. 3) To create a Token Header: -`venv/bin/python make_hawk_token.py` +You'll need to pass along your `SYNC_MASTER_SECRET` and the uri you'll be testing in order to generate a valid Hawk Id: + +`venv/bin/python make_hawk_token.py --uri /1.5/1/storage/meta/global --secret=$SYNC_MASTER_SECRET --as_header` + +** For testing against uri's using methods other than GET, you'll need to pass along the `--method` flag to generate your token. Ie, `venv/bin/python make_hawk_token.py --method PUT --uri /1.5/1/storage/meta/global --secret=$SYNC_MASTER_SECRET --as_header`. See [examples/put.bash](https://github.com/mozilla-services/syncstorage-rs/blob/master/tools/examples/put.bash) for an example of this. + Use `-h` for help. diff --git a/tools/poster/README.md b/tools/poster/README.md deleted file mode 100644 index 716042da..00000000 --- a/tools/poster/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Post a fake BSO to the local server - -`post.bash` is a crappy bash script that attempts to post a fake BSO to a local instance of syncserver-rs. It's useful for line testing operations. -