decode does not allow stubbing for unit test with libraries such as sinon
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, node.js
Hướng nghiên cứu
Bắt đầu bằng cách đọc commit 15a1bc449ab529d540eb9c2be4e093f9f5b0278d và xác định decode được định nghĩa như thế nào trong node-jsonwebtoken. Tái hiện việc gán lại trực tiếp được trình bày trong issue, sau đó xác minh rằng có thể thay đổi decode mà không gặp TypeError và bổ sung coverage cho hành vi đó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Changes to how decode is defined in 9.0.0 (https://github.com/auth0/node-jsonwebtoken/commit/15a1bc449ab529d540eb9c2be4e093f9f5b0278d) prevent it from being altered for unit tests by tools such as sinon, or even direct alteration such as
jwt.decode = function() { return( 'teststring' ); };
As a result errors such as TypeError: Cannot redefine property: decode are thrown in these scenarios.
Other JWT libraries such as jose have added configurable: true to allow this scenario to succeed, which should probably be done here too:
- discussion: https://stackoverflow.com/a/64598197
- fix: https://github.com/panva/jose/commit/6c3b92f4394a5d7092d7336922eda61e311e6f8c
Reproduction
Test code such as
jwt.decode = function() { return( 'teststring' ); };
results in
TypeError: Cannot redefine property
Environment
- Version of this library used:
9.0.0 - Version of the platform or framework used, if applicable:
n/a - Other relevant versions (language, server software, OS, browser):
n/a - Other modules/plugins/libraries that might be involved:
n/a
- Ngôn ngữ chính
- JavaScript
- Star
- 18.2k
- Fork
- 1.3k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của auth0/node-jsonwebtoken
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
auth0/node-jsonwebtoken#1042 · 1 bình luận ·
-
`jwt.sign()` callback is executed twice for "The payload already has an "..." property" errorsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
auth0/node-jsonwebtoken#1000 · 2 bình luận · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
auth0/node-jsonwebtoken#1048 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 65/100
auth0/node-jsonwebtoken#1046 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
auth0/node-jsonwebtoken#1034 ·
Tất cả issue của auth0/node-jsonwebtoken
Issue tương tự
-
Complexity: Small P-Feature: Projects page ready for merge team role: back end/devOps role: front end size: 0.25pt
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 67/100
bellingcat/toolkit#905 ·
-
self-care self-care:docs-build-time-investigator
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 76/100
githubnext/gh-aw-cao#14191 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
effort:low impact:medium RAG status: auto-triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
mastra-ai/mastra#25229 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
sugarlabs/musicblocks#8984 ·
Maintainer thường phản hồi trong vòng 1 ngày