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-posts-controller.php

    r42056 r42427  
    11301130    }
    11311131
    1132     public function test_get_post_without_permission() {
     1132    public function test_get_post_draft_status_not_authenicated() {
    11331133        $draft_id = $this->factory->post->create( array(
    11341134            'post_status' => 'draft',
     
    11391139        $response = $this->server->dispatch( $request );
    11401140
    1141         $this->assertErrorResponse( 'rest_forbidden', $response, 403 );
     1141        $this->assertErrorResponse( 'rest_forbidden', $response, 401 );
    11421142    }
    11431143
     
    12511251    }
    12521252
    1253     public function test_get_item_read_permission_custom_post_status() {
     1253    public function test_get_item_read_permission_custom_post_status_not_authenticated() {
    12541254        register_post_status( 'testpubstatus', array( 'public' => true ) );
    12551255        register_post_status( 'testprivtatus', array( 'public' => false ) );
     
    12631263        $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
    12641264        $response = $this->server->dispatch( $request );
    1265         $this->assertEquals( 403, $response->get_status() );
     1265        $this->assertEquals( 401, $response->get_status() );
    12661266    }
    12671267
Note: See TracChangeset for help on using the changeset viewer.