| @@ 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. |
|
| @@ 745-758 (lines=14) @@ | ||
| 742 | * |
|
| 743 | * @return array |
|
| 744 | */ |
|
| 745 | public function intercept_validate_tokens_request_failed( $response, $args, $url ) { |
|
| 746 | if ( false === strpos( $url, 'jetpack-token-health' ) ) { |
|
| 747 | return $response; |
|
| 748 | } |
|
| 749 | ||
| 750 | return array( |
|
| 751 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
| 752 | 'body' => wp_json_encode( array( 'dummy_error' => true ) ), |
|
| 753 | 'response' => array( |
|
| 754 | 'code' => 500, |
|
| 755 | 'message' => 'failed', |
|
| 756 | ), |
|
| 757 | ); |
|
| 758 | } |
|
| 759 | ||
| 760 | /** |
|
| 761 | * Build the response for a tokens validation request |
|
| @@ 812-825 (lines=14) @@ | ||
| 809 | * |
|
| 810 | * @return array |
|
| 811 | */ |
|
| 812 | public function intercept_refresh_blog_token_request( $response, $args, $url ) { |
|
| 813 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
| 814 | return $response; |
|
| 815 | } |
|
| 816 | ||
| 817 | return array( |
|
| 818 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
| 819 | 'body' => wp_json_encode( array( 'jetpack_secret' => self::BLOG_TOKEN ) ), |
|
| 820 | 'response' => array( |
|
| 821 | 'code' => 200, |
|
| 822 | 'message' => 'OK', |
|
| 823 | ), |
|
| 824 | ); |
|
| 825 | } |
|
| 826 | ||
| 827 | /** |
|
| 828 | * Intercept the `jetpack-refresh-blog-token` API request sent to WP.com, and mock the failure response. |
|
| @@ 836-849 (lines=14) @@ | ||
| 833 | * |
|
| 834 | * @return array |
|
| 835 | */ |
|
| 836 | public function intercept_refresh_blog_token_request_fail( $response, $args, $url ) { |
|
| 837 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
| 838 | return $response; |
|
| 839 | } |
|
| 840 | ||
| 841 | return array( |
|
| 842 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
| 843 | 'body' => wp_json_encode( array( 'jetpack_secret_missing' => true ) ), // Meaningless body. |
|
| 844 | 'response' => array( |
|
| 845 | 'code' => 200, |
|
| 846 | 'message' => 'OK', |
|
| 847 | ), |
|
| 848 | ); |
|
| 849 | } |
|
| 850 | ||
| 851 | /** |
|
| 852 | * Intercept the `jetpack-token-health` API request sent to WP.com, and mock the "invalid blog token" response. |
|