summaryrefslogtreecommitdiff
path: root/test/signtest
blob: 02d73defe895fdcf7744eb714d33018b5dc2162c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash

SUT=$(realpath $(dirname $0)/../makeself.sh)
SOURCE=$(realpath ..)
GPG_SECRET_KEY="secret_key.gpg"
GPG_KEY_ID="64F66800CCC556CB7E8FE108EE8CE9E55B602BD9"
BAD_GPG_KEY_ID="64F66800CCC556CB7E8FE108EE8CE9E55B602BD8"
GPG_KEY_PASSPHRASE="123123"
################################################################################

setupGPGKey() 
{
  echo $GPG_KEY_PASSPHRASE | gpg --batch --yes --passphrase-fd 0 --import $GPG_SECRET_KEY
}

deleteGPGKey() 
{
  gpg --batch --yes --delete-secret-keys $GPG_KEY_ID
}

testCreateSingedArchive() 
{
    setupGPGKey
    mkdir archive
    touch archive/file
    output=$($SUT --sign $GPG_KEY_PASSPHRASE archive makeself-test.run "Test" id)
    assertReturn "$output" 0
    assertEqual "$(echo $output | grep -c Signature:)" "1"
    deleteGPGKey
}

testVerifySingedArchive()
{
    setupGPGKey
    assertReturn "$(./makeself-test.run --verify-sig $GPG_KEY_ID --quiet)" 0
    assertReturn "$(./makeself-test.run --verify-sig $BAD_GPG_KEY_ID --quiet)" 2
    deleteGPGKey
    rm -rf archive
}

################################################################################

source bashunit/bashunit.bash