mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 10:44:26 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@50954 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -16,24 +16,15 @@ class Tests_XMLRPC_Basic extends WP_XMLRPC_UnitTestCase {
|
||||
$this->assertSame( 403, $result->code );
|
||||
}
|
||||
|
||||
function test_disabled() {
|
||||
add_filter( 'xmlrpc_enabled', '__return_false' );
|
||||
|
||||
$result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'username', 'password' ) );
|
||||
|
||||
$this->assertIXRError( $result );
|
||||
$this->assertSame( 405, $result->code );
|
||||
}
|
||||
|
||||
function test_login_pass_ok() {
|
||||
$user_id = $this->make_user_by_role( 'subscriber' );
|
||||
$this->make_user_by_role( 'subscriber' );
|
||||
|
||||
$this->assertTrue( $this->myxmlrpcserver->login_pass_ok( 'subscriber', 'subscriber' ) );
|
||||
$this->assertInstanceOf( 'WP_User', $this->myxmlrpcserver->login( 'subscriber', 'subscriber' ) );
|
||||
}
|
||||
|
||||
function test_login_pass_bad() {
|
||||
$user_id = $this->make_user_by_role( 'subscriber' );
|
||||
$this->make_user_by_role( 'subscriber' );
|
||||
|
||||
$this->assertFalse( $this->myxmlrpcserver->login_pass_ok( 'username', 'password' ) );
|
||||
$this->assertFalse( $this->myxmlrpcserver->login( 'username', 'password' ) );
|
||||
@@ -117,4 +108,13 @@ class Tests_XMLRPC_Basic extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
$this->assertXmlStringEqualsXmlString( $return, $value->getXML() );
|
||||
}
|
||||
|
||||
function test_disabled() {
|
||||
add_filter( 'xmlrpc_enabled', '__return_false' );
|
||||
$testcase_xmlrpc_server = new wp_xmlrpc_server();
|
||||
$result = $testcase_xmlrpc_server->wp_getOptions( array( 1, 'username', 'password' ) );
|
||||
|
||||
$this->assertIXRError( $result );
|
||||
$this->assertSame( 405, $result->code );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user