| 678 | |
| 679 | /* |
| 680 | * @ticket 57512 |
| 681 | * @covers ::wp_populate_basic_auth_from_authorization_header |
| 682 | */ |
| 683 | public function tests_basic_http_authentication_with_username_and_password() { |
| 684 | // username:password |
| 685 | $_SERVER['HTTP_AUTHORIZATION'] = 'Basic dXNlcm5hbWU6cGFzc3dvcmQ='; |
| 686 | |
| 687 | wp_populate_basic_auth_from_authorization_header(); |
| 688 | |
| 689 | $this->assertSame($_SERVER['PHP_AUTH_USER'], 'username'); |
| 690 | $this->assertSame($_SERVER['PHP_AUTH_PW'], 'password'); |
| 691 | } |
| 692 | |
| 693 | /* |
| 694 | * @ticket 57512 |
| 695 | * @covers ::wp_populate_basic_auth_from_authorization_header |
| 696 | */ |
| 697 | public function tests_basic_http_authentication_with_username_only() { |
| 698 | // username |
| 699 | $_SERVER['HTTP_AUTHORIZATION'] = 'Basic dXNlcm5hbWU='; |
| 700 | |
| 701 | wp_populate_basic_auth_from_authorization_header(); |
| 702 | |
| 703 | $this->assertArrayNotHasKey('PHP_AUTH_USER', $_SERVER); |
| 704 | $this->assertArrayNotHasKey('PHP_AUTH_PW', $_SERVER); |
| 705 | } |
| 706 | |
| 707 | /* |
| 708 | * @ticket 57512 |
| 709 | * @covers ::wp_populate_basic_auth_from_authorization_header |
| 710 | */ |
| 711 | public function tests_basic_http_authentication_with_more_than_2_parts() { |
| 712 | // username:password:foo |
| 713 | $_SERVER['HTTP_AUTHORIZATION'] = 'Basic dXNlcm5hbWU6cGFzc3dvcmQ6Zm9v'; |
| 714 | |
| 715 | wp_populate_basic_auth_from_authorization_header(); |
| 716 | |
| 717 | $this->assertArrayNotHasKey('PHP_AUTH_USER', $_SERVER); |
| 718 | $this->assertArrayNotHasKey('PHP_AUTH_PW', $_SERVER); |
| 719 | } |