From 21561ef9d0bd877b6993a1af469c83ad31c04aa4 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Tue, 5 May 2020 13:54:32 +0200 Subject: [PATCH] Move IndexTest to test-framework --- composer.lock | 22 ++++--- tests/www/IndexTest.php | 124 ---------------------------------------- 2 files changed, 14 insertions(+), 132 deletions(-) delete mode 100644 tests/www/IndexTest.php diff --git a/composer.lock b/composer.lock index 2e05e645c..6502c1a37 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2cdc1717baae0d13a9dadae83340bf27", + "content-hash": "521de9afe6edd13fefd674606cb3029d", "packages": [ { "name": "gettext/gettext", @@ -2859,6 +2859,12 @@ "Xdebug", "performance" ], + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + } + ], "time": "2020-03-01T12:26:26+00:00" }, { @@ -4696,16 +4702,16 @@ }, { "name": "simplesamlphp/simplesamlphp-test-framework", - "version": "v0.1.4", + "version": "v0.1.5", "source": { "type": "git", "url": "https://github.com/simplesamlphp/simplesamlphp-test-framework.git", - "reference": "951d6a3113bee3b14355a3ea74763c735c10e157" + "reference": "52b04dc7d65055113e0e2338166304e5a291b1f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/simplesamlphp/simplesamlphp-test-framework/zipball/951d6a3113bee3b14355a3ea74763c735c10e157", - "reference": "951d6a3113bee3b14355a3ea74763c735c10e157", + "url": "https://api.github.com/repos/simplesamlphp/simplesamlphp-test-framework/zipball/52b04dc7d65055113e0e2338166304e5a291b1f0", + "reference": "52b04dc7d65055113e0e2338166304e5a291b1f0", "shasum": "" }, "require": { @@ -4713,7 +4719,7 @@ "phpunit/phpunit": "^8.5|^9.0", "sensiolabs/security-checker": "^6.0", "squizlabs/php_codesniffer": "^3.5", - "vimeo/psalm": "^3.9" + "vimeo/psalm": "^3.11" }, "require-dev": { "ext-curl": "*", @@ -4745,7 +4751,7 @@ "keywords": [ "test-framework" ], - "time": "2020-05-05T11:05:41+00:00" + "time": "2020-05-05T11:53:01+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -5192,7 +5198,7 @@ "ext-curl": "*" }, "platform-overrides": { - "php": "7.2.30" + "php": "7.2.40" }, "plugin-api-version": "1.1.0" } diff --git a/tests/www/IndexTest.php b/tests/www/IndexTest.php deleted file mode 100644 index 1985d8388..000000000 --- a/tests/www/IndexTest.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace SimpleSAML\Test\Web; - -use PHPUnit\Framework\TestCase; -use SimpleSAML\TestUtils\BuiltInServer; - -/** - * Simple test for the www/index.php script. - * - * This test is intended mostly as a demonstration of how to test the public web interface in SimpleSAMLphp. - * - * @author Jaime PĂ©rez Crespo <jaime.perez@uninett.no> - * @package SimpleSAMLphp - */ -class IndexTest extends TestCase -{ - /** - * @var \SimpleSAML\TestUtils\BuiltInServer - */ - protected $server; - - /** - * @var string - */ - protected $server_addr; - - /** - * @var int - */ - protected $server_pid; - - /** - * @var string - */ - protected $shared_file; - - - /** - * The setup method that is run before any tests in this class. - * @return void - */ - protected function setup(): void - { - $this->server = new BuiltInServer('configLoader'); - $this->server_addr = $this->server->start(); - $this->server_pid = $this->server->getPid(); - - $this->shared_file = sys_get_temp_dir() . '/' . $this->server_pid . '.lock'; - @unlink($this->shared_file); // remove it if it exists - } - - - /** - * @param array $config - * @return void - */ - protected function updateConfig(array $config): void - { - @unlink($this->shared_file); - $config = "<?php\n\$config = " . var_export($config, true) . ";\n"; - file_put_contents($this->shared_file, $config); - } - - - /** - * A simple test to make sure the index.php file redirects appropriately to the right URL. - * @return void - */ - public function testRedirection(): void - { - // test most basic redirection - $this->updateConfig([ - 'baseurlpath' => 'http://example.org/simplesaml/' - ]); - $resp = $this->server->get('/index.php', [], [ - CURLOPT_FOLLOWLOCATION => 0, - ]); - $this->assertEquals('302', $resp['code']); - $this->assertEquals( - 'http://example.org/simplesaml/module.php/core/login', - $resp['headers']['Location'] - ); - - // test non-default path and https - $this->updateConfig([ - 'baseurlpath' => 'https://example.org/' - ]); - $resp = $this->server->get('/index.php', [], [ - CURLOPT_FOLLOWLOCATION => 0, - ]); - $this->assertEquals('302', $resp['code']); - $this->assertEquals( - 'https://example.org/module.php/core/login', - $resp['headers']['Location'] - ); - - // test URL guessing - $this->updateConfig([ - 'baseurlpath' => '/simplesaml/' - ]); - $resp = $this->server->get('/index.php', [], [ - CURLOPT_FOLLOWLOCATION => 0, - ]); - $this->assertEquals('302', $resp['code']); - $this->assertEquals( - 'http://' . $this->server_addr . '/simplesaml/module.php/core/login', - $resp['headers']['Location'] - ); - } - - - /** - * The tear down method that is executed after all tests in this class. - * @return void - */ - protected function tearDown(): void - { - unlink($this->shared_file); - $this->server->stop(); - } -} -- GitLab