You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.7 KiB

8 years ago
8 years ago
  1. #!/bin/bash
  2. set -e
  3. source $(dirname $0)/helpers.sh
  4. export src=$(mktemp -d /tmp/in-src.XXXXXX)
  5. # set FILE_URL_WITH_LAST_MODIFIED_INFO with a URL of a file whose HTTP HEADER info provides a Last-Modified entry
  6. # to check it do "curl -I -R <url>"
  7. export FILE_URL_WITH_LAST_MODIFIED_INFO=https://s3-us-west-1.amazonaws.com/lsilva-bpws/PCF_usage/pcf-sandbox-usage-from-2016-09-01-to-2016-09-30_1475771124.json
  8. export FILE_NAME_1=pcf-sandbox.json
  9. # set FILE_URL_WITHOUT_LAST_MODIFIED_INFO with a URL of a file whose HTTP HEADER info DOES NOT provide a Last-Modified entry
  10. # to check it do "curl -I -R <url>"
  11. export FILE_URL_WITHOUT_LAST_MODIFIED_INFO=https://raw.githubusercontent.com/pivotalservices/concourse-curl-resource/master/test/data/pivotal-1.0.0.txt
  12. export FILE_NAME_2=ivotal-1.0.0.txt
  13. # set FILE_URL_BASIC_AUTH with a URL of a file that requires basic authentication
  14. export FILE_URL_BASIC_AUTH=https://auth-demo.aerobatic.io/protected-standard
  15. it_can_get_file_with_date_info() {
  16. jq -n "{
  17. source: {
  18. url: $(echo $FILE_URL_WITH_LAST_MODIFIED_INFO | jq -R .),
  19. filename: $(echo $FILE_NAME_1 | jq -R .)
  20. }
  21. }" | $resource_dir/in "$src" | tee /dev/stderr
  22. }
  23. it_can_get_file_with_basic_auth() {
  24. echo "Source=[$src]"
  25. jq -n "{
  26. source: {
  27. url: $(echo $FILE_URL_BASIC_AUTH | jq -R .),
  28. username: $(echo 'aerobatic' | jq -R .),
  29. password: $(echo 'aerobatic' | jq -R .),
  30. filename: $(echo 'basicauth.txt' | jq -R .)
  31. }
  32. }" | $resource_dir/in "$src" | tee /dev/stderr
  33. # cat "$src"/basicauth.txt | grep expect
  34. # should return "...Hi, we've been expecting you!..."
  35. }
  36. run it_can_get_file_with_date_info
  37. run it_can_get_file_with_basic_auth