-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bats | ||
|
||
load _common/helpers | ||
|
||
function setup() { | ||
|
||
# Defining the TMP dir | ||
TESTFILES=${BATS_TEST_FILENAME}.d | ||
mkdir -p "$TESTFILES" | ||
|
||
} | ||
|
||
function teardown() { | ||
rm -rf ${TESTFILES} | ||
} | ||
|
||
@test "Bob sends the testfile secretly to Alice, with a past expiration date" { | ||
|
||
TESTFILE=${BATS_TEST_DIRNAME}/_common/testfile.abcd | ||
|
||
# Bob encrypts the testfile for Alice | ||
export C4GH_PASSPHRASE=${BOB_PASSPHRASE} | ||
EXP_DATE=$(date -jf %s $(( $(date +%s) - 86400 * 2 ))) | ||
crypt4gh encrypt --sk ${BOB_SECKEY} --recipient_pk ${BOB_PUBKEY} --recipient_pk ${ALICE_PUBKEY} --expiration "${EXP_DATE}" < $TESTFILE > $TESTFILES/message.c4gh | ||
|
||
# Alice decrypts it | ||
export C4GH_PASSPHRASE=${ALICE_PASSPHRASE} | ||
crypt4gh decrypt --sk ${ALICE_SECKEY} < $TESTFILES/message.c4gh > $TESTFILES/message.alice.received | ||
[ "$status" -ne 0 ] | ||
|
||
unset C4GH_PASSPHRASE | ||
} | ||
|
||
@test "Bob sends the testfile secretly to Alice, with a future expiration date" { | ||
|
||
TESTFILE=${BATS_TEST_DIRNAME}/_common/testfile.abcd | ||
|
||
# Bob encrypts the testfile for Alice | ||
export C4GH_PASSPHRASE=${BOB_PASSPHRASE} | ||
EXP_DATE=$(date -jf %s $(( $(date +%s) + 86400 * 2 ))) | ||
crypt4gh encrypt --sk ${BOB_SECKEY} --recipient_pk ${BOB_PUBKEY} --recipient_pk ${ALICE_PUBKEY} --expiration "${EXP_DATE}" < $TESTFILE > $TESTFILES/message.c4gh | ||
|
||
# Alice decrypts it | ||
export C4GH_PASSPHRASE=${ALICE_PASSPHRASE} | ||
crypt4gh decrypt --sk ${ALICE_SECKEY} < $TESTFILES/message.c4gh > $TESTFILES/message.alice.received | ||
|
||
run diff $TESTFILE $TESTFILES/message.alice.received | ||
[ "$status" -eq 0 ] | ||
|
||
|
||
unset C4GH_PASSPHRASE | ||
} |