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: added test for Video Room, fix: resolved conflict of duplicated names, enhanced code of 'time' logic #845

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

NHV4546
Copy link

@NHV4546 NHV4546 commented Feb 25, 2025

feat(jwt): Improve JWT expiration handling and fix naming conflicts

  • Replaced time.time() with datetime.datetime.utcnow() to ensure accurate expiration handling.
  • Used datetime.timedelta(seconds=...) for better timestamp calculations.
  • Ensured compatibility with jwt.encode() by converting expiration times using .timestamp().
  • Renamed algorithm to jwt_algorithm to avoid conflicts with the ALGORITHM constant and ensure consistency.

test(twilio): Add unit test for Twilio Video Room creation

  • Integrated unittest framework for structured testing.
  • Used responses library to mock Twilio API calls.
  • Implemented a test case that validates room creation by checking sid, unique_name, and status.

These changes enhance JWT handling, resolve potential naming conflicts, and introduce automated testing for Twilio API interactions.

Fixes #777

Summary of Changes

This PR addresses the following improvements:

  • Fix for Issue Code Enhancement #777 (JWT Expiration Handling):

    • Replaced time.time() with datetime.datetime.utcnow() to ensure accurate expiration calculations.
    • Applied datetime.timedelta(seconds=...) to improve timestamp consistency.
    • Ensured compatibility with jwt.encode() by converting expiration times using .timestamp().
    • These changes improve time handling accuracy, ensuring JWTs expire correctly across different time zones.
  • Resolved SonarCloud issue (Naming Conflict with ALGORITHM):

    • Renamed algorithm parameter to jwt_algorithm to prevent confusion with the ALGORITHM constant.
    • This improves maintainability by avoiding case-sensitive conflicts in variable names.
  • Added a new unit test for Twilio Video Room creation:

    • Integrated unittest framework for structured testing.
    • Mocked Twilio API calls using the responses library.
    • Verified room creation by checking sid, unique_name, and status.
    • Note: Existing tests already cover the JWT expiration fix, so no additional tests were needed for that.

Checklist

  • I acknowledge that all my contributions will be made under the project's license.
  • I have made a material change to the repo (functionality, testing, spelling, grammar).
  • I have read the Contribution Guidelines and my PR follows them.
  • I have titled the PR appropriately.
  • I have updated my branch with the main branch.
  • I have added inline documentation to the code I modified.
  • I have added tests that prove my fix is effective or that my feature works (not required, as existing tests already cover the fix).
  • I have added the necessary documentation about the functionality in the appropriate .md file (not required).

If you have questions, please file a support ticket, or create a GitHub Issue in this repository.

Dina Samatova added 2 commits February 25, 2025 10:47
…aming conflict, and add Twilio Video Room test

- Improved JWT expiration logic:
  - Replaced time.time() with datetime.datetime.utcnow() to ensure more accurate expiration handling.
  - Applied datetime.timedelta(seconds=...) for better timestamp calculations.
  - Ensured compatibility with jwt.encode() by converting expiration times using .timestamp().

- Resolved naming issue between ALGORITHM and algorithm:
  - Renamed the algorithm parameter to jwt_algorithm to avoid conflicts with the ALGORITHM constant.
  - Updated all references to maintain consistency throughout the class.

- Added unit test for Twilio Video Room creation:
  - Integrated unittest framework for structured testing.
  - Used responses library to mock Twilio API calls.
  - Implemented a test case that validates room creation by checking sid, unique_name, and status.

These updates improve JWT handling, fix potential naming conflicts, and introduce automated testing for Twilio API interactions.
@NHV4546 NHV4546 changed the title Added test for Video Room, resolved conflict of duplicated names, enhanced code of 'time' logic test: added test for Video Room, fix: resolved conflict of duplicated names, enhanced code of 'time' logic Feb 25, 2025
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.

Code Enhancement
1 participant