This commit is contained in:
Robin Appelman 2025-10-24 01:06:49 +02:00
commit 89fa87e65b
2 changed files with 64 additions and 84 deletions

View file

@ -14,32 +14,26 @@ jobs:
name: PHP-CS-Fixer name: PHP-CS-Fixer
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Setup PHP - name: Setup PHP
uses: https://github.com/shivammathur/setup-php@v2 uses: https://github.com/shivammathur/setup-php@v2
with: with:
php-version: '8.0' php-version: '8.0'
extensions: apcu extensions: apcu
- name: Composer
run: composer install
- name: PHP-CS-Fixer - name: PHP-CS-Fixer
uses: https://github.com/OskarStark/php-cs-fixer-ga@2.16.7 run: |
with: composer run cs:check
args: --diff --dry-run --allow-risky yes --stop-on-violation --using-cache=no --path-mode=intersection
php-versions: php-versions:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
name: Unit tests name: Unit tests - PHP ${{ matrix.php-version }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
backend:
- smbclient
- libsmbclient
php-version: php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1" - "8.1"
- "8.2" - "8.2"
- "8.3" - "8.3"
@ -55,9 +49,12 @@ jobs:
steps: steps:
- name: Install packages - name: Install packages
env:
DEBIAN_FRONTEND: noninteractive
run: | run: |
sudo apt-get install smbclient libsmbclient-dev sudo apt-get update
- uses: actions/checkout@v3 sudo apt-get install -y smbclient libsmbclient-dev
- uses: actions/checkout@v4
- name: Setup PHP - name: Setup PHP
uses: https://github.com/shivammathur/setup-php@v2 uses: https://github.com/shivammathur/setup-php@v2
with: with:
@ -68,10 +65,8 @@ jobs:
run: composer install run: composer install
- name: Config - name: Config
run: | run: |
IP=$(docker inspect ${{ job.services.samba.id }} | jq -r 'map(.NetworkSettings.Networks)[0] | .[].IPAddress') echo '{"host": "samba","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
echo "Samba running at $IP" - name: PHPUnit Tests - smbclient
echo '{"host": "'$IP'","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
- name: PHPUnit Tests
uses: https://github.com/nick-invision/retry@v2 uses: https://github.com/nick-invision/retry@v2
with: with:
timeout_minutes: 2 timeout_minutes: 2
@ -79,14 +74,23 @@ jobs:
retry_on: timeout retry_on: timeout
command: php ./vendor/bin/phpunit tests -c tests/phpunit.xml --coverage-clover=coverage.xml command: php ./vendor/bin/phpunit tests -c tests/phpunit.xml --coverage-clover=coverage.xml
env: env:
BACKEND: ${{ matrix.backend }} BACKEND: smbclient
- name: PHPUnit Tests - libsmbclient
uses: https://github.com/nick-invision/retry@v2
with:
timeout_minutes: 2
max_attempts: 3
retry_on: timeout
command: php ./vendor/bin/phpunit tests -c tests/phpunit.xml --coverage-clover=coverage.xml
env:
BACKEND: libsmbclient
- uses: https://github.com/codecov/codecov-action@v3 - uses: https://github.com/codecov/codecov-action@v3
with: with:
files: ./coverage.xml files: ./coverage.xml
smb-versions: smb-versions:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
name: Unit tests name: Unit tests - Samba ${{ matrix.server-version }} - smbclient ${{ matrix.client-version }}
strategy: strategy:
fail-fast: false fail-fast: false
@ -116,26 +120,27 @@ jobs:
steps: steps:
- name: Setup smbclient - name: Setup smbclient
env:
DEBIAN_FRONTEND: noninteractive
run: | run: |
sudo apt install libjansson4 libcap2 libbsd0 libreadline8 libicu70 sudo apt-get update
sudo apt install -y libjansson4 libcap2 libbsd0 libreadline8 libicu70
sudo mkdir -p /etc/samba /var/lib/samba/private sudo mkdir -p /etc/samba /var/lib/samba/private
echo "[global]\nclient min protocol = SMB2\nclient max protocol = SMB3" | sudo tee /etc/samba/smb.conf echo "[global]\nclient min protocol = SMB2\nclient max protocol = SMB3" | sudo tee /etc/samba/smb.conf
sudo wget "https://github.com/icewind1991/smbclient-builder/releases/download/v0.2.0/smbclient-${{ matrix.client-version }}" -O /usr/local/bin/smbclient sudo wget "https://github.com/icewind1991/smbclient-builder/releases/download/v0.2.0/smbclient-${{ matrix.client-version }}" -O /usr/local/bin/smbclient
sudo chmod +x /usr/local/bin/smbclient sudo chmod +x /usr/local/bin/smbclient
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Setup PHP - name: Setup PHP
uses: https://github.com/shivammathur/setup-php@v2 uses: https://github.com/shivammathur/setup-php@v2
with: with:
php-version: 8.0 php-version: 8.1
extensions: apcu, smbclient extensions: apcu, smbclient
coverage: pcov coverage: pcov
- name: Composer - name: Composer
run: composer install run: composer install
- name: Config - name: Config
run: | run: |
IP=$(docker inspect ${{ job.services.samba.id }} | jq -r 'map(.NetworkSettings.Networks)[0] | .[].IPAddress') echo '{"host": "samba","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
echo "Samba running at $IP"
echo '{"host": "'$IP'","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
- name: PHPUnit Tests - name: PHPUnit Tests
uses: https://github.com/nick-invision/retry@v2 uses: https://github.com/nick-invision/retry@v2
with: with:
@ -150,7 +155,7 @@ jobs:
files: ./coverage.xml files: ./coverage.xml
alpine-test: alpine-test:
runs-on: ubuntu-latest runs-on: alpine-latest
name: Unit tests (alpine) name: Unit tests (alpine)
services: services:
@ -162,52 +167,25 @@ jobs:
SAMBA_VOLUME_CONFIG_test: "[test]; path=/tmp; valid users = test; guest ok = no; read only = no; browseable = yes" SAMBA_VOLUME_CONFIG_test: "[test]; path=/tmp; valid users = test; guest ok = no; read only = no; browseable = yes"
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Setup PHP - name: Install dependencies
uses: https://github.com/shivammathur/setup-php@v2 shell: sh
with: run: |
php-version: 8.0 apk add bash sudo git coreutils samba-client php composer php-curl php-iconv php-mbstring php-openssl php-zip php-phar php-tokenizer php-dom php-xml php-xmlwriter
- name: Composer - name: Composer
run: composer install run: composer install
- name: Pull images
run: |
docker pull icewind1991/smbclient-php-alpine
- name: Config - name: Config
run: | run: |
IP=$(docker inspect ${{ job.services.samba.id }} | jq -r 'map(.NetworkSettings.Networks)[0] | .[].IPAddress') echo '{"host": "samba","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
echo "Samba running at $IP" - name: PHPUnit Tests - smbclient
echo '{"host": "'$IP'","user": "test","password": "test","share": "test","root": ""}' > tests/config.json uses: https://github.com/nick-invision/retry@v2
- name: PHPUnit Tests with:
run: | timeout_minutes: 2
docker run --network "host" --rm -v $PWD:/smb icewind1991/smbclient-php-alpine /smb/vendor/bin/phpunit -c /smb/tests/phpunit.xml /smb/tests max_attempts: 3
retry_on: timeout
kerberos-sso: command: php ./vendor/bin/phpunit tests -c tests/phpunit.xml --coverage-clover=coverage.xml
runs-on: ubuntu-latest env:
name: Kerberos SSO tests BACKEND: smbclient
steps:
- uses: actions/checkout@v3
- name: Composer
run: composer install
- name: Pull images
run: |
docker pull icewind1991/samba-krb-test-dc
docker pull icewind1991/samba-krb-test-apache
docker pull icewind1991/samba-krb-test-client
- name: Setup AD-DC
run: |
tests/setup-krb.sh
- name: Test kerberos auth
run: |
DC_IP=$(docker inspect dc --format '{{.NetworkSettings.IPAddress}}')
LIST=$(docker run --rm --name client -v /tmp/shared:/shared --dns $DC_IP --hostname client.domain.test icewind1991/samba-krb-test-client \
curl -s --negotiate -u testuser@DOMAIN.TEST: --delegation always http://httpd.domain.test/example-sso-kerberos.php)
echo $LIST
LIST=$(echo $LIST | tr -d '[:space:]')
[[ $LIST == "test.txt" ]]
- name: Apache logs
if: always()
run: |
docker logs apache
static-psalm-analysis: static-psalm-analysis:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -217,10 +195,6 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
php-version: php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1" - "8.1"
- "8.2" - "8.2"
- "8.3" - "8.3"
@ -228,9 +202,13 @@ jobs:
steps: steps:
- name: krb5-dev - name: krb5-dev
run: sudo apt-get install -y libkrb5-dev libsmbclient-dev env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install -y libkrb5-dev libsmbclient-dev
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Set up php - name: Set up php
uses: https://github.com/shivammathur/setup-php@master uses: https://github.com/shivammathur/setup-php@master
with: with:
@ -251,12 +229,14 @@ jobs:
steps: steps:
- name: krb5-dev - name: krb5-dev
run: sudo apt-get install -y libkrb5-dev run: |
- uses: actions/checkout@v3 sudo apt-get update
sudo apt-get install -y libkrb5-dev
- uses: actions/checkout@v4
- name: Setup PHP - name: Setup PHP
uses: https://github.com/shivammathur/setup-php@v2 uses: https://github.com/shivammathur/setup-php@v2
with: with:
php-version: '8.0' php-version: 8.3
extensions: apcu, smbclient, krb5 extensions: apcu, smbclient, krb5
env: env:
fail-fast: true fail-fast: true

View file

@ -24,14 +24,14 @@ function waitContainer {
mkdir /tmp/shared mkdir /tmp/shared
# start the dc # start the dc
docker run -dit --name dc -v /tmp/shared:/shared --hostname krb.domain.test --cap-add SYS_ADMIN icewind1991/samba-krb-test-dc docker run -dit --name dc${FORGEJO_RUN_NUMBER} -v /tmp/shared:/shared --hostname krb.domain.test --cap-add SYS_ADMIN icewind1991/samba-krb-test-dc
DC_IP=$(docker inspect dc --format '{{.NetworkSettings.IPAddress}}') DC_IP=$(docker inspect dc${FORGEJO_RUN_NUMBER} --format '{{.NetworkSettings.IPAddress}}')
waitContainer dc waitContainer dc${FORGEJO_RUN_NUMBER}
# start apache # start apache
docker run -d --name apache -v $PWD:/var/www/html -v /tmp/shared:/shared --dns $DC_IP --hostname httpd.domain.test icewind1991/samba-krb-test-apache docker run -d --name apache${FORGEJO_RUN_NUMBER} -v $PWD:/var/www/html -v /tmp/shared:/shared --dns $DC_IP --hostname httpd.domain.test icewind1991/samba-krb-test-apache
APACHE_IP=$(docker inspect apache --format '{{.NetworkSettings.IPAddress}}') APACHE_IP=$(docker inspect apache${FORGEJO_RUN_NUMBER} --format '{{.NetworkSettings.IPAddress}}')
# add the dns record for apache # add the dns record for apache
docker exec dc samba-tool dns add krb.domain.test domain.test httpd A $APACHE_IP -U administrator --password=passwOrd1 docker exec dc${FORGEJO_RUN_NUMBER} samba-tool dns add krb.domain.test domain.test httpd A $APACHE_IP -U administrator --password=passwOrd1