Browse Source

Support for basic authentication

master
Luciano Silva 8 years ago
parent
commit
502dcfbcb6
  1. 6
      README.md
  2. 10
      pipeline.yml
  3. 19
      test/test-check.sh
  4. 18
      test/test-in.sh

6
README.md

@ -6,10 +6,14 @@ This is a useful resource for pipeline development time, while a required artifa
## Source Configuration
* `url`: *Required.* The url location of the file. It has to be publicly available, no user authentication supported in v0.0.1.
* `url`: *Required.* The url location of the file.
* `filename`: *Optional.* The name of the file for the downloaded artifact to be save as. If not provided, the file will be saved using the full url string as its name.
* `username`: *Optional.* Username for accessing an authenticated repository.
* `password`: *Optional.* Password for accessing an authenticated repository.
* `skip_ssl_verification`: *Optional.* Skips ssl verification if defined as `true`. Default is `false`.
### Example

10
pipeline.yml

@ -16,20 +16,12 @@ resources:
source:
url: https://raw.githubusercontent.com/pivotalservices/concourse-curl-resource/master/test/data/pivotal-1.0.0.txt
filename: pivotal-1.0.0.txt
- name: my-file-requiring-auth
type: file-url
source:
url: https://auth-demo.aerobatic.io/protected-standard
filename: auth-request-response.txt
username: aerobatic
password: aerobatic
jobs:
- name: run-and-get-files
plan:
- get: my-file-with-last-modified-info
- get: my-file-without-last-modified-info
- get: my-file-requiring-auth
- task: run-and-get-file
config:
platform: linux
@ -41,11 +33,9 @@ jobs:
inputs:
- name: my-file-with-last-modified-info
- name: my-file-without-last-modified-info
- name: my-file-requiring-auth
run:
path: sh
args:
- -exc
- |
find .
cat ./my-file-requiring-auth/auth-request-response.txt | grep expecting

19
test/test-check.sh

@ -10,6 +10,9 @@ export FILE_URL_WITH_LAST_MODIFIED_INFO=https://s3-us-west-1.amazonaws.com/lsilv
# set FILE_URL_WITHOUT_LAST_MODIFIED_INFO with a URL of a file whose HTTP HEADER info DOES NOT provide a Last-Modified entry
# to check it do "curl -I -R <url>"
export FILE_URL_WITHOUT_LAST_MODIFIED_INFO=https://raw.githubusercontent.com/pivotalservices/concourse-curl-resource/master/test/data/pivotal-1.0.0.txt
# set FILE_URL_WITHOUT_LAST_MODIFIED_INFO with a URL of a file whose HTTP HEADER info DOES NOT provide a Last-Modified entry
# to check it do "curl -I -R <url>"
export FILE_URL_BASIC_AUTH=https://auth-demo.aerobatic.io/protected-standard
it_can_get_file_with_last_modified_info() {
@ -33,5 +36,21 @@ it_can_get_file_without_last_modified_info() {
}
it_can_get_file_with_basic_auth() {
echo $resource_dir
jq -n "{
source: {
url: $(echo $FILE_URL_BASIC_AUTH | jq -R .),
username: $(echo 'aerobatic' | jq -R .),
password: $(echo 'aerobatic' | jq -R .),
filename: $(echo 'basicauth.txt' | jq -R .)
}
}" | $resource_dir/check "$FILE_URL_BASIC_AUTH" | tee /dev/stderr
}
run it_can_get_file_with_last_modified_info
run it_can_get_file_without_last_modified_info
run it_can_get_file_with_basic_auth

18
test/test-in.sh

@ -13,6 +13,8 @@ export FILE_NAME_1=pcf-sandbox.json
# to check it do "curl -I -R <url>"
export FILE_URL_WITHOUT_LAST_MODIFIED_INFO=https://raw.githubusercontent.com/pivotalservices/concourse-curl-resource/master/test/data/pivotal-1.0.0.txt
export FILE_NAME_2=ivotal-1.0.0.txt
# set FILE_URL_BASIC_AUTH with a URL of a file that requires basic authentication
export FILE_URL_BASIC_AUTH=https://auth-demo.aerobatic.io/protected-standard
it_can_get_file_with_date_info() {
jq -n "{
@ -24,4 +26,20 @@ it_can_get_file_with_date_info() {
}
it_can_get_file_with_basic_auth() {
echo "Source=[$src]"
jq -n "{
source: {
url: $(echo $FILE_URL_BASIC_AUTH | jq -R .),
username: $(echo 'aerobatic' | jq -R .),
password: $(echo 'aerobatic' | jq -R .),
filename: $(echo 'basicauth.txt' | jq -R .)
}
}" | $resource_dir/in "$src" | tee /dev/stderr
}
run it_can_get_file_with_date_info
run it_can_get_file_with_basic_auth
Loading…
Cancel
Save