| @@ 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. |
|
| @@ 564-577 (lines=14) @@ | ||
| 561 | * |
|
| 562 | * @return array |
|
| 563 | */ |
|
| 564 | public function intercept_validate_tokens_request_failed( $response, $args, $url ) { |
|
| 565 | if ( false === strpos( $url, 'jetpack-token-health' ) ) { |
|
| 566 | return $response; |
|
| 567 | } |
|
| 568 | ||
| 569 | return array( |
|
| 570 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
| 571 | 'body' => wp_json_encode( array( 'dummy_error' => true ) ), |
|
| 572 | 'response' => array( |
|
| 573 | 'code' => 500, |
|
| 574 | 'message' => 'failed', |
|
| 575 | ), |
|
| 576 | ); |
|
| 577 | } |
|
| 578 | ||
| 579 | /** |
|
| 580 | * Build the response for a tokens validation request |
|
| @@ 631-644 (lines=14) @@ | ||
| 628 | * |
|
| 629 | * @return array |
|
| 630 | */ |
|
| 631 | public function intercept_refresh_blog_token_request( $response, $args, $url ) { |
|
| 632 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
| 633 | return $response; |
|
| 634 | } |
|
| 635 | ||
| 636 | return array( |
|
| 637 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
| 638 | 'body' => wp_json_encode( array( 'jetpack_secret' => self::BLOG_TOKEN ) ), |
|
| 639 | 'response' => array( |
|
| 640 | 'code' => 200, |
|
| 641 | 'message' => 'OK', |
|
| 642 | ), |
|
| 643 | ); |
|
| 644 | } |
|
| 645 | ||
| 646 | /** |
|
| 647 | * Intercept the `jetpack-refresh-blog-token` API request sent to WP.com, and mock the failure response. |
|
| @@ 655-668 (lines=14) @@ | ||
| 652 | * |
|
| 653 | * @return array |
|
| 654 | */ |
|
| 655 | public function intercept_refresh_blog_token_request_fail( $response, $args, $url ) { |
|
| 656 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
| 657 | return $response; |
|
| 658 | } |
|
| 659 | ||
| 660 | return array( |
|
| 661 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
| 662 | 'body' => wp_json_encode( array( 'jetpack_secret_missing' => true ) ), // Meaningless body. |
|
| 663 | 'response' => array( |
|
| 664 | 'code' => 200, |
|
| 665 | 'message' => 'OK', |
|
| 666 | ), |
|
| 667 | ); |
|
| 668 | } |
|
| 669 | ||
| 670 | /** |
|
| 671 | * Intercept the `jetpack-token-health` API request sent to WP.com, and mock the "invalid blog token" response. |
|