Make WordPress Core


Ignore:
Timestamp:
01/01/2018 02:30:39 AM (7 years ago)
Author:
rachelbaker
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r42343 r42423  
    525525    }
    526526
    527     public function test_get_item_private_post() {
     527    public function test_get_item_private_post_not_authenticated() {
    528528        wp_set_current_user( 0 );
    529529        $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) );
     
    536536        $request    = new WP_REST_Request( 'GET', '/wp/v2/media/' . $id1 );
    537537        $response   = $this->server->dispatch( $request );
    538         $this->assertEquals( 403, $response->get_status() );
     538        $this->assertEquals( 401, $response->get_status() );
    539539    }
    540540
     
    554554    }
    555555
    556     public function test_get_item_auto_status_with_invalid_parent_returns_error() {
     556    public function test_get_item_auto_status_with_invalid_parent_not_authenticated_returns_error() {
    557557        $attachment_id = $this->factory->attachment->create_object(
    558558            $this->test_file, REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, array(
     
    565565        $response      = $this->server->dispatch( $request );
    566566
    567         $this->assertErrorResponse( 'rest_forbidden', $response, 403 );
     567        $this->assertErrorResponse( 'rest_forbidden', $response, 401 );
    568568    }
    569569
Note: See TracChangeset for help on using the changeset viewer.