Skip to content

Commit

Permalink
fix stat check in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thatportugueseguy committed Jul 4, 2024
1 parent 131ec42 commit e4001ec
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.24.1
version=0.26.2
profile=default
ocaml-version=4.14.0

Expand All @@ -17,4 +17,3 @@ nested-match=align # deprecated
parens-ite=true
parens-tuple=multi-line-only
type-decl=sparse

3 changes: 1 addition & 2 deletions tests/create_command.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ Should succeed - create a secret in a new folder, with info about recipients add

If the secret is a staging secret, its only recipient should be @everyone.


Newly created secrets should have permissions 0o644
$ stat -c "%a" $PASSAGE_DIR/secrets/new/secret.age
$ check_permissions $PASSAGE_DIR/secrets/new/secret.age
644

Should succeed - handle secrets with comments too
Expand Down
2 changes: 1 addition & 1 deletion tests/refresh_command.t
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Should show individual operations on secrets when -v is passed
I: refreshed 6 secrets, skipped 4, failed 0

Refreshed secrets should have the same permissions as before (0o644)
$ stat -c "%a" $PASSAGE_DIR/secrets/test_secret.age
$ check_permissions $PASSAGE_DIR/secrets/test_secret.age
644

Secret content should be the same before and after refresh.
Expand Down
4 changes: 2 additions & 2 deletions tests/replace_command.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Should succeed - replace a secret that does not yet exist in a folder where we a
new secret line 3\123\65

Newly created secrets should have permissions 0o644
$ stat -c "%a" $PASSAGE_DIR/secrets/00/new_secret_singleline.age
$ check_permissions $PASSAGE_DIR/secrets/00/new_secret_singleline.age
644
$ stat -c "%a" $PASSAGE_DIR/secrets/00/new_secret_multiline.age
$ check_permissions $PASSAGE_DIR/secrets/00/new_secret_multiline.age
644

Should fail - replace a secret that does not yet exist in a folder where we are NOT listed on the .keys (invariant)
Expand Down
11 changes: 11 additions & 0 deletions tests/setup_fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ setup_multiline_secret_with_comments() {
EOF
}

check_permissions() {
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
stat -c "%a" $1
elif [[ "$OSTYPE" == "darwin"* ]]; then
stat -f "%A" $1
else
echo "Unsupported OS"
exit 1
fi
}

# $PASSAGE_DIR/secrets/
# ├── .keys
# ├── 00
Expand Down

0 comments on commit e4001ec

Please sign in to comment.