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

Test/add oauth2 cases #88

Closed
wants to merge 8 commits into from
Closed

Test/add oauth2 cases #88

wants to merge 8 commits into from

Conversation

caputomarcos
Copy link
Owner

Release Notes

Version: [Your Version Number]

Refactor ESLint Configuration and Improve OAuth2 Node Functionality

  • ESLint Configuration Updates:
    • Included Prettier plugin and adjusted rules for consistent code style.
    • Added browser and mocha environments.
  • OAuth2 Node Enhancements:
    • Removed unused crypto and circular reference replacer from oauth2.js.
    • Simplified axios POST request logic and added proxy support.
    • Included response headers in the message payload for better context.
    • Adjusted tests to reflect changes in oauth2.js and reduced timeout for faster execution.
    • Added new test cases for handling different grant types, network failures, custom headers, multiple scopes, and proxy settings.

Update Dependencies and Refactor OAuth2 Node

  • OAuth2 Node Improvements:
    • Updated oauth2.js to handle additional edge cases and improve error handling.
    • Refactored logger.js for better readability and consistency.
    • Added new test cases in oauth2_spec.js to cover more scenarios and ensure robustness.
    • Removed unused dependencies and cleaned up package.json and yarn.lock files.
    • Adjusted package.json scripts to include a new coverage script for test coverage reporting.

Refactor oauth2.json and oauth2.html for Clarity and Add Debug Mode

  • Configuration Enhancements:
    • Added tips for debug mode, client credentials, and rejectUnauthorized in oauth2.json.
    • Updated labels in oauth2.html to be more concise.
    • Introduced a debug mode checkbox with corresponding help information.
  • Logging Improvements:
    • Removed logger.js and integrated logging directly into oauth2.js.
    • Toggled debug mode via node configuration.
    • Included more descriptive logging messages to aid in debugging.

Add Refresh Token Support and Refactor OAuth2 Node Options

  • Refresh Token Flow:
    • Added a refresh_token field in oauth2.html.
    • Updated oauth2.js to handle the new refresh token flow.
    • Refactored the generateOptions function in oauth2.js for better readability and maintainability.
    • Enhanced localization file oauth2.json to include the new refresh token field.

Update Dependencies and Adjust Code for Compatibility

  • Dependency Updates:
    • Updated axios, eslint, and prettier to their latest versions.
    • Adjusted eslint configuration to accommodate updated eslint-plugin-n and eslint-plugin-jsdoc.
    • Modified Logger.prototype.objectDump method to handle invalid objects more gracefully.

Remove Unused 'should' Require in oauth2-generate-options Tests

  • Removed the unnecessary require statement for the 'should' library in oauth2-generate-options_spec.js.

Improve Error Handling and Remove Unused URL Import in oauth2.js

  • Error Handling Improvements:
    • Removed unused URL import.
    • Added URLSearchParams import for handling form data.
    • Wrapped credentials retrieval in a try-catch block to handle potential errors.
    • Adjusted response status codes: 404 for missing credentials, 500 for server errors, and 400 for missing credentials in token exchange endpoint.
    • Updated success HTML response to use proper indentation and formatting.

 - Update ESLint configuration to include Prettier plugin and adjust rules for code style consistency.
 - Add browser and mocha environments to ESLint configuration.
 - Remove unused crypto and circular reference replacer from oauth2.js.
 - Simplify axios POST request logic and add proxy support in OAuth2 node.
 - Include response headers in the message payload for better context.
 - Adjust tests to reflect changes in oauth2.js and reduce timeout for faster test execution.
 - Add new test cases for handling different grant types, network failures, custom headers, multiple scopes, and proxy settings.
 - Updated the `oauth2.js` node to handle additional edge cases and improve error handling.
 - Refactored `logger.js` for better readability and consistency.
 - Added new test cases in `oauth2_spec.js` to cover more scenarios and ensure robustness.
 - Removed unused dependencies and cleaned up `package.json` and `yarn.lock` files.
 - Adjusted the `package.json` scripts to include a new `coverage` script for test coverage reporting.
 This commit introduces several changes to improve the clarity and functionality of the oauth2 configuration. In the oauth2.json locale file, the tips for debug mode, client credentials, and
 rejectUnauthorized have been added, and the labels have been updated to be more concise. The oauth2.html file has been updated to include a new debug mode checkbox with corresponding help information, a
 the labels for client credentials and rejectUnauthorized have been adjusted to match the updated locale file.

 Additionally, the logger.js file has been removed as it appears to be no longer needed, and the corresponding references to the logger have been added to the oauth2.js file to incorporate logging
 functionality directly within the OAuth2 node implementation. The debug mode can now be toggled via the node configuration, and the logger is initialized with the debug setting from the config.

 Lastly, the oauth2.js file has been refactored to include more descriptive logging messages that will aid in debugging and understanding the flow of the OAuth2 node's operations.
 This commit introduces several changes to the oauth2 node configuration and handling of OAuth2 flows. The primary addition is the support for the refresh token grant type, which allows the node to obtai
 new access tokens using a refresh token.

 Key changes include:
 - Added a new `refresh_token` field in the oauth2.html file to allow users to input their refresh token.
 - Updated oauth2.js to handle the new refresh token flow, including generating the appropriate form data and handling the client credentials.
 - Refactored the `generateOptions` function in oauth2.js to improve readability and maintainability. The function now uses a mapping of grant type to specific handling functions.
 - Updated the logger.js to allow for an undefined `count` parameter, which means logging will not be limited unless specified.
 - Enhanced the localization file (oauth2.json) to include the new refresh token field.

 These changes aim to enhance the node-red-contrib-oauth2 package by providing a more comprehensive and user-friendly OAuth2 implementation.
 This commit updates several dependencies to their latest versions, including axios, eslint, and prettier. It also includes adjustments to the codebase to ensure compatibility with the updated
 dependencies. Notably, the eslint-plugin-n and eslint-plugin-jsdoc have been updated, which required changes to the eslint configuration. Additionally, the Logger.prototype.objectDump method in logger.j
 has been modified to handle invalid objects more gracefully.
 The 'should' library was included in the oauth2-generate-options_spec.js file but was not being used. This commit removes the unnecessary require statement to clean up the code.
 - Removed the unused URL import from oauth2.js.
 - Added URLSearchParams import for handling form data.
 - Wrapped the credentials retrieval in a try-catch block to handle potential errors.
 - Changed the response status code to 404 when credentials are not found.
 - Changed the response status code to 500 for server errors.
 - Updated the success HTML response to use proper indentation and formatting.
 - Changed the response status code to 400 when credentials are missing in the token exchange endpoint.
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.

1 participant