- ID
- 0d617f40-d937-4f99-9791-91d50569889e
- ROAM_ALIASES
- "15Five LocalStack"
Using LocalStack to Test SFTP in 15Five
Getting started
- ID
- 3bcc7f2d-87a4-401d-9ca7-d6ceb945911a
1. Add the Workday demo company using run_local_scripts
#+begin_src python
#+end_src
1. Install localstack
#+begin_src shell
pip install localstack
#+end_src
2. Start localstack (making sure docker is working)
#+begin_src
localstack start
#+end_src
3. Install https://github.com/localstack/awscli-local
4. Create a bucket
#+begin_src shell
awslocal s3api create-bucket --bucket local --region us-east-1
#+end_src
5. Copy the following into import.csv and upload it to S3
#+begin_src csv
email,first_name,last_name,title,due_day,reviewer_email,time_zone,active_group_names,location,employee_id,job_description,strengths,saml_user_id,start_date,is_group_admin_for
workday-test1@15five.com.com,Workday,Test1,,Friday,,America/New_York,,,,,,,,
workday-test2@15five.com.com,Workday,Test2,,Friday,,America/New_York,,,,,,,,
#+end_src
#+begin_src shell
awslocal s3api put-object --bucket local --key import.csv --body import.csv
#+end_src
5. Upload test file
6. Add AWS env vars to local env:
+ AWS_ACCESS_KEY_ID=doesnt_matter
+ AWS_SECRET_ACCESS_KEY=doesnt_matter
+ FF_AWS_STORAGE_BUCKET_NAME_PUBLIC=local
+ FF_AWS_STORAGE_BUCKET_NAME_PRIVATE=local
7. Test it for fun and profit!
#+begin_src shell
curl -k -i -H Content-Type\:\ application/json -XPOST https\://15five.localhost/sftp/receiver/ -d \{\ \"Records\"\:\ \[\ \{\ \"s3\"\:\ \{\ \"object\"\:\ \{\ \"key\"\:\ \"import.csv\"\ \}\ \}\ \}\ \]\ \}
#+end_src
#+RESULTS:
RestClient examples
#+begin_src restclient :outputs none
POST https://15five.localhost/mobile/login?debug_api=1&check_signature=false
Content-Type: application/x-www-form-urlencoded
email=workday@15five.com&password=15five
#
#+end_src
#+RESULTS:
#+BEGIN_SRC js
{
"result": "ok",
"sessionid": "ealuch9m6rt4zslb6ht1e1gqoa19v52e",
"signature_secret": "87b1e4fe46bcd4fd3b1f3f7481be49ba",
"first_name": "Workday",
"last_name": "Admin",
"email": "workday@15five.com",
"display_name": "Workday Admin",
"title": "Manager",
"user_id": 9,
"user_gid": "ae61e6a8153640a693f6d73dbd0272ac",
"is_reviewer": false,
"is_reporter": false,
"company_info": {
"enforce_mobile_pin": false,
"features": {
"high_fives_when_reviewing_module_enabled": false
},
"company_id": 130003
},
"avatar_url": "data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%20120%20120%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%22100%22%20height%3D%22100%22%3E%3Crect%20width%3D%22120%22%20height%3D%22120%22%20fill%3D%22%23FEF7EA%22/%3E%3Ctext%20x%3D%2250%25%22%20y%3D%2250%25%22%20font-size%3D%2242%22%20letter-spacing%3D%222%22%20font-family%3D%22Arial%2C%20sans-serif%22%20dy%3D%2214%22%20text-anchor%3D%22middle%22%20fill%3D%22%23AB7A1D%22%3EWA%3C/text%3E%3C/svg%3E",
"unread_notification_count": 0
}
// POST https://15five.localhost/mobile/login?debug_api=1&check_signature=false
// HTTP/1.1 200 OK
// Server: nginx/1.18.0 (Ubuntu)
// Date: Thu, 04 Feb 2021 08:30:01 GMT
// Content-Type: application/json
// Content-Length: 1062
// Connection: keep-alive
// Content-Language: en-us
// X-Frame-Options: SAMEORIGIN
// Vary: Cookie, Authorization
// Set-Cookie: django_language=en-us; Path=/
// Set-Cookie: ff_csrf_token=zKJCdAWZ97DtkSbbWuqUCdJjKRlb7LAoV2WqkDGrgwiJqXPWrU0tY9fwtqZiP1BD; Domain=.15five.localhost; expires=Thu, 03 Feb 2022 08:30:01 GMT; Max-Age=31449600; Path=/; SameSite=Lax
// Set-Cookie: sessionid=ealuch9m6rt4zslb6ht1e1gqoa19v52e; Domain=15five.localhost; expires=Thu, 04 Mar 2021 16:30:01 GMT; HttpOnly; Max-Age=2448000; Path=/
// Request duration: 13.470223s
#+END_SRC
#+begin_src restclient :output result
POST https://15five.localhost/sftp/receiver/
Content-Type: application/json
{ "Records": [ { "s3": { "object": { "key": "import.csv" } } } ] }
#+end_src
#+RESULTS:
#+BEGIN_SRC js
{
"key": "import.csv"
}
// POST https://15five.localhost/sftp/receiver/
// HTTP/1.1 200 OK
// Server: nginx/1.18.0 (Ubuntu)
// Date: Thu, 04 Feb 2021 16:50:18 GMT
// Content-Type: application/json
// Content-Length: 21
// Connection: keep-alive
// Content-Language: en-us
// X-Frame-Options: SAMEORIGIN
// Vary: Authorization, Cookie
// Set-Cookie: django_language=en-us; Path=/
// Request duration: 0.658052s
#+END_SRC