Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/YOURLS/YOURLS.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author྅༻ Ǭɀħ ༄༆ཉ <ozh@ozh.org>2022-01-09 19:46:21 +0300
committerGitHub <noreply@github.com>2022-01-09 19:46:21 +0300
commit1a7a60760d86d11b677af16e83e16fa3e8f5d662 (patch)
tree0b455bde1bc7188e3ea9ba0b38fe18795d459f38
parent42fd3b85c2d49120f3328c7f77ce4d5c100fcc61 (diff)
Revert 3090 & fix tests (#3188)
-rw-r--r--includes/functions-auth.php3
-rw-r--r--includes/functions-html.php4
-rw-r--r--phpunit.xml.dist1
-rw-r--r--tests/tests/auth/logout.php9
4 files changed, 10 insertions, 7 deletions
diff --git a/includes/functions-auth.php b/includes/functions-auth.php
index 7e2b41de..a18d9626 100644
--- a/includes/functions-auth.php
+++ b/includes/functions-auth.php
@@ -99,7 +99,6 @@ function yourls_is_valid_user() {
// Login form : redirect to requested URL to avoid re-submitting the login form on page reload
if( isset( $_REQUEST['username'] ) && isset( $_REQUEST['password'] ) && isset( $_SERVER['REQUEST_URI'] ) ) {
yourls_redirect( yourls_sanitize_url_safe($_SERVER['REQUEST_URI']) );
- return;
}
}
@@ -126,7 +125,7 @@ function yourls_check_username_password() {
// If login form (not API), check for nonce
if(!yourls_is_API()) {
- yourls_verify_nonce('admin_login', false, '-1');
+ yourls_verify_nonce('admin_login');
}
if( isset( $yourls_user_passwords[ $_REQUEST['username'] ] ) && yourls_check_password_hash( $_REQUEST['username'], $_REQUEST['password'] ) ) {
diff --git a/includes/functions-html.php b/includes/functions-html.php
index 1cb7fa6d..46432f0c 100644
--- a/includes/functions-html.php
+++ b/includes/functions-html.php
@@ -475,7 +475,9 @@ function yourls_die( $message = '', $title = '', $header_code = 200 ) {
if( !yourls_did_action( 'html_footer' ) ) {
yourls_html_footer(false);
}
- die();
+
+ // die with a value in case we're running tests, so PHPUnit doesn't exit with 0 as if success
+ die(1);
}
/**
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 8fee4f84..0c61fbc4 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -32,7 +32,6 @@
<!-- Login -->
<request name="username" value="yourls"/>
<request name="password" value="secret-ci-test"/>
- <server name="REQUEST_URI" value="/"/>
<!-- Install -->
<server name="SERVER_SOFTWARE" value="TRAVIS APACHE"/>
<!-- Stats data -->
diff --git a/tests/tests/auth/logout.php b/tests/tests/auth/logout.php
index 4dde4bcb..5de8c84a 100644
--- a/tests/tests/auth/logout.php
+++ b/tests/tests/auth/logout.php
@@ -8,21 +8,23 @@
class Logout_Func_Tests extends PHPUnit\Framework\TestCase {
protected $backup_get;
+ protected $backup_request;
protected function setUp(): void {
- $this->backup_get = $_GET;
- $_REQUEST['nonce'] = yourls_create_nonce('admin_login');
+ $this->backup_get = $_GET;
+ $this->backup_request = $_REQUEST;
}
protected function tearDown(): void {
$_GET = $this->backup_get;
- yourls_remove_all_actions('pre_yourls_die');
+ $_REQUEST = $this->backup_request;
}
/**
* Check logout procedure - phase 1
*/
public function test_logout_user_is_logged_in() {
+ $_REQUEST['nonce'] = yourls_create_nonce('admin_login');
$valid = yourls_is_valid_user();
$this->assertTrue($valid);
}
@@ -42,6 +44,7 @@ class Logout_Func_Tests extends PHPUnit\Framework\TestCase {
* @depends test_logout_user_logs_out
*/
public function test_logout_user_is_logged_in_back() {
+ $_REQUEST['nonce'] = yourls_create_nonce('admin_login');
$valid = yourls_is_valid_user();
$this->assertTrue( $valid );
}