make tests a bit more accepting of older server behavior

This commit is contained in:
Robin Appelman 2021-10-28 17:39:35 +02:00
commit e4f0be4edb

View file

@ -10,6 +10,7 @@ namespace Icewind\SMB\Test;
use Icewind\SMB\BasicAuth;
use Icewind\SMB\Exception\AuthenticationException;
use Icewind\SMB\Exception\ConnectionRefusedException;
use Icewind\SMB\Exception\InvalidHostException;
use Icewind\SMB\IOptions;
use Icewind\SMB\IShare;
use Icewind\SMB\Options;
@ -52,7 +53,6 @@ class ServerTest extends TestCase {
public function testWrongUserName() {
$this->expectException(AuthenticationException::class);
$this->markTestSkipped('This fails for no reason on travis');
$server = new Server(
$this->config->host,
new BasicAuth(
@ -84,7 +84,6 @@ class ServerTest extends TestCase {
}
public function testWrongHost() {
$this->expectException(ConnectionRefusedException::class);
$server = new Server(
uniqid(),
new BasicAuth(
@ -96,11 +95,17 @@ class ServerTest extends TestCase {
new TimeZoneProvider(new System()),
new Options()
);
try {
$server->listShares();
$this->fail("Expected exception");
} catch (ConnectionRefusedException $e) {
$this->assertTrue(true);
} catch (InvalidHostException $e) {
$this->assertTrue(true);
}
}
public function testHostEscape() {
$this->expectException(ConnectionRefusedException::class);
$server = new Server(
$this->config->host . ';asd',
new BasicAuth(
@ -112,7 +117,14 @@ class ServerTest extends TestCase {
new TimeZoneProvider(new System()),
new Options()
);
try {
$server->listShares();
$this->fail("Expected exception");
} catch (ConnectionRefusedException $e) {
$this->assertTrue(true);
} catch (InvalidHostException $e) {
$this->assertTrue(true);
}
}
public function testProtocolMatch() {
@ -135,7 +147,6 @@ class ServerTest extends TestCase {
}
public function testToLowMaxProtocol() {
$this->expectException(ConnectionRefusedException::class);
$options = new Options();
$options->setMaxProtocol(IOptions::PROTOCOL_NT1);
$server = new Server(
@ -149,6 +160,13 @@ class ServerTest extends TestCase {
new TimeZoneProvider(new System()),
$options
);
try {
$server->listShares();
$this->markTestSkipped("Server seems to accept NT1 connections");
} catch (ConnectionRefusedException $e) {
$this->assertTrue(true);
} catch (\Exception $e) {
$this->fail("Wrong exception");
}
}
}