mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-06 13:44:30 +00:00
REST API: Adjust unit testes to expect a 401 status code in error responses from permission callbacks when user is not authenticated.
Missed in [42421]. Fixes #42828. git-svn-id: https://develop.svn.wordpress.org/trunk@42423 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -524,7 +524,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
||||
$this->assertFalse( isset( $data['media_details']['sizes']['rest-api-test']['source_url'] ) );
|
||||
}
|
||||
|
||||
public function test_get_item_private_post() {
|
||||
public function test_get_item_private_post_not_authenticated() {
|
||||
wp_set_current_user( 0 );
|
||||
$draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) );
|
||||
$id1 = $this->factory->attachment->create_object(
|
||||
@@ -535,7 +535,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
||||
);
|
||||
$request = new WP_REST_Request( 'GET', '/wp/v2/media/' . $id1 );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$this->assertEquals( 403, $response->get_status() );
|
||||
$this->assertEquals( 401, $response->get_status() );
|
||||
}
|
||||
|
||||
public function test_get_item_inherit_status_with_invalid_parent() {
|
||||
@@ -553,7 +553,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
||||
$this->assertEquals( $attachment_id, $data['id'] );
|
||||
}
|
||||
|
||||
public function test_get_item_auto_status_with_invalid_parent_returns_error() {
|
||||
public function test_get_item_auto_status_with_invalid_parent_not_authenticated_returns_error() {
|
||||
$attachment_id = $this->factory->attachment->create_object(
|
||||
$this->test_file, REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, array(
|
||||
'post_mime_type' => 'image/jpeg',
|
||||
@@ -564,7 +564,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
||||
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/media/%d', $attachment_id ) );
|
||||
$response = $this->server->dispatch( $request );
|
||||
|
||||
$this->assertErrorResponse( 'rest_forbidden', $response, 403 );
|
||||
$this->assertErrorResponse( 'rest_forbidden', $response, 401 );
|
||||
}
|
||||
|
||||
public function test_create_item() {
|
||||
|
||||
Reference in New Issue
Block a user