XML-RPC: Emit an appropriate HTTP status code when an error is returned in response to an XML-RPC request.

This most notably affects the response when XML-RPC is disabled or when the supplied username and password is incorrect.

Props ericmann

Fixes #48213


git-svn-id: https://develop.svn.wordpress.org/trunk@49862 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn
2020-12-21 20:21:12 +00:00
parent 6c7bb97313
commit 7ef5a65f44
3 changed files with 16 additions and 2 deletions

View File

@@ -16,6 +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' );