| @@ 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. |
|
| @@ 647-660 (lines=14) @@ | ||
| 644 | * |
|
| 645 | * @return array |
|
| 646 | */ |
|
| 647 | public function intercept_validate_tokens_request_failed( $response, $args, $url ) { |
|
| 648 | if ( false === strpos( $url, 'jetpack-token-health' ) ) { |
|
| 649 | return $response; |
|
| 650 | } |
|
| 651 | ||
| 652 | return array( |
|
| 653 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
| 654 | 'body' => wp_json_encode( array( 'dummy_error' => true ) ), |
|
| 655 | 'response' => array( |
|
| 656 | 'code' => 500, |
|
| 657 | 'message' => 'failed', |
|
| 658 | ), |
|
| 659 | ); |
|
| 660 | } |
|
| 661 | ||
| 662 | /** |
|
| 663 | * Build the response for a tokens validation request |
|
| @@ 714-727 (lines=14) @@ | ||
| 711 | * |
|
| 712 | * @return array |
|
| 713 | */ |
|
| 714 | public function intercept_refresh_blog_token_request( $response, $args, $url ) { |
|
| 715 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
| 716 | return $response; |
|
| 717 | } |
|
| 718 | ||
| 719 | return array( |
|
| 720 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
| 721 | 'body' => wp_json_encode( array( 'jetpack_secret' => self::BLOG_TOKEN ) ), |
|
| 722 | 'response' => array( |
|
| 723 | 'code' => 200, |
|
| 724 | 'message' => 'OK', |
|
| 725 | ), |
|
| 726 | ); |
|
| 727 | } |
|
| 728 | ||
| 729 | /** |
|
| 730 | * Intercept the `jetpack-refresh-blog-token` API request sent to WP.com, and mock the failure response. |
|
| @@ 738-751 (lines=14) @@ | ||
| 735 | * |
|
| 736 | * @return array |
|
| 737 | */ |
|
| 738 | public function intercept_refresh_blog_token_request_fail( $response, $args, $url ) { |
|
| 739 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
| 740 | return $response; |
|
| 741 | } |
|
| 742 | ||
| 743 | return array( |
|
| 744 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
| 745 | 'body' => wp_json_encode( array( 'jetpack_secret_missing' => true ) ), // Meaningless body. |
|
| 746 | 'response' => array( |
|
| 747 | 'code' => 200, |
|
| 748 | 'message' => 'OK', |
|
| 749 | ), |
|
| 750 | ); |
|
| 751 | } |
|
| 752 | ||
| 753 | /** |
|
| 754 | * Intercept the `jetpack-token-health` API request sent to WP.com, and mock the "invalid blog token" response. |
|