@@ 437-450 (lines=14) @@ | ||
434 | * |
|
435 | * @return array |
|
436 | */ |
|
437 | public function intercept_validate_tokens_request_failed( $response, $args, $url ) { |
|
438 | if ( false === strpos( $url, 'jetpack-token-health' ) ) { |
|
439 | return $response; |
|
440 | } |
|
441 | ||
442 | return array( |
|
443 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
444 | 'body' => wp_json_encode( array( 'dummy_error' => true ) ), |
|
445 | 'response' => array( |
|
446 | 'code' => 500, |
|
447 | 'message' => 'failed', |
|
448 | ), |
|
449 | ); |
|
450 | } |
|
451 | ||
452 | /** |
|
453 | * Build the response for a tokens validation request |
|
@@ 504-517 (lines=14) @@ | ||
501 | * |
|
502 | * @return array |
|
503 | */ |
|
504 | public function intercept_refresh_blog_token_request( $response, $args, $url ) { |
|
505 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
506 | return $response; |
|
507 | } |
|
508 | ||
509 | return array( |
|
510 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
511 | 'body' => wp_json_encode( array( 'jetpack_secret' => self::BLOG_TOKEN ) ), |
|
512 | 'response' => array( |
|
513 | 'code' => 200, |
|
514 | 'message' => 'OK', |
|
515 | ), |
|
516 | ); |
|
517 | } |
|
518 | ||
519 | /** |
|
520 | * Intercept the `jetpack-refresh-blog-token` API request sent to WP.com, and mock the failure response. |
|
@@ 528-541 (lines=14) @@ | ||
525 | * |
|
526 | * @return array |
|
527 | */ |
|
528 | public function intercept_refresh_blog_token_request_fail( $response, $args, $url ) { |
|
529 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
530 | return $response; |
|
531 | } |
|
532 | ||
533 | return array( |
|
534 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
535 | 'body' => wp_json_encode( array( 'jetpack_secret_missing' => true ) ), // Meaningless body. |
|
536 | 'response' => array( |
|
537 | 'code' => 200, |
|
538 | 'message' => 'OK', |
|
539 | ), |
|
540 | ); |
|
541 | } |
|
542 | ||
543 | /** |
|
544 | * Intercept the `jetpack-token-health` API request sent to WP.com, and mock the "invalid blog token" response. |
@@ 193-206 (lines=14) @@ | ||
190 | * |
|
191 | * @return array |
|
192 | */ |
|
193 | public function intercept_jetpack_token_health_request_failed( $response, $args, $url ) { |
|
194 | if ( false === strpos( $url, 'jetpack-token-health' ) ) { |
|
195 | return $response; |
|
196 | } |
|
197 | ||
198 | return array( |
|
199 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
200 | 'body' => wp_json_encode( array( 'dummy_error' => true ) ), |
|
201 | 'response' => array( |
|
202 | 'code' => 500, |
|
203 | 'message' => 'failed', |
|
204 | ), |
|
205 | ); |
|
206 | } |
|
207 | ||
208 | /** |
|
209 | * Intercept the `jetpack-token-health` API request sent to WP.com, and mock successful response. |