Qithub-BOT / QiiCipher

✅ GitHub の SSH 公開鍵でファイルを暗号化およびローカルの秘密鍵で復号・署名・検証するスクリプトのリポジトリです。
https://qiita.com/KEINOS/items/2abce1e5b15d799ac6d7
Creative Commons Attribution Share Alike 4.0 International
4 stars 3 forks source link

sign コマンドで失敗しても `*.sig` ファイルが作成されてしまう #34

Closed KEINOS closed 3 years ago

KEINOS commented 3 years ago

sign コマンドで、引数のパスが間違えていても *.sig ファイルが作成されてしまいます。(Issue https://github.com/Qithub-BOT/QiiCipher/issues/31#issuecomment-852686386 より)

#shellcheck shell=sh

Describe 'sign with unexisting key'
    name_file_to_sign="dummy.txt"
    path_file_sig_out="${SHELLSPEC_TMPDIR}/${name_file_to_sign}.sig"

    It 'should print err with status 1 and should not create .enc file'
        When call sign KEINOS '/path/to/unknown/key.pub' "$name_file_to_sign" "$path_file_sig_out"

        The stdout should include '署名ファイルを生成できませんでした'
        The stderr should include 'No such file or directory'
        The status should be failure # status is 1-255

        Path file_sig="$path_file_sig_out"
        The path file_sig should not be exist
    End
End

- 実行結果

$ shellspec ./tests/issue31_test.sh
Running: /bin/sh [sh]
F

Examples:
  1) sign with unexisting key should print err with status 1 and should not create .enc file
     When call sign KEINOS /path/to/unknown/key.pub dummy.txt /tmp/dummy.txt.sig

     1.1) The path file_sig should not be exist

            The specified path exists
            path: /tmp/dummy.txt.sig

          # tests/issue31_test.sh:13

Finished in 0.37 seconds (user 0.10 seconds, sys 0.08 seconds)
1 example, 1 failure

Failure examples / Errors: (Listed here affect your suite's status)

shellspec tests/issue31_test.sh:7 # 1) sign with unexisting key should print err with status 1 and should not create .enc file FAILED
yoshi389111 commented 3 years ago

これやります