@@ 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. |
@@ 629-642 (lines=14) @@ | ||
626 | * |
|
627 | * @return array |
|
628 | */ |
|
629 | public function intercept_validate_tokens_request_failed( $response, $args, $url ) { |
|
630 | if ( false === strpos( $url, 'jetpack-token-health' ) ) { |
|
631 | return $response; |
|
632 | } |
|
633 | ||
634 | return array( |
|
635 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
636 | 'body' => wp_json_encode( array( 'dummy_error' => true ) ), |
|
637 | 'response' => array( |
|
638 | 'code' => 500, |
|
639 | 'message' => 'failed', |
|
640 | ), |
|
641 | ); |
|
642 | } |
|
643 | ||
644 | /** |
|
645 | * Build the response for a tokens validation request |
|
@@ 696-709 (lines=14) @@ | ||
693 | * |
|
694 | * @return array |
|
695 | */ |
|
696 | public function intercept_refresh_blog_token_request( $response, $args, $url ) { |
|
697 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
698 | return $response; |
|
699 | } |
|
700 | ||
701 | return array( |
|
702 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
703 | 'body' => wp_json_encode( array( 'jetpack_secret' => self::BLOG_TOKEN ) ), |
|
704 | 'response' => array( |
|
705 | 'code' => 200, |
|
706 | 'message' => 'OK', |
|
707 | ), |
|
708 | ); |
|
709 | } |
|
710 | ||
711 | /** |
|
712 | * Intercept the `jetpack-refresh-blog-token` API request sent to WP.com, and mock the failure response. |
|
@@ 720-733 (lines=14) @@ | ||
717 | * |
|
718 | * @return array |
|
719 | */ |
|
720 | public function intercept_refresh_blog_token_request_fail( $response, $args, $url ) { |
|
721 | if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { |
|
722 | return $response; |
|
723 | } |
|
724 | ||
725 | return array( |
|
726 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), |
|
727 | 'body' => wp_json_encode( array( 'jetpack_secret_missing' => true ) ), // Meaningless body. |
|
728 | 'response' => array( |
|
729 | 'code' => 200, |
|
730 | 'message' => 'OK', |
|
731 | ), |
|
732 | ); |
|
733 | } |
|
734 | ||
735 | /** |
|
736 | * Intercept the `jetpack-token-health` API request sent to WP.com, and mock the "invalid blog token" response. |