Make WordPress Core


Ignore:
Timestamp:
05/24/2021 02:17:36 AM (5 years ago)
Author:
peterwilsoncc
Message:

XML-RPC: Set HTTP status code in accordance with the spec.

When the XML-RPC endpoint is enabled, always return a HTTP 200 OK status code in accordance with the XML-RPC specification. Continue to return an HTTP 405 Method Not Allowed status code when the endpoint is disabled.

Props ariskataoka, johnbillion.
Fixes #52958.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/xmlrpc/basic.php

    r49862 r50954  
    1717        }
    1818
    19         function test_disabled() {
    20                 add_filter( 'xmlrpc_enabled', '__return_false' );
    21 
    22                 $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'username', 'password' ) );
    23 
    24                 $this->assertIXRError( $result );
    25                 $this->assertSame( 405, $result->code );
    26         }
    27 
    2819        function test_login_pass_ok() {
    29                 $user_id = $this->make_user_by_role( 'subscriber' );
     20                $this->make_user_by_role( 'subscriber' );
    3021
    3122                $this->assertTrue( $this->myxmlrpcserver->login_pass_ok( 'subscriber', 'subscriber' ) );
     
    3425
    3526        function test_login_pass_bad() {
    36                 $user_id = $this->make_user_by_role( 'subscriber' );
     27                $this->make_user_by_role( 'subscriber' );
    3728
    3829                $this->assertFalse( $this->myxmlrpcserver->login_pass_ok( 'username', 'password' ) );
     
    118109                $this->assertXmlStringEqualsXmlString( $return, $value->getXML() );
    119110        }
     111
     112        function test_disabled() {
     113                add_filter( 'xmlrpc_enabled', '__return_false' );
     114                $testcase_xmlrpc_server = new wp_xmlrpc_server();
     115                $result                 = $testcase_xmlrpc_server->wp_getOptions( array( 1, 'username', 'password' ) );
     116
     117                $this->assertIXRError( $result );
     118                $this->assertSame( 405, $result->code );
     119        }
    120120}
Note: See TracChangeset for help on using the changeset viewer.