Skip to content

Commit

Permalink
update debian builds and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sdepassio committed Feb 13, 2025
1 parent e252589 commit c61b4ee
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
21 changes: 19 additions & 2 deletions .github/actions/test-cpan-libs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ runs:
fail-on-cache-miss: true

- if: ${{ inputs.package_extension == 'rpm' }}
name: Install packages
name: Check packages installation / uninstallation
run: |
error_log="install_error_${{ inputs.distrib }}_${{ inputs.arch }}.log"
for package in ./*.rpm; do
Expand All @@ -73,6 +73,15 @@ runs:
echo "Package installation..."
error_output=$(dnf install -y $package 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of the package $package" >> $error_log; true; }
echo "Package installation done."
script_name=$(echo $package | tr '[:upper:]' '[:lower:]' | sed 's/\.\/perl-//' | sed 's/-[0-9\.-]*.el[0-9]..*.rpm//')
if [[ -f tests/cpan-libraries/$script_name.pl ]]; then
echo "Testing package..."
error_output=$(perl tests/cpan-libraries/$script_name.pl 2>&1) || { echo "$error_output" >> $error_log; echo "Error during the usage test of the package $package" >> $error_log; true; }
echo "Testing done."
else
echo "No test script found for the package $package"
fi
error_output=$(perl tests/cpan-libraries/$script_name.pl 2>&1) || { echo "$error_output" >> $error_log; echo "Error during testing of the package $package" >> $error_log; true; }
echo "Package uninstallation..."
error_output=$(dnf autoremove --setopt=keepcache=True -y $(echo $package | sed 's/_[0-9].*\.rpm//' | sed 's/.\///') 2>&1) || { echo "$error_output" >> $error_log; echo "Error during autoremove of the package $package" >> $error_log; true; }
echo "Package uninstallation done."
Expand All @@ -85,7 +94,7 @@ runs:
shell: bash

- if: ${{ inputs.package_extension == 'deb' }}
name: Install packages
name: Check packages installation / uninstallation
run: |
error_log="install_error_${{ inputs.distrib }}_${{ inputs.arch }}.log"
for package in ./*.deb; do
Expand Down Expand Up @@ -113,6 +122,14 @@ runs:
echo "Package installation..."
error_output=$(apt-get install -y $package 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of the package $package" >> $error_log; true; }
echo "Package installation done."
script_name=$(echo $package | sed 's/.\/lib//' | sed 's/-perl_[0-9\.-]*-deb.*\.deb//')
if [[ -f tests/cpan-libraries/$script_name.pl ]]; then
echo "Testing package..."
error_output=$(perl tests/cpan-libraries/$script_name.pl 2>&1) || { echo "$error_output" >> $error_log; echo "Error during the usage test of the package $package" >> $error_log; true; }
echo "Testing done."
else
echo "No test script found for the package $package"
fi
echo "Package uninstallation..."
error_output=$(apt-get autoremove -y --purge $(echo $package | sed 's/_[0-9].*\.deb//' | sed 's/.\///') 2>&1) || { echo "$error_output" >> $error_log; echo "Error during autoremove of the package $package" >> $error_log; true; }
echo "Package uninstallation done."
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/perl-new-cpan-libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,18 @@ jobs:
arch: arm64
runner_name: ["self-hosted", "collect-arm64"]
- name: Crypt::Argon2
build_names: "bullseye-amd64,jammy"
build_names: "bullseye-amd64,jammy,bullseye-arm64"
preinstall_cpanlibs: "Dist::Build"
use_dh_make_perl: "false"
no-auto-depends: "true"
- name: Libssh::Session
use_dh_make_perl: "false"
build_names: "bullseye-amd64,bookworm,jammy,bullseye-arm64"
no-auto-depends: "true"
- name: Net::Curl
use_dh_make_perl: "false"
build_names: "bullseye-amd64,bookworm,jammy,bullseye-arm64"
no-auto-depends: "true"
name: package ${{ matrix.distrib }} ${{ matrix.arch }} ${{ matrix.name }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest
Expand Down
41 changes: 41 additions & 0 deletions tests/cpan-libs/crypt-argon2.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/perl

use strict;
use warnings;
use Crypt::Argon2 qw/argon2_raw argon2d_raw argon2i_raw argon2id_raw argon2_pass argon2i_pass argon2id_pass argon2_verify argon2i_verify argon2id_verify/;

# Password to hash
my $password = 'my_secure_password';
my $salt = 'random_salt';
my $iterations = 3;
my $memory_cost = 32 * 1024; # in KB
my $parallelism = 1;
my $hash_length = 32;

# Hash with Argon2d
my $argon2d_hash = argon2d_raw('argon2d', $password, $salt, $iterations, $memory_cost, $parallelism, $hash_length);
print("Argon2d hash: $argon2d_hash\n");
# Hash with Argon2i
my $argon2i_hash = argon2i_raw('argon2i', $password, $salt, $iterations, $memory_cost, $parallelism, $hash_length);
print("Argon2i hash: $argon2i_hash\n");
# Hash with Argon2id
my $argon2id_hash = argon2id_raw($password, $salt, $iterations, $memory_cost, $parallelism, $hash_length);
print("Argon2id hash: $argon2id_hash\n");

# Encode password with Argon2d
my $argon2d_encoded = argon2_pass('argon2d', $password, $salt, $iterations, $memory_cost, $parallelism, $hash_length);
print "Argon2d encoded: $argon2d_encoded\n";
# Encode password with Argon2i
my $argon2i_encoded = argon2_pass('argon2i', $password, $salt, $iterations, $memory_cost, $parallelism, $hash_length);
print "Argon2i encoded: $argon2i_encoded\n";
# Encode password with Argon2id
my $argon2id_encoded = argon2_pass('argon2id', $password, $salt, $iterations, $memory_cost, $parallelism, $hash_length);
print "Argon2id encoded: $argon2id_encoded\n";

# Verify password with Argon2d
# print argon2d_verify($argon2d_encoded1, $password) ? "Argon2d password is correct.\n" : "Argon2d password is incorrect.\n";
argon2_verify($argon2d_encoded, $password) ? print "Argon2d password is correct.\n" : print "Argon2d password is incorrect.\n";
# Verify password with Argon2i
argon2_verify($argon2i_encoded, $password) ? print "Argon2i password is correct.\n" : print "Argon2i password is incorrect.\n";
# Verify password with Argon2id
argon2_verify($salt, $password) ? print "Argon2id password is correct.\n" : print "Argon2id password is incorrect.\n";

0 comments on commit c61b4ee

Please sign in to comment.