Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #16 Unit test cases for plugin #19

Merged
merged 48 commits into from
Jan 29, 2020
Merged

Conversation

surajkrsingh
Copy link
Contributor

@surajkrsingh surajkrsingh commented Apr 25, 2019

Fixes #16

Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs scanning turned up:

❗ 2 warnings


hashes-api-scanning skipped

tests/bootstrap.php Outdated Show resolved Hide resolved
tests/bootstrap.php Show resolved Hide resolved
@surajkrsingh surajkrsingh changed the title Work in progress Fixes #16 WIP Unit test cases for plugin Apr 25, 2019
Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs scanning turned up:

🚫 2 errors


hashes-api-scanning skipped

tests/test-class-plugin.php Outdated Show resolved Hide resolved
tests/test-class-plugin.php Show resolved Hide resolved
Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs scanning turned up:

❗ 7 warnings


hashes-api-scanning skipped

tests/test-class-google-auth.php Outdated Show resolved Hide resolved
tests/test-class-google-auth.php Outdated Show resolved Hide resolved
tests/test-class-google-auth.php Outdated Show resolved Hide resolved
tests/test-class-google-auth.php Outdated Show resolved Hide resolved
tests/test-class-google-auth.php Outdated Show resolved Hide resolved
tests/class-utility.php Outdated Show resolved Hide resolved
tests/bootstrap.php Show resolved Hide resolved
Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs scanning turned up:

❗ 2 warnings


hashes-api-scanning skipped

tests/test-class-google-auth.php Outdated Show resolved Hide resolved
tests/test-class-google-auth.php Outdated Show resolved Hide resolved
rtBot
rtBot previously requested changes May 20, 2019
Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs scanning turned up:

🚫 1 error

❗ 2 warnings


hashes-api-scanning skipped

tests/test-class-google-auth.php Outdated Show resolved Hide resolved
tests/test-class-google-auth.php Outdated Show resolved Hide resolved
tests/test-class-google-auth.php Outdated Show resolved Hide resolved
Signed-off-by: Riddhesh Sanghvi <riddhesh237@gmail.com>
Signed-off-by: Riddhesh Sanghvi <riddhesh237@gmail.com>
Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs scanning turned up:

🚫 21 errors

⚠️ 10 warnings


hashes-api-scanning skipped

Posting will continue in further review(s)


}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).


}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).

parent::setUp();
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).

*/
class Test_Plugin extends \WP_UnitTestCase {

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).

$this->assertEquals( $_ENV['custom_key'], Helper::filter_input( INPUT_ENV, 'custom_key' ) );
$this->assertEquals( $_SERVER['HTTP_HOST'], Helper::filter_input( INPUT_SERVER, 'HTTP_HOST' ) );

unset( $_GET['custom_key'], $_POST['custom_key'], $_COOKIE['custom_key'], $_ENV['custom_key'] );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Due to using Batcache, server side based client related logic will not work, use JS instead (WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE).

$this->assertEquals( $_ENV['custom_key'], Helper::filter_input( INPUT_ENV, 'custom_key' ) );
$this->assertEquals( $_SERVER['HTTP_HOST'], Helper::filter_input( INPUT_SERVER, 'HTTP_HOST' ) );

unset( $_GET['custom_key'], $_POST['custom_key'], $_COOKIE['custom_key'], $_ENV['custom_key'] );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Processing form data without nonce verification (WordPress.Security.NonceVerification.Recommended).

$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) );
$this->assertEquals( $_COOKIE['custom_key'], Helper::filter_input( INPUT_COOKIE, 'custom_key' ) );
$this->assertEquals( $_ENV['custom_key'], Helper::filter_input( INPUT_ENV, 'custom_key' ) );
$this->assertEquals( $_SERVER['HTTP_HOST'], Helper::filter_input( INPUT_SERVER, 'HTTP_HOST' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Detected usage of a non-sanitized input variable: $_SERVER['HTTP_HOST'] (WordPress.Security.ValidatedSanitizedInput.InputNotSanitized).

$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) );
$this->assertEquals( $_COOKIE['custom_key'], Helper::filter_input( INPUT_COOKIE, 'custom_key' ) );
$this->assertEquals( $_ENV['custom_key'], Helper::filter_input( INPUT_ENV, 'custom_key' ) );
$this->assertEquals( $_SERVER['HTTP_HOST'], Helper::filter_input( INPUT_SERVER, 'HTTP_HOST' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Detected usage of a possibly undefined superglobal array index: $_SERVER['HTTP_HOST']. Use isset() or empty() to check the index exists before using it (WordPress.Security.ValidatedSanitizedInput.InputNotValidated).


$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) );
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) );
$this->assertEquals( $_COOKIE['custom_key'], Helper::filter_input( INPUT_COOKIE, 'custom_key' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Detected usage of a non-sanitized input variable: $_COOKIE['custom_key'] (WordPress.Security.ValidatedSanitizedInput.InputNotSanitized).


$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) );
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) );
$this->assertEquals( $_COOKIE['custom_key'], Helper::filter_input( INPUT_COOKIE, 'custom_key' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Detected usage of a possibly undefined superglobal array index: $_COOKIE['custom_key']. Use isset() or empty() to check the index exists before using it (WordPress.Security.ValidatedSanitizedInput.InputNotValidated).

Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.


$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) );
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) );
$this->assertEquals( $_COOKIE['custom_key'], Helper::filter_input( INPUT_COOKIE, 'custom_key' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Due to using Batcache, server side based client related logic will not work, use JS instead (WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE).

$_ENV['custom_key'] = 'Values on ENV variable.';

$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) );
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Detected usage of a non-sanitized input variable: $_POST['custom_key'] (WordPress.Security.ValidatedSanitizedInput.InputNotSanitized).

$_ENV['custom_key'] = 'Values on ENV variable.';

$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) );
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Detected usage of a possibly undefined superglobal array index: $_POST['custom_key']. Use isset() or empty() to check the index exists before using it (WordPress.Security.ValidatedSanitizedInput.InputNotValidated).

$_ENV['custom_key'] = 'Values on ENV variable.';

$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) );
$this->assertEquals( $_POST['custom_key'], Helper::filter_input( INPUT_POST, 'custom_key' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Processing form data without nonce verification (WordPress.Security.NonceVerification.Missing).

$_COOKIE['custom_key'] = 'Values on COOKIE variable.';
$_ENV['custom_key'] = 'Values on ENV variable.';

$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Detected usage of a non-sanitized input variable: $_GET['custom_key'] (WordPress.Security.ValidatedSanitizedInput.InputNotSanitized).

$_COOKIE['custom_key'] = 'Values on COOKIE variable.';
$_ENV['custom_key'] = 'Values on ENV variable.';

$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Detected usage of a possibly undefined superglobal array index: $_GET['custom_key']. Use isset() or empty() to check the index exists before using it (WordPress.Security.ValidatedSanitizedInput.InputNotValidated).

$_COOKIE['custom_key'] = 'Values on COOKIE variable.';
$_ENV['custom_key'] = 'Values on ENV variable.';

$this->assertEquals( $_GET['custom_key'], Helper::filter_input( INPUT_GET, 'custom_key' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Processing form data without nonce verification (WordPress.Security.NonceVerification.Recommended).

*/
$_GET['custom_key'] = 'Values on GET variable.';
$_POST['custom_key'] = 'Values on POST variable.';
$_COOKIE['custom_key'] = 'Values on COOKIE variable.';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Due to using Batcache, server side based client related logic will not work, use JS instead (WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE).

$this->assertEquals( '', $output );
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).

*/
class Test_Helper extends \WP_UnitTestCase {

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).

Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.


}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).


}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).

if ( empty( $_redirect_to ) ) {
$this->assertEquals( $state[0], admin_url() );
} else {
$this->assertEquals( $state[0], $_redirect_to );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Variable $_redirect_to is undefined (WordPressVIPMinimum.Variables.VariableAnalysis.UndefinedVariable).

$state = $client_config['state'];
$state = explode( '|', urldecode_deep( $state ) );

if ( empty( $_redirect_to ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Variable $_redirect_to is undefined (WordPressVIPMinimum.Variables.VariableAnalysis.UndefinedVariable).

tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );

// Start up the WP testing environment.
require_once $_tests_dir . '/includes/bootstrap.php';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: File inclusion using variable ($_tests_dir). Probably needs manual inspection (WordPressVIPMinimum.Files.IncludingFile.UsingVariable).

}

// Give access to tests_add_filter() function.
require_once $_tests_dir . '/includes/functions.php';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: File inclusion using variable ($_tests_dir). Probably needs manual inspection (WordPressVIPMinimum.Files.IncludingFile.UsingVariable).

tests/bootstrap.php Outdated Show resolved Hide resolved
inc/classes/class-helper.php Outdated Show resolved Hide resolved
inc/classes/class-helper.php Outdated Show resolved Hide resolved
inc/classes/class-helper.php Outdated Show resolved Hide resolved
rtBot
rtBot previously requested changes Jan 16, 2020
Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

inc/classes/class-helper.php Outdated Show resolved Hide resolved
Signed-off-by: Riddhesh Sanghvi <riddhesh237@gmail.com>
Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs scanning turned up:

⚠️ 1 warning


hashes-api-scanning skipped

tests/bootstrap.php Outdated Show resolved Hide resolved
@deepaklalwani97 deepaklalwani97 dismissed rtBot’s stale review January 20, 2020 06:51

To re trigger review

rtBot
rtBot previously requested changes Jan 20, 2020
Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs scanning turned up:

🚫 5 errors


hashes-api-scanning skipped

tests/test-class-google-auth.php Outdated Show resolved Hide resolved
tests/test-class-google-auth.php Outdated Show resolved Hide resolved
inc/classes/class-google-auth.php Show resolved Hide resolved
inc/classes/class-google-auth.php Outdated Show resolved Hide resolved
inc/classes/class-google-auth.php Outdated Show resolved Hide resolved
rtBot
rtBot previously requested changes Jan 20, 2020
Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs scanning turned up:

🚫 1 error


hashes-api-scanning skipped

inc/classes/class-google-auth.php Outdated Show resolved Hide resolved
@deepaklalwani97 deepaklalwani97 changed the base branch from master to develop January 29, 2020 10:10
@deepaklalwani97 deepaklalwani97 merged commit 9eeb5e6 into develop Jan 29, 2020
@deepaklalwani97 deepaklalwani97 mentioned this pull request Jan 29, 2020
2 tasks
@rahul286 rahul286 deleted the feature/issue-16 branch February 23, 2022 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants