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

Add Management API framework #537

Merged
merged 1 commit into from
Sep 26, 2018
Merged

Conversation

joshcanhelp
Copy link
Contributor

@joshcanhelp joshcanhelp commented Sep 18, 2018

Create a more clear, complete, and easy-to-use access to the Management API, including better error logging when things go wrong.

  • Add WP_Auth0_Api_Abstract abstract class to provide a wrapper around the WP HTTP class. This can be extended to add Management API endpoints more easily with built-in error handling.
  • Add WP_Auth0_Api_Client_Credentials to perform a Client Credentials grant for API calls
  • Add WP_Auth0_Api_Jobs_Verification to perform re-send email functionality (mainly to show how the framework is used).
  • Refactor WP_Auth0_Email_Verification to use the new API framework, provide better error responses.
  • Add multiple test classes and helper traits to test this framework and the resend email functionality, including the ability to halt or mock API calls for examination.
  • Marked unused or soon-to-be-replaced methods in WP_Auth0_Api_Client as TODO for deprecation.

Note to reviewers

This is a large PR but almost 60% of code added is related to testing.

@joshcanhelp joshcanhelp force-pushed the add-management-api-framework branch from 92983ab to be1b8da Compare September 18, 2018 23:29
@@ -508,6 +508,7 @@ private function autoloader( $class ) {
$paths = array(
$source_dir,
$source_dir . 'admin/',
$source_dir . 'api/',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add new directory to auto-load from.

),
);
return array( 'Auth0-Client' => base64_encode( wp_json_encode( $header_value ) ) );
return WP_Auth0_Api_Abstract::get_info_headers();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Returns an identical array.

*
* @param WP_Auth0_Api_Jobs_Verification $api_jobs_resend - WP_Auth0_Api_Jobs_Verification instance.
*/
public function __construct( WP_Auth0_Api_Jobs_Verification $api_jobs_resend ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add dependency injection.

@auth0 auth0 deleted a comment from codecov-io Sep 19, 2018
@joshcanhelp joshcanhelp force-pushed the add-management-api-framework branch from ea1cc17 to 3d649e5 Compare September 21, 2018 22:52
@auth0 auth0 deleted a comment from codecov-io Sep 21, 2018
@joshcanhelp joshcanhelp added this to the v3-Next milestone Sep 21, 2018
@joshcanhelp joshcanhelp force-pushed the add-management-api-framework branch from 3d649e5 to e253e5f Compare September 24, 2018 16:34
@auth0 auth0 deleted a comment from codecov-io Sep 25, 2018
@joshcanhelp joshcanhelp force-pushed the add-management-api-framework branch from 13c0f3b to 41a16f1 Compare September 25, 2018 16:53
@@ -120,6 +120,14 @@ public static function ro( $domain, $client_id, $username, $password, $connectio

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of the changes in this file are doc blocks to add TODOs for deprecation.

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.

Looks good in general, the abstraction is good and more tests is great.


/**
* Class WP_Auth0_Email_Verification
* Class WP_Auth0_Email_Verification.
Copy link
Member

Choose a reason for hiding this comment

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

In general some of these comments seem a little superfluous.

@joshcanhelp joshcanhelp force-pushed the add-management-api-framework branch from 41a16f1 to fc5c23c Compare September 26, 2018 19:48
@auth0 auth0 deleted a comment from codecov-io Sep 26, 2018
@joshcanhelp joshcanhelp merged commit 38dab4f into dev Sep 26, 2018
@joshcanhelp joshcanhelp deleted the add-management-api-framework branch September 26, 2018 19:54
@joshcanhelp joshcanhelp changed the title Add Management API framework [WIP] Add Management API framework Dec 17, 2018
@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.

2 participants