| @@ 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. | |
| @@ 458-471 (lines=14) @@ | ||
| 455 | * | |
| 456 | * @return array | |
| 457 | */ | |
| 458 | 	public function intercept_validate_tokens_request_failed( $response, $args, $url ) { | |
| 459 | 		if ( false === strpos( $url, 'jetpack-token-health' ) ) { | |
| 460 | return $response; | |
| 461 | } | |
| 462 | ||
| 463 | return array( | |
| 464 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), | |
| 465 | 'body' => wp_json_encode( array( 'dummy_error' => true ) ), | |
| 466 | 'response' => array( | |
| 467 | 'code' => 500, | |
| 468 | 'message' => 'failed', | |
| 469 | ), | |
| 470 | ); | |
| 471 | } | |
| 472 | ||
| 473 | /** | |
| 474 | * Build the response for a tokens validation request | |
| @@ 525-538 (lines=14) @@ | ||
| 522 | * | |
| 523 | * @return array | |
| 524 | */ | |
| 525 | 	public function intercept_refresh_blog_token_request( $response, $args, $url ) { | |
| 526 | 		if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { | |
| 527 | return $response; | |
| 528 | } | |
| 529 | ||
| 530 | return array( | |
| 531 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), | |
| 532 | 'body' => wp_json_encode( array( 'jetpack_secret' => self::BLOG_TOKEN ) ), | |
| 533 | 'response' => array( | |
| 534 | 'code' => 200, | |
| 535 | 'message' => 'OK', | |
| 536 | ), | |
| 537 | ); | |
| 538 | } | |
| 539 | ||
| 540 | /** | |
| 541 | * Intercept the `jetpack-refresh-blog-token` API request sent to WP.com, and mock the failure response. | |
| @@ 549-562 (lines=14) @@ | ||
| 546 | * | |
| 547 | * @return array | |
| 548 | */ | |
| 549 | 	public function intercept_refresh_blog_token_request_fail( $response, $args, $url ) { | |
| 550 | 		if ( false === strpos( $url, 'jetpack-refresh-blog-token' ) ) { | |
| 551 | return $response; | |
| 552 | } | |
| 553 | ||
| 554 | return array( | |
| 555 | 'headers' => new Requests_Utility_CaseInsensitiveDictionary( array( 'content-type' => 'application/json' ) ), | |
| 556 | 'body' => wp_json_encode( array( 'jetpack_secret_missing' => true ) ), // Meaningless body. | |
| 557 | 'response' => array( | |
| 558 | 'code' => 200, | |
| 559 | 'message' => 'OK', | |
| 560 | ), | |
| 561 | ); | |
| 562 | } | |
| 563 | ||
| 564 | /** | |
| 565 | * Intercept the `jetpack-token-health` API request sent to WP.com, and mock the "invalid blog token" response. | |