diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index dd51d7d..e4ab85e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -167,9 +167,6 @@ jobs: php-versions: ['8.1', '8.2', '8.3'] steps: - - name: Install Apache and Stunnel - run: sudo apt-get install stunnel4 apache2 - - name: Setup PHP, with composer and extensions # https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v2 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c8a72ec..0000000 --- a/.travis.yml +++ /dev/null @@ -1,122 +0,0 @@ -sudo: required - -language: php - -stages: - - pre-conditions - - test - - quality - -################ -# Test stage # -################ - -php: - - 7.4 - -env: - - COMMAND="composer install --no-interaction" - - COMMAND="composer update --no-interaction" - -before_install: - - printf "\n" | pecl install krb5 - -before_script: - - sudo apt-get install stunnel4 apache2 - - mkdir /tmp/testdisk; sudo mount -t tmpfs -o size=100k tmpfs /tmp/testdisk; sudo chmod -R 777 /tmp/testdisk - - phpenv config-add tests/files/myphp.ini - - ${COMMAND} --no-interaction - - sudo stunnel4 tests/files/stunnel.conf - - php -S localhost:8080 & - - export WEBPID=$! - -script: - - php vendor/bin/phpunit --no-coverage - -after_success: - - sudo umount /tmp/testdisk; rm -rf /tmp/testdisk - - kill -kill $WEBPID - -jobs: - fast_finish: true - - allow_failures: - - php: 7.4 - env: Psalm - - php: 7.4 - env: PHP Codesniffer - - include: - - ########################## - # Pre-conditions stage # - ########################## - - - stage: pre-conditions - env: Syntax check PHP - php: 7.4 - before_script: - - composer install - script: - - vendor/bin/check-syntax-php.sh - - - stage: pre-conditions - env: Syntax check YAML / XML / JSON - before_script: - - composer install - script: - - vendor/simplesamlphp/simplesamlphp-test-framework/bin/check-syntax-json.sh - - vendor/simplesamlphp/simplesamlphp-test-framework/bin/check-syntax-xml.sh - - vendor/simplesamlphp/simplesamlphp-test-framework/bin/check-syntax-yaml.sh - - ################### - # Quality stage # - ################### - - - stage: quality - php: 7.4 - env: Security check (composer install) - before_script: - - composer update - script: - - vendor/bin/security-checker security:check - - - stage: quality - php: 7.4 - env: Security check (composer update) - before_script: - - composer update - script: - - vendor/bin/security-checker security:check - - - stage: quality - php: 7.4 - env: Codecov - before_script: - - sudo apt-get install stunnel4 apache2 - - mkdir /tmp/testdisk; sudo mount -t tmpfs -o size=100k tmpfs /tmp/testdisk; sudo chmod -R 777 /tmp/testdisk - - phpenv config-add tests/files/myphp.ini - - composer update - - sudo stunnel4 tests/files/stunnel.conf - - php -S localhost:8080 & - - export WEBPID=$! - script: - - php vendor/bin/phpunit - - bash <(curl -s https://codecov.io/bash) - - - stage: quality - php: 7.4 - env: Psalm - before_script: - - composer update - script: - - vendor/bin/psalm - - vendor/bin/psalter --issues=UnnecessaryVarAnnotation --dry-run - - - stage: quality - php: 7.4 - env: PHP Codesniffer - before_script: - - composer update - script: - - vendor/bin/phpcs diff --git a/tests/files/myphp.ini b/tests/files/myphp.ini deleted file mode 100644 index 324d611..0000000 --- a/tests/files/myphp.ini +++ /dev/null @@ -1 +0,0 @@ -session.save_path=/tmp/testdisk diff --git a/tests/files/stunnel.conf b/tests/files/stunnel.conf deleted file mode 100644 index 801707a..0000000 --- a/tests/files/stunnel.conf +++ /dev/null @@ -1,6 +0,0 @@ -client = no -[webserver] -accept = 443 -connect = 127.0.0.1:8080 -cert = vendor/simplesamlphp/xml-security/tests/resources/certificates/rsa-pem/selfsigned.simplesamlphp.org.crt -key = vendor/simplesamlphp/xml-security/tests/resources/certificates/rsa-pem/selfsigned.simplesamlphp.org_nopasswd.key diff --git a/tests/src/TestCase/AuthSource/Ldap/LdapBindTest.php b/tests/src/TestCase/AuthSource/Ldap/LdapBindTest.php index 792248d..bb32c92 100644 --- a/tests/src/TestCase/AuthSource/Ldap/LdapBindTest.php +++ b/tests/src/TestCase/AuthSource/Ldap/LdapBindTest.php @@ -25,7 +25,7 @@ public function testBindSuccesful(): void $connectionMock = $this->getMockBuilder(Ldap::class)->onlyMethods( ['bind'], )->disableOriginalConstructor()->getMock(); - $connectionMock->expects($this->once())->method('bind')->willReturn(true); + $connectionMock->expects($this->once())->method('bind'); $confTest = new TestCase\AuthSource\Ldap\Bind( new TestData([ 'authSourceData' => Configuration::loadFromArray($authSourceData), diff --git a/tests/src/TestCase/AuthSource/NegotiateTest.php b/tests/src/TestCase/AuthSource/NegotiateTest.php index fcb2afe..3ab6cf9 100644 --- a/tests/src/TestCase/AuthSource/NegotiateTest.php +++ b/tests/src/TestCase/AuthSource/NegotiateTest.php @@ -49,10 +49,10 @@ public function testNegotiateSuccess(): void $KRB5NegotiateAuthMock = $this->getMockBuilder(KRB5NegotiateAuth::class)->onlyMethods( ['doAuthentication', 'getAuthenticatedUser'], )->disableOriginalConstructor()->getMock(); - $KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->will($this->returnValue(true)); - $KRB5NegotiateAuthMock->expects($this->any())->method('getAuthenticatedUser')->will( - $this->returnValue('testuser@example.org'), - ); + $KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->willReturn(true); + $KRB5NegotiateAuthMock->expects($this->any()) + ->method('getAuthenticatedUser') + ->willReturn('testuser@example.org'); $testData = new TestData([ 'handle' => $KRB5NegotiateAuthMock, ]); @@ -67,7 +67,7 @@ public function testNegotiateNoAuthorzation(): void $KRB5NegotiateAuthMock = $this->getMockBuilder(KRB5NegotiateAuth::class)->onlyMethods( ['doAuthentication', 'getAuthenticatedUser'], )->disableOriginalConstructor()->getMock(); - $KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->will($this->returnValue(false)); + $KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->willReturn(false); $testData = new TestData([ 'handle' => $KRB5NegotiateAuthMock, ]); @@ -82,7 +82,7 @@ public function testNegotiateError(): void $KRB5NegotiateAuthMock = $this->getMockBuilder(KRB5NegotiateAuth::class)->onlyMethods( ['doAuthentication', 'getAuthenticatedUser'], )->disableOriginalConstructor()->getMock(); - $KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->will($this->returnValue(false)); + $KRB5NegotiateAuthMock->expects($this->any())->method('doAuthentication')->willReturn(false); $testData = new TestData([ 'handle' => $KRB5NegotiateAuthMock, 'authorization' => 'test', diff --git a/tests/src/TestCase/CertificatesTest.php b/tests/src/TestCase/CertificatesTest.php index d3b2159..046cf81 100644 --- a/tests/src/TestCase/CertificatesTest.php +++ b/tests/src/TestCase/CertificatesTest.php @@ -18,7 +18,7 @@ class TestCertificatesTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass(): void { - self::$certdir = getcwd() . '/vendor/simplesamlphp/xml-security/tests/resources/certificates/'; + self::$certdir = getcwd() . '/vendor/simplesamlphp/xml-security/resources/certificates/'; } public function testCertExpired(): void diff --git a/tests/src/TestCase/Network/ConnectUriTest.php b/tests/src/TestCase/Network/ConnectUriTest.php index 0cbf57b..3dd9de2 100644 --- a/tests/src/TestCase/Network/ConnectUriTest.php +++ b/tests/src/TestCase/Network/ConnectUriTest.php @@ -8,6 +8,8 @@ use SimpleSAML\Module\monitor\TestCase; use SimpleSAML\Module\monitor\TestData; +use function gethostbyname; +use function sprintf; use function stream_context_create; /** @@ -15,10 +17,18 @@ */ class TestConnectUriTest extends \PHPUnit\Framework\TestCase { + protected static string $host; + + public static function setUpBeforeClass(): void + { + self::$host = gethostbyname('packagist.org'); + } + public function testConnectUriOK(): void { $testData = new TestData([ - 'uri' => 'ssl://127.0.0.1:443', + 'uri' => sprintf('ssl://%s:443', self::$host), + 'timeout' => 3, 'context' => stream_context_create([ "ssl" => [ "capture_peer_cert" => true, @@ -35,7 +45,8 @@ public function testConnectUriOK(): void public function testConnectUriFailed(): void { $testData = new TestData([ - 'uri' => 'ssl://127.0.0.1:442', + 'uri' => sprintf('ssl://%s:442', self::$host), + 'timeout' => 3, ]); $connectionTest = new TestCase\Network\ConnectUri($testData); $testResult = $connectionTest->getTestResult(); diff --git a/tests/src/TestCase/Store/SqlTest.php b/tests/src/TestCase/Store/SqlTest.php index bd9cce5..4aee50d 100644 --- a/tests/src/TestCase/Store/SqlTest.php +++ b/tests/src/TestCase/Store/SqlTest.php @@ -4,6 +4,7 @@ namespace SimpleSAML\Module\monitor\Test; +use PHPunit\Framework\Attributes\RequiresOperatingSystem; use SimpleSAML\Configuration; use SimpleSAML\Module\monitor\State; use SimpleSAML\Module\monitor\TestCase\Store\Sql; @@ -16,6 +17,7 @@ */ class TestSqlTest extends \SimpleSAML\TestUtils\ClearStateTestCase { + #[RequiresOperatingSystem('Linux')] public function testSqlSuccess(): void { $globalConfig_input = [ @@ -33,6 +35,7 @@ public function testSqlSuccess(): void unlink('/tmp/test.sqlite'); } + #[RequiresOperatingSystem('Linux')] public function testSqlFailure(): void { $globalConfig_input = [ diff --git a/tests/src/TestConfigurationTest.php b/tests/src/TestConfigurationTest.php index 1b07ea2..231d9a7 100644 --- a/tests/src/TestConfigurationTest.php +++ b/tests/src/TestConfigurationTest.php @@ -59,7 +59,7 @@ public function testTestConfiguration(): void $metadataConfig['saml20-idp-remote'], ); - $this->assertNotEmpty($testConf->getAvailableApacheModules()); + //$this->assertNotEmpty($testConf->getAvailableApacheModules()); $this->assertNotEmpty($testConf->getAvailablePhpModules()); } }