explicity set protocol in test

This commit is contained in:
Robin Appelman 2025-10-26 02:50:20 +02:00
commit 7f6eafacfc
2 changed files with 108 additions and 102 deletions

View file

@ -61,7 +61,9 @@ jobs:
run: | run: |
nix build .#apps.x86_64-linux.phpunit${{ matrix.php-version }}.program nix build .#apps.x86_64-linux.phpunit${{ matrix.php-version }}.program
- name: PHPUnit Tests - smbclient - name: PHPUnit Tests - smbclient
run: nix run .#phpunit${{ matrix.php-version }} -- tests -c tests/phpunit.xml run:
nix run .#phpunit${{ matrix.php-version }} -- tests -c
tests/phpunit.xml
env: env:
BACKEND: smbclient BACKEND: smbclient
- name: PHPUnit Tests - libsmbclient - name: PHPUnit Tests - libsmbclient
@ -71,103 +73,103 @@ jobs:
env: env:
BACKEND: libsmbclient BACKEND: libsmbclient
# smb-versions: smb-versions:
# runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
# name: name:
# Unit tests - Samba ${{ matrix.server-version }} - smbclient ${{ Unit tests - Samba ${{ matrix.server-version }} - smbclient ${{
# matrix.client-version }} matrix.client-version }}
#
# strategy: strategy:
# fail-fast: false fail-fast: false
# matrix: matrix:
# client-version: client-version:
# - "4.21.4" - "4.21.4"
# - "4.20.4" - "4.20.4"
# - "4.19.5" - "4.19.5"
# - "4.18.1" - "4.18.1"
# - "4.17.7" - "4.17.7"
# - "4.16.10" - "4.16.10"
# - "4.15.13" - "4.15.13"
# - "4.14.9" - "4.14.9"
# - "4.11.17" - "4.11.17"
# server-version: server-version:
# - "latest" - "latest"
# - "4.9.4" - "4.9.4"
# - "4.8.5" - "4.8.5"
#
# services: services:
# samba: samba:
# image: "servercontainers/samba:${{ matrix.server-version }}" image: "servercontainers/samba:${{ matrix.server-version }}"
# env: env:
# ACCOUNT_test: test ACCOUNT_test: test
# UID_test: 1000 UID_test: 1000
# SAMBA_VOLUME_CONFIG_test: SAMBA_VOLUME_CONFIG_test:
# "[test]; path=/tmp; valid users = test; guest ok = no; read only = "[test]; path=/tmp; valid users = test; guest ok = no; read only =
# no; browseable = yes" no; browseable = yes"
#
# steps: steps:
# - name: Setup smbclient - name: Setup smbclient
# env: env:
# DEBIAN_FRONTEND: noninteractive DEBIAN_FRONTEND: noninteractive
# run: | run: |
# sudo apt-get update sudo apt-get update
# sudo apt install -y libjansson4 libcap2 libbsd0 libreadline8 libicu70 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@v4 - 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.2 php-version: 8.2
# extensions: apcu, smbclient extensions: apcu, smbclient
# - name: Composer - name: Composer
# run: composer install run: composer install
# - name: Config - name: Config
# run: | run: |
# echo '{"host": "samba","user": "test","password": "test","share": "test","root": ""}' > tests/config.json echo '{"host": "samba","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:
# timeout_minutes: 2 timeout_minutes: 2
# max_attempts: 3 max_attempts: 3
# retry_on: timeout retry_on: timeout
# command: php ./vendor/bin/phpunit tests -c tests/phpunit.xml command: php ./vendor/bin/phpunit tests -c tests/phpunit.xml
# env: env:
# BACKEND: smbclient BACKEND: smbclient
#
# alpine-test: alpine-test:
# runs-on: alpine-latest runs-on: alpine-latest
# name: Unit tests (alpine) name: Unit tests (alpine)
#
# services: services:
# samba: samba:
# image: "servercontainers/samba" image: "servercontainers/samba"
# env: env:
# ACCOUNT_test: test ACCOUNT_test: test
# UID_test: 1000 UID_test: 1000
# SAMBA_VOLUME_CONFIG_test: SAMBA_VOLUME_CONFIG_test:
# "[test]; path=/tmp; valid users = test; guest ok = no; read only = "[test]; path=/tmp; valid users = test; guest ok = no; read only =
# no; browseable = yes" no; browseable = yes"
#
# steps: steps:
# - uses: actions/checkout@v4 - uses: actions/checkout@v4
# - name: Install dependencies - name: Install dependencies
# shell: sh shell: sh
# run: | run: |
# 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 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: Config - name: Config
# run: | run: |
# echo '{"host": "samba","user": "test","password": "test","share": "test","root": ""}' > tests/config.json echo '{"host": "samba","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
# - name: PHPUnit Tests - smbclient - name: PHPUnit Tests - smbclient
# uses: https://github.com/nick-invision/retry@v2 uses: https://github.com/nick-invision/retry@v2
# with: with:
# timeout_minutes: 2 timeout_minutes: 2
# max_attempts: 3 max_attempts: 3
# retry_on: timeout retry_on: timeout
# command: php ./vendor/bin/phpunit tests -c tests/phpunit.xml command: php ./vendor/bin/phpunit tests -c tests/phpunit.xml
# env: env:
# BACKEND: smbclient BACKEND: smbclient

View file

@ -7,6 +7,7 @@
namespace Icewind\SMB\Test; namespace Icewind\SMB\Test;
use Icewind\SMB\BasicAuth; use Icewind\SMB\BasicAuth;
use Icewind\SMB\IOptions;
use Icewind\SMB\Native\NativeServer; use Icewind\SMB\Native\NativeServer;
use Icewind\SMB\Options; use Icewind\SMB\Options;
use Icewind\SMB\System; use Icewind\SMB\System;
@ -36,6 +37,9 @@ class NativeStreamTest extends TestCase {
$this->markTestSkipped('libsmbclient php extension not installed'); $this->markTestSkipped('libsmbclient php extension not installed');
} }
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json')); $this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
$options = new Options();
$options->setMinProtocol(IOptions::PROTOCOL_SMB2);
$options->setMaxProtocol(IOptions::PROTOCOL_SMB3);
$this->server = new NativeServer( $this->server = new NativeServer(
$this->config->host, $this->config->host,
new BasicAuth( new BasicAuth(
@ -45,7 +49,7 @@ class NativeStreamTest extends TestCase {
), ),
new System(), new System(),
new TimeZoneProvider(new System()), new TimeZoneProvider(new System()),
new Options() $options
); );
$this->share = $this->server->getShare($this->config->share); $this->share = $this->server->getShare($this->config->share);
if ($this->config->root) { if ($this->config->root) {