NBISweden / sda-cli

User command line interface for the SDA
GNU Affero General Public License v3.0
5 stars 1 forks source link

Enable downloading encrypted file from sda-download API #406

Closed nanjiangshu closed 2 months ago

nanjiangshu commented 2 months ago

Related issue(s) and PR(s)
This PR closes #393

Description When the flag -pubkey is set, the subcommand sda-download will downloaded the encrypted file (and reencrypted by the provided public key) from the sda-download service

How to test

  1. Start the docker setup by running the following command in the root folder
    bash .github/integration/setup/setup.sh 
  2. Create a crypt4gh key pair by e.g.
    ./sda-cli createKey c4gh
  3. Download the dummy encrypted file with the following command
    ./sda-cli sda-download  -pubkey c4gh.pub.pem -config testing/s3cmd-download.conf -dataset https://doi.example/ty009.sfrrss/600.45asasga -url http://localhost:8080 -outdir test-download main/subfolder/dummy_data.c4gh

    Note that the filepath can be provided with or without the .c4gh extension

After success run, the encrypted file will be downloaded to test-download/main/subfolder/dummy_data.c4gh

  1. Try to decrypt the downloaded file with your private key by
    ./sda-cli decrypt -key c4gh.sec.pem test-download/main/subfolder/dummy_data.c4gh
codecov-commenter commented 2 months ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 73.33333% with 8 lines in your changes missing coverage. Please review.

Project coverage is 43.41%. Comparing base (10bd4b7) to head (1363a21).

Files Patch % Lines
sda_download/sda_download.go 73.33% 7 Missing and 1 partial :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #406 +/- ## ========================================== + Coverage 43.15% 43.41% +0.26% ========================================== Files 13 13 Lines 1840 1861 +21 ========================================== + Hits 794 808 +14 - Misses 938 944 +6 - Partials 108 109 +1 ``` | [Flag](https://app.codecov.io/gh/NBISweden/sda-cli/pull/406/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NBISweden) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/NBISweden/sda-cli/pull/406/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NBISweden) | `43.41% <73.33%> (+0.26%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NBISweden#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.