Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API directory test #8141

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
PGP_PASSWORD: ${{ secrets.PGP_PASSWORD }}
PGP_KEY_ID: ${{ steps.pgp.outputs.keyid }}

- name: Validate API file structure
run: bash tests/api_files.sh

- name: Prepare publish directory
run: |
rsync -av {robots.txt,api/} public/
Expand Down
30 changes: 30 additions & 0 deletions tests/api_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

status=0

# Expected files in directories
declare -A expected_files
expected_files[api/v3]="all.json all.json.sig call.json call.json.sig custom-hardware.json custom-hardware.json.sig custom-software.json custom-software.json.sig email.json email.json.sig regions.json regions.json.sig sms.json sms.json.sig tfa.json tfa.json.sig totp.json totp.json.sig u2f.json u2f.json.sig"
expected_files[api/v4]="all.json all.json.sig call.json call.json.sig custom-hardware.json custom-hardware.json.sig custom-software.json custom-software.json.sig email.json email.json.sig sms.json sms.json.sig totp.json totp.json.sig u2f.json u2f.json.sig"

# $1 = directory
# $2 = expected files (space-separated)
function checkFiles(){
dir="$1";
shift;
missing_files=();
for file in "$@"; do
[[ ! -f "${dir}/${file}" ]] && missing_files+=("$file");
done;
if [[ ${#missing_files[@]} -gt 0 ]]; then
echo "Directory '$dir' is missing the following files: ${missing_files[*]}"
status=1
fi
}

# Validate expected files in directories
for dir in "${!expected_files[@]}"; do
checkFiles "$dir" "${expected_files[$dir]}"
done

exit $status