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

Fix migration login route output and add tests #595

Merged
merged 3 commits into from
Dec 7, 2018

Conversation

joshcanhelp
Copy link
Contributor

Changes

  • Add WP_Auth0_Options_Generic::reset() to reset all options back to defaults
  • Add dependency injection to WP_Auth0_Routes for the WP_Auth0_Ip_Check class
  • Add error output for migration login route to help with troubleshooting

Testing

  • This change adds unit test coverage
  • This change has been tested on the latest version of the platform/language

Checklist

  • All existing and new tests complete without errors
  • All code quality tools/guidelines in the Contribution guide have been run/followed
  • All active GitHub CI checks have passed - composer pre-commit

@joshcanhelp joshcanhelp added this to the 3.9.0 milestone Dec 1, 2018
@joshcanhelp joshcanhelp changed the title Fix migration route output and add tests Fix migration login route output and add tests Dec 1, 2018
@codecov-io
Copy link

codecov-io commented Dec 1, 2018

Codecov Report

Merging #595 into master will increase coverage by 1.37%.
The diff coverage is 92.85%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master    #595      +/-   ##
===========================================
+ Coverage     31.03%   32.4%   +1.37%     
- Complexity     1306    1309       +3     
===========================================
  Files            54      54              
  Lines          4183    4187       +4     
===========================================
+ Hits           1298    1357      +59     
+ Misses         2885    2830      -55
Impacted Files Coverage Δ Complexity Δ
lib/WP_Auth0_Routes.php 43.88% <92.85%> (+42.4%) 48 <2> (+3) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f9e67e...f2e75c2. Read the comment docs.

Copy link
Member

@cocojoe cocojoe left a comment

Choose a reason for hiding this comment

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

Feedback

@@ -22,11 +37,6 @@ public function setup_rewrites( $force_ws = false ) {

add_rewrite_rule( '^auth0', 'index.php?auth0=1', 'top' );
add_rewrite_rule( '^\.well-known/oauth2-client-configuration', 'index.php?a0_action=oauth2-config', 'top' );

// if ( $force_ws || $this->a0_options->get( 'migration_ws' ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

This is no longer relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cocojoe - It's been commented out for a while, no need to keep in in there.

if ( ! empty( $page ) ) {
switch ( $page ) {
case 'oauth2-config':
$this->oauth2_config();
exit;
case 'migration-ws-login':
$this->migration_ws_login();
exit;
$output = $this->migration_ws_login();
Copy link
Member

Choose a reason for hiding this comment

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

What's going on here that you buffer it and then either echo it or return it? Only appears to be one case that needs to do this? Is the intention to have more since you broke out the if (output) logic later on vs handling in the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All these routes handle execution and, in some cases echo out a string, some just return. I'm combining the behavior into one flow so JSON is echoed and the process exits at the same time. In case the methods need to return instead of echoing, I added that query_var (mostly used for testing at this point but could be helpful in a custom API route).

Copy link
Member

Choose a reason for hiding this comment

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

I still think the code could be tidier for this single use case. However, makes no real odds in terms of execution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of these routes will do the same, just wanted to keep PRs a little more streamlined 👍

cocojoe
cocojoe previously approved these changes Dec 6, 2018
Copy link
Member

@cocojoe cocojoe left a comment

Choose a reason for hiding this comment

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

👍

if ( ! empty( $page ) ) {
switch ( $page ) {
case 'oauth2-config':
$this->oauth2_config();
exit;
case 'migration-ws-login':
$this->migration_ws_login();
exit;
$output = $this->migration_ws_login();
Copy link
Member

Choose a reason for hiding this comment

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

I still think the code could be tidier for this single use case. However, makes no real odds in terms of execution.

@joshcanhelp joshcanhelp merged commit 2a13e9d into master Dec 7, 2018
@joshcanhelp joshcanhelp deleted the fix-migration-error-output branch December 7, 2018 17:59
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants