Make WordPress Core


Ignore:
Timestamp:
01/06/2018 07:28:44 PM (7 years ago)
Author:
rachelbaker
Message:

EST API: Adjust unit testes to expect a 401 status code in error responses from permission callbacks when user is not authenticated.

Missed in [42421].

Merges [42423] to the 4.9 branch.
Fixes #42828.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r40306 r42427  
    469469    }
    470470
    471     public function test_get_item_private_post() {
     471    public function test_get_item_private_post_not_authenticated() {
    472472        wp_set_current_user( 0 );
    473473        $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) );
     
    478478        $request = new WP_REST_Request( 'GET', '/wp/v2/media/' . $id1 );
    479479        $response = $this->server->dispatch( $request );
    480         $this->assertEquals( 403, $response->get_status() );
     480        $this->assertEquals( 401, $response->get_status() );
    481481    }
    482482
     
    494494    }
    495495
    496     public function test_get_item_auto_status_with_invalid_parent_returns_error() {
     496    public function test_get_item_auto_status_with_invalid_parent_not_authenticated_returns_error() {
    497497        $attachment_id = $this->factory->attachment->create_object( $this->test_file, REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, array(
    498498            'post_mime_type' => 'image/jpeg',
     
    503503        $response = $this->server->dispatch( $request );
    504504
    505         $this->assertErrorResponse( 'rest_forbidden', $response, 403 );
     505        $this->assertErrorResponse( 'rest_forbidden', $response, 401 );
    506506    }
    507507
Note: See TracChangeset for help on using the changeset viewer.