@@ 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. |
@@ 669-682 (lines=14) @@ | ||
666 | * |
|
667 | * @return array |
|
668 | */ |
|
669 | public function intercept_validate_tokens_request_failed( $response, $args, $url ) { |
|
670 | if ( false === strpos( $url, 'jetpack-token-health' ) ) { |
|
671 | return $response; |
|
672 | } |
|
673 | ||
674 | return array( |
|
675 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
676 | 'body' => wp_json_encode( array( 'dummy_error' => true ) ), |
|
677 | 'response' => array( |
|
678 | 'code' => 500, |
|
679 | 'message' => 'failed', |
|
680 | ), |
|
681 | ); |
|
682 | } |
|
683 | ||
684 | /** |
|
685 | * Build the response for a tokens validation request |
|
@@ 736-749 (lines=14) @@ | ||
733 | * |
|
734 | * @return array |
|
735 | */ |
|
736 | public function intercept_refresh_blog_token_request( $response, $args, $url ) { |
|
737 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
738 | return $response; |
|
739 | } |
|
740 | ||
741 | return array( |
|
742 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
743 | 'body' => wp_json_encode( array( 'jetpack_secret' => self::BLOG_TOKEN ) ), |
|
744 | 'response' => array( |
|
745 | 'code' => 200, |
|
746 | 'message' => 'OK', |
|
747 | ), |
|
748 | ); |
|
749 | } |
|
750 | ||
751 | /** |
|
752 | * Intercept the `jetpack-refresh-blog-token` API request sent to WP.com, and mock the failure response. |
|
@@ 760-773 (lines=14) @@ | ||
757 | * |
|
758 | * @return array |
|
759 | */ |
|
760 | public function intercept_refresh_blog_token_request_fail( $response, $args, $url ) { |
|
761 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
762 | return $response; |
|
763 | } |
|
764 | ||
765 | return array( |
|
766 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
767 | 'body' => wp_json_encode( array( 'jetpack_secret_missing' => true ) ), // Meaningless body. |
|
768 | 'response' => array( |
|
769 | 'code' => 200, |
|
770 | 'message' => 'OK', |
|
771 | ), |
|
772 | ); |
|
773 | } |
|
774 | ||
775 | /** |
|
776 | * Intercept the `jetpack-token-health` API request sent to WP.com, and mock the "invalid blog token" response. |