HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33
System: Linux li317-225.members.linode.com 3.10.0-1062.12.1.el7.x86_64 #1 SMP Tue Feb 4 23:02:59 UTC 2020 x86_64
User: apache (48)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //usr/share/phpMyAdmin/test/libraries/core/PMA_checkPageValidity_test.php
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Tests for PMA_checkPageValidity() from libraries/core.lib.php
 *
 * @package PhpMyAdmin-test
 */

/*
 * Include to test.
 */
require_once 'libraries/core.lib.php';

/**
 * Tests for PMA_checkPageValidity() from libraries/core.lib.php
 *
 * @package PhpMyAdmin-test
 */
class PMA_CheckPageValidity_Test extends PHPUnit_Framework_TestCase
{
    protected $goto_whitelist = array(
        'db_create.php',
        'db_datadict.php',
        'db_sql.php',
        'db_export.php',
        'db_search.php',
        'export.php',
        'import.php',
        'index.php',
        'pdf_pages.php',
        'pdf_schema.php',
        'server_binlog.php',
        'server_variables.php',
        'sql.php',
        'tbl_select.php',
        'transformation_overview.php',
        'transformation_wrapper.php',
        'user_password.php',
    );

    /**
     * Test for PMA_checkPageValidity
     *
     * @param string     $page      Page
     * @param array|null $whiteList White list
     * @param int        $expected  Expected value
     *
     * @return void
     *
     * @dataProvider provider
     */
    function testGotoNowhere($page, $whiteList, $expected)
    {
        $this->assertTrue($expected === PMA_checkPageValidity($page, $whiteList));
    }

    /**
     * Data provider for testGotoNowhere
     *
     * @return array
     */
    public function provider()
    {
        return array(
            array(null, null, false),
            array('export.php', $this->goto_whitelist, true),
            array('shell.php', $this->goto_whitelist, false),
            array('index.php?sql.php&test=true', $this->goto_whitelist, true),
            array('index.php%3Fsql.php%26test%3Dtrue', $this->goto_whitelist, true),
        );
    }
}