From a2c12ffe1f2f81654a445e6984083ed464a90333 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 8 Jan 2026 16:52:44 +0000 Subject: [PATCH 1/7] Initial plan From eb412e65e3000d80132b8cade989ce91f0cc240b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 8 Jan 2026 16:55:47 +0000 Subject: [PATCH 2/7] Add GitHub Actions workflow for automated testing Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com> --- .github/workflows/test.yaml | 43 +++++++++++++++++++++++++++++++++++++ src/run_all_ut.sh | 33 +++++++++++++++++++++++----- 2 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..fa3f66f --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,43 @@ +name: Run Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Conan + uses: conan-io/setup-conan@v1 + + - name: Create default Conan profile + run: conan profile detect --force + + - name: Create build directory + run: mkdir -p src/build + + - name: Install dependencies + run: conan install src --output-folder=src/build --build=missing + + - name: Configure CMake + working-directory: src + run: cmake --preset conan-release + + - name: Build + working-directory: src + run: cmake --build --preset conan-release + + - name: Run unit tests + working-directory: src + run: ./build/Release/ut_sha_functions + + - name: Test Summary + if: always() + run: echo "Tests completed" diff --git a/src/run_all_ut.sh b/src/run_all_ut.sh index 475b253..b757af8 100755 --- a/src/run_all_ut.sh +++ b/src/run_all_ut.sh @@ -5,9 +5,32 @@ set -e # Nella cartella ./build avviare tutti gli eseguibili che iniziano con ut_ BUILD_DIR="build" +BUILD_TYPE="${1:-Release}" # Default a Release se non specificato -if [ -d "$BUILD_DIR" ]; then - for file in "$BUILD_DIR"/ut_*; do - ./"$file" - done -fi \ No newline at end of file +# Cerca gli eseguibili di test nelle diverse possibili locazioni +TEST_LOCATIONS=( + "$BUILD_DIR/$BUILD_TYPE" + "$BUILD_DIR" +) + +echo "Searching for test executables (build type: $BUILD_TYPE)..." + +TESTS_FOUND=0 +for location in "${TEST_LOCATIONS[@]}"; do + if [ -d "$location" ]; then + for file in "$location"/ut_*; do + if [ -x "$file" ]; then + echo "Running test: $file" + "$file" + TESTS_FOUND=$((TESTS_FOUND + 1)) + fi + done + fi +done + +if [ $TESTS_FOUND -eq 0 ]; then + echo "No test executables found. Please build the project first." + exit 1 +fi + +echo "All tests completed successfully! ($TESTS_FOUND test suite(s) executed)" \ No newline at end of file From 0cd0c35d85eb9daed732c18d0b18990036faa9f9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 8 Jan 2026 16:56:25 +0000 Subject: [PATCH 3/7] Enhance test workflow with XML output and test result reporting Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com> --- .github/workflows/test.yaml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fa3f66f..30fe276 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -36,8 +36,20 @@ jobs: - name: Run unit tests working-directory: src - run: ./build/Release/ut_sha_functions + run: | + echo "Running SHA implementation tests..." + ./build/Release/ut_sha_functions --gtest_output=xml:test-results.xml + continue-on-error: false + + - name: Publish test results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + files: | + src/test-results.xml + check_name: "Unit Test Results" + comment_mode: "off" - name: Test Summary if: always() - run: echo "Tests completed" + run: echo "✅ All tests completed successfully" From cf293c4bba1c9db8dd0633042d97058b4f004478 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 8 Jan 2026 16:57:08 +0000 Subject: [PATCH 4/7] Update README with test workflow badge and testing documentation Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com> --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 2739ec5..ddcbce5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Italian: Implementazione Secure Hash Algorithm (SHA) [![Cmake compilation Conan](https://github.com/AndreaCicca/SHA-implementation/actions/workflows/compilation.yaml/badge.svg)](https://github.com/AndreaCicca/SHA-implementation/actions/workflows/compilation.yaml) +[![Run Tests](https://github.com/AndreaCicca/SHA-implementation/actions/workflows/test.yaml/badge.svg)](https://github.com/AndreaCicca/SHA-implementation/actions/workflows/test.yaml) Corso di Crittografia presso Unipr. @@ -42,3 +43,32 @@ cmake --build build > [!NOTE] > Per non copia e incollare i singoli comandi si può usare lo script src/compile.sh + +## Esecuzione dei test + +Dopo aver compilato il progetto, è possibile eseguire i test unitari: + +### Eseguire tutti i test + +```bash +cd src && ./run_all_ut.sh +``` + +### Eseguire i test manualmente + +```bash +cd src && ./build/Release/ut_sha_functions +``` + +### Eseguire i test con output XML (per CI/CD) + +```bash +cd src && ./build/Release/ut_sha_functions --gtest_output=xml:test-results.xml +``` + +I test verificano la correttezza dell'implementazione SHA-1 e SHA-256 confrontandola con la libreria OpenSSL, includendo: +- Test con stringhe vuote, corte, lunghe e molto lunghe +- Test con caratteri speciali e non-ASCII +- Test di determinismo +- Test dell'effetto valanga (avalanche effect) +- Test di performance From b891cca37848a8c141c9cde3af9009ea3cb1b70e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 8 Jan 2026 16:58:42 +0000 Subject: [PATCH 5/7] Address code review feedback: upgrade setup-conan and improve consistency Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com> --- .github/workflows/compilation.yaml | 2 +- .github/workflows/test.yaml | 4 +++- src/run_all_ut.sh | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compilation.yaml b/.github/workflows/compilation.yaml index 1442389..1e4e7db 100644 --- a/.github/workflows/compilation.yaml +++ b/.github/workflows/compilation.yaml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v4 - name: Install Conan - uses: conan-io/setup-conan@v1 + uses: conan-io/setup-conan@v2 - name: Create default Conan profile run: conan profile detect --force diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 30fe276..6be43bb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v4 - name: Install Conan - uses: conan-io/setup-conan@v1 + uses: conan-io/setup-conan@v2 - name: Create default Conan profile run: conan profile detect --force @@ -38,6 +38,8 @@ jobs: working-directory: src run: | echo "Running SHA implementation tests..." + ./run_all_ut.sh Release + # Also generate XML output for test reporting ./build/Release/ut_sha_functions --gtest_output=xml:test-results.xml continue-on-error: false diff --git a/src/run_all_ut.sh b/src/run_all_ut.sh index b757af8..eda997d 100755 --- a/src/run_all_ut.sh +++ b/src/run_all_ut.sh @@ -5,7 +5,7 @@ set -e # Nella cartella ./build avviare tutti gli eseguibili che iniziano con ut_ BUILD_DIR="build" -BUILD_TYPE="${1:-Release}" # Default a Release se non specificato +BUILD_TYPE="${1:-Release}" # Default to Release if not specified # Cerca gli eseguibili di test nelle diverse possibili locazioni TEST_LOCATIONS=( From 294af831bfb49bdba6826c3a4197bb1d518596fa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 8 Jan 2026 17:00:00 +0000 Subject: [PATCH 6/7] Add explicit permissions to workflows for security best practices Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com> --- .github/workflows/compilation.yaml | 2 ++ .github/workflows/test.yaml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/compilation.yaml b/.github/workflows/compilation.yaml index 1e4e7db..d78ce81 100644 --- a/.github/workflows/compilation.yaml +++ b/.github/workflows/compilation.yaml @@ -9,6 +9,8 @@ on: jobs: build: runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout code diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6be43bb..fe990ad 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,6 +9,9 @@ on: jobs: test: runs-on: ubuntu-latest + permissions: + contents: read + checks: write steps: - name: Checkout code From 3603e1998b372b6a218b203344d4a11421b7a328 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 8 Jan 2026 17:07:28 +0000 Subject: [PATCH 7/7] Revert to conan-io/setup-conan@v1 as v2 does not exist Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com> --- .github/workflows/compilation.yaml | 2 +- .github/workflows/test.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compilation.yaml b/.github/workflows/compilation.yaml index d78ce81..5d16e5a 100644 --- a/.github/workflows/compilation.yaml +++ b/.github/workflows/compilation.yaml @@ -17,7 +17,7 @@ jobs: uses: actions/checkout@v4 - name: Install Conan - uses: conan-io/setup-conan@v2 + uses: conan-io/setup-conan@v1 - name: Create default Conan profile run: conan profile detect --force diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fe990ad..30f6089 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@v4 - name: Install Conan - uses: conan-io/setup-conan@v2 + uses: conan-io/setup-conan@v1 - name: Create default Conan profile run: conan profile detect --force