Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation url for python uploader library #25

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Pacifica CLI Uploader

[![PyPi](https://img.shields.io/pypi/v/pacifica-cli.svg)]
[![Read the Docs](https://readthedocs.org/projects/pacifica-cli/badge/?version=latest)]
[![Build Status](https://travis-ci.org/pacifica/pacifica-cli.svg?branch=master)](https://travis-ci.org/pacifica/pacifica-cli)
[![Build Status](https://ci.appveyor.com/api/projects/status/0ddinx1bdfroptf7?svg=true)](https://ci.appveyor.com/project/dmlb2000/pacifica-cli)
[![Code Climate](https://codeclimate.com/github/pacifica/pacifica-cli/badges/gpa.svg)](https://codeclimate.com/github/pacifica/pacifica-cli)
Expand Down
10 changes: 6 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ before_test:
Start-Process C:\pacifica\Scripts\pacifica-archiveinterface.exe;
$env:UNIQUEID_CONFIG = "$PWD/travis/uniqueid/config.cfg";
$env:UNIQUEID_CPCONFIG = "$PWD/travis/uniqueid/server.conf";
pacifica-uniqueid-cmd dbsync;
Start-Process C:\pacifica\Scripts\pacifica-uniqueid.exe;
$env:CARTD_CONFIG = "$PWD/travis/cartd/config.cfg";
$env:CARTD_CPCONFIG = "$PWD/travis/cartd/server.conf";
Expand All @@ -46,6 +47,7 @@ before_test:
Start-Process C:\pacifica\Scripts\celery.exe -ArgumentList "-A pacifica.cartd.tasks worker --loglevel=info -P solo -c 1" -RedirectStandardOutput ccelery-output.log -RedirectStandardError ccelery-error.log;
$env:INGEST_CONFIG = "$PWD/travis/ingest/config.cfg";
$env:INGEST_CPCONFIG = "$PWD/travis/ingest/server.conf";
pacifica-ingest-cmd dbsync;
Start-Process C:\pacifica\Scripts\pacifica-ingest.exe;
Start-Process C:\pacifica\Scripts\celery.exe -ArgumentList "-A pacifica.ingest.tasks worker --loglevel=info -P solo -c 1" -RedirectStandardOutput celery-output.log -RedirectStandardError celery-error.log;
$MD_VERSION = `pip show pacifica-metadata | grep Version: | awk '{ print $2 }';
Expand Down Expand Up @@ -100,10 +102,10 @@ test_script:
coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli upload --help;
coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli download --help;
coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli configure --help;
printf '\n\n\n\n\n\n' | coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli configure;
printf '\n\n\n\n\nTrue\nclientssl\n~/.pacifica-cli/my.key\n~/.pacifica-cli/my.cert\n' | coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli configure;
printf '\n\n\n\n\nFalse\nbasic\nusername\npassword\n' | coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli configure;
printf 'http://localhost:8066/upload\nhttp://localhost:8066/get_state\nhttp://localhost:8181/uploader\nhttp://localhost:8081\nhttp://localhost:8181/status/transactions/by_id\nTrue\nNone\n' | coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli configure;
printf '\n\n\n\n\n\n\n' | coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli configure;
printf '\n\n\n\n\n\nTrue\nclientssl\n~/.pacifica-cli/my.key\n~/.pacifica-cli/my.cert\n' | coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli configure;
printf '\n\n\n\n\n\nFalse\nbasic\nusername\npassword\n' | coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli configure;
printf 'http://localhost:8066/upload\nhttp://localhost:8066/get_state\nhttp://localhost:8181/uploader\nhttp://localhost:8181/ingest\nhttp://localhost:8081\nhttp://localhost:8181/status/transactions/by_id\nTrue\nNone\n' | coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli configure;
coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli download --transaction-id 67;
coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli download --cloudevent ce_stub.json;
coverage run --include='*/site-packages/pacifica/cli/*' -a -m pacifica.cli upload --dry-run --instrument 54 --logon dmlb2001;
Expand Down
5 changes: 5 additions & 0 deletions config/example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
;
; upload_policy_url =

; Policy service external endpoint url for validation.
; (https://policy.example.com/ingest)
;
; upload_validation_url =

; Cart service external endpoint url for the download.
; (https://cartd.example.com/
;
Expand Down
5 changes: 5 additions & 0 deletions docs/_static/example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
;
; upload_policy_url =

; Policy service external endpoint url for validation.
; (https://policy.example.com/ingest)
;
; upload_validation_url =

; Cart service external endpoint url for the download.
; (https://cartd.example.com/
;
Expand Down
1 change: 1 addition & 0 deletions docs/exampleusage.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ What are the endpoint URLs for the following...
Upload URL (https://ingest.example.com/upload):
Upload Status URL (https://ingest.example.com/get_state):
Upload Policy URL (https://policy.example.com/uploader):
Upload Validation URL (https://policy.example.com/ingest):
Download URL (https://cartd.example.com):
Download Policy URL (https://policy.example.com/status/transactions/by_id):

Expand Down
2 changes: 1 addition & 1 deletion pacifica/cli/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def configure_url_endpoints(global_ini):

What are the endpoint URLs for the following...
""")
for endpnt in ['upload', 'upload_status', 'upload_policy', 'download', 'download_policy']:
for endpnt in ['upload', 'upload_status', 'upload_policy', 'upload_validation', 'download', 'download_policy']:
default_url = global_ini.get('endpoints', '{}_url'.format(endpnt))
endpnt_nice = ' '.join([
part.capitalize() for part in endpnt.split('_')
Expand Down
7 changes: 6 additions & 1 deletion pacifica/cli/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def save_user_config(global_ini):

def set_environment_vars(global_ini):
"""Set some environment variables to be used later."""
environ['POLICY_URL'] = global_ini.get('endpoints', 'upload_policy_url')
environ['POLICY_UPLOADER_URL'] = global_ini.get(
'endpoints', 'upload_policy_url')
environ['POLICY_INGEST_URL'] = global_ini.get(
'endpoints', 'upload_validation_url')
environ['INGEST_UPLOAD_URL'] = global_ini.get('endpoints', 'upload_url')
environ['INGEST_STATUS_URL'] = global_ini.get(
'endpoints', 'upload_status_url')
Expand All @@ -63,6 +66,8 @@ def generate_global_config():
'https://ingest.example.com/get_state')
global_ini.set('endpoints', 'upload_policy_url',
'https://policy.example.com/uploader')
global_ini.set('endpoints', 'upload_validation_url',
'https://policy.example.com/ingest')
global_ini.set('endpoints', 'download_url',
'https://cartd.example.com')
global_ini.set('endpoints', 'download_policy_url',
Expand Down
2 changes: 2 additions & 0 deletions travis/before-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pacifica-archiveinterface &
echo $! > archiveinterface.pid
export UNIQUEID_CONFIG="$PWD/travis/uniqueid/config.cfg"
export UNIQUEID_CPCONFIG="$PWD/travis/uniqueid/server.conf"
pacifica-uniqueid-cmd dbsync
pacifica-uniqueid &
echo $! > uniqueid.pid
export CARTD_CONFIG="$PWD/travis/cartd/config.cfg"
Expand All @@ -23,6 +24,7 @@ celery -A pacifica.cartd.tasks worker --loglevel=info &
echo $! > cartd.pid
export INGEST_CONFIG="$PWD/travis/ingest/config.cfg"
export INGEST_CPCONFIG="$PWD/travis/ingest/server.conf"
pacifica-ingest-cmd dbsync
pacifica-ingest &
echo $! > ingest.pid
celery -A pacifica.ingest.tasks worker --loglevel=info &
Expand Down
6 changes: 3 additions & 3 deletions travis/unit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ $COV_RUN -a -m pacifica.cli configure --help
# Configure commands
############################
yes | $COV_RUN -a -m pacifica.cli configure
printf '\n\n\n\n\nTrue\nclientssl\n~/.pacifica-cli/my.key\n~/.pacifica-cli/my.cert\n' |
printf '\n\n\n\n\n\nTrue\nclientssl\n~/.pacifica-cli/my.key\n~/.pacifica-cli/my.cert\n' |
$COV_RUN -a -m pacifica.cli configure
printf '\n\n\n\n\nFalse\nbasic\nusername\npassword\n' |
printf '\n\n\n\n\n\nFalse\nbasic\nusername\npassword\n' |
$COV_RUN -a -m pacifica.cli configure

############################
# Build testing config
############################
printf 'http://localhost:8066/upload\nhttp://localhost:8066/get_state\nhttp://localhost:8181/uploader\nhttp://localhost:8081\nhttp://localhost:8181/status/transactions/by_id\nTrue\nNone\n' |
printf 'http://localhost:8066/upload\nhttp://localhost:8066/get_state\nhttp://localhost:8181/uploader\nhttp://localhost:8181/ingest\nhttp://localhost:8081\nhttp://localhost:8181/status/transactions/by_id\nTrue\nNone\n' |
python -m pacifica.cli configure

############################
Expand Down