File tree Expand file tree Collapse file tree 2 files changed +5
-11
lines changed
tests/wp-includes/rest-api/auth
wp-includes/rest-api/auth Expand file tree Collapse file tree 2 files changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -233,15 +233,9 @@ public function test_require_token() {
233
233
234
234
// Some GET requests require authentication to work correctly (i.e. – fetching draft posts)
235
235
// If a token is present, treat it as though it's required.
236
- $ mock = $ this ->getMockBuilder ( get_class ( $ this ->token ) )
237
- ->setMethods (
238
- array (
239
- 'validate_token ' ,
240
- )
241
- )
242
- ->getMock ();
243
- $ mock ->method ( 'validate_token ' )->willReturn ( true );
244
- $ this ->assertTrue ( $ mock ->require_token () );
236
+ $ _SERVER ['HTTP_AUTHORIZATION ' ] = 'Bearer: Test ' ;
237
+ $ this ->assertTrue ( $ this ->token ->require_token () );
238
+ unset( $ _SERVER ['HTTP_AUTHORIZATION ' ] );
245
239
246
240
// Don't require authentication to generate a token.
247
241
$ _SERVER ['REQUEST_METHOD ' ] = 'POST ' ;
Original file line number Diff line number Diff line change @@ -275,8 +275,8 @@ public function require_token() {
275
275
// GET requests do not require authentication, but if
276
276
// the Authorization header is provided, requests should
277
277
// be performed as the user corresponding to that token.
278
- if ( 'GET ' === $ request_method && ! is_wp_error ( $ this ->get_auth_header () ) ) {
279
- $ require_token = true ;
278
+ if ( 'GET ' === $ request_method && is_wp_error ( $ this ->get_auth_header () ) ) {
279
+ $ require_token = false ;
280
280
}
281
281
282
282
// Don't require authentication to generate a token.
You can’t perform that action at this time.
0 commit comments