Skip to content

Commit c99c20d

Browse files
committed
Fix unit tests to run and pass with OpenSSL >= 1.1
Adjust GitHub tests to run on older and newer versions of OpenSSL by using older and newer versions of Ubuntu. Fix tests by changing a few output checks to look for expected text anywhere in the output, instead of at specific lines, so tests will pass despite warning output like this: *** WARNING : deprecated key derivation used. Using -iter or -pbkdf2 would be better. See also #55 Also print OpenSSL version on test runs to aid debugging.
1 parent 38d8a9e commit c99c20d

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

.github/workflows/run-bats-core-tests.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@ on:
1010

1111
jobs:
1212
test:
13-
# We use older Ubuntu for now to avoid warning from newer OpenSSL (#55)
14-
# which break output expectations in some (fragile) tests
15-
runs-on: ubuntu-16.04
13+
# Test on older Ubuntu with OpenSSL < 1.1 and newer with OpenSSL >= 1.1
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os: [ubuntu-16.04, ubuntu-18.04]
1618

1719
steps:
1820
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
1921
- uses: actions/checkout@v2
2022

23+
- name: Print OpenSSL version
24+
run: openssl version
25+
2126
- name: Install and set up bats-core
2227
run: |
2328
git clone https://github.com/bats-core/bats-core.git /tmp/bats-core-repo

tests/test_crypt.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function check_repo_is_clean {
101101
SECRET_CONTENT_ENC="U2FsdGVkX19Fp9SwTyQ+tz1OgHNIN0OJ+6sMgHIqPMzfdZ6rZ2iVquS293WnjJMx"
102102

103103
encrypt_named_file "$FILENAME" "$SECRET_CONTENT"
104-
[[ "${lines[0]}" = *"Encrypt file \"$FILENAME\"" ]]
104+
[[ "${output}" = *"Encrypt file \"$FILENAME\""* ]]
105105

106106
# Working copy is decrypted
107107
run cat "$FILENAME"

tests/test_merge.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ load $BATS_TEST_DIRNAME/_test_helper.bash
8686

8787
run git merge branch-2
8888
[ "$status" -ne 0 ]
89-
[ "${lines[1]}" = "CONFLICT (content): Merge conflict in sensitive_file" ]
89+
[[ "${output}" = *"CONFLICT (content): Merge conflict in sensitive_file"* ]]
9090

9191
run cat sensitive_file
9292
[ "$status" -eq 0 ]

tests/test_pre_commit.bats

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ load $BATS_TEST_DIRNAME/_test_helper.bash
4444
# an encrypted file
4545
run git commit -m "Added more"
4646
[ "$status" -ne 0 ]
47-
[ "${lines[0]}" = "Transcrypt managed file is not encrypted in the Git index: sensitive_file" ]
48-
[ "${lines[1]}" = "You probably staged this file using a tool that does not apply .gitattribute filters as required by Transcrypt." ]
49-
[ "${lines[2]}" = "Fix this by re-staging the file with a compatible tool or with Git on the command line:" ]
50-
[ "${lines[3]}" = " git reset -- sensitive_file" ]
51-
[ "${lines[4]}" = " git add sensitive_file" ]
47+
[[ "${output}" = *"Transcrypt managed file is not encrypted in the Git index: sensitive_file"* ]]
48+
[[ "${output}" = *"You probably staged this file using a tool that does not apply .gitattribute filters as required by Transcrypt."* ]]
49+
[[ "${output}" = *"Fix this by re-staging the file with a compatible tool or with Git on the command line:"* ]]
50+
[[ "${output}" = *" git reset -- sensitive_file"* ]]
51+
[[ "${output}" = *" git add sensitive_file"* ]]
5252
}
5353

5454
@test "pre-commit: warn and don't clobber existing pre-commit hook on init" {

0 commit comments

Comments
 (0)