Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dni
Copy link
Member

@dni dni commented Mar 21, 2024

  • refactor KeyChecker to be more approachable
  • only 1 sql query needed even if you use get_key_type
  • rename WalletType to KeyType wallet type was misleading

@dni dni force-pushed the fix-duplicated-keychecker branch from 4b5a895 to 27dc00a Compare March 21, 2024 14:57
@codecov
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 93.54839% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 61.61%. Comparing base (9f8942a) to head (9fa969c).

Files Patch % Lines
lnbits/decorators.py 92.30% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2339      +/-   ##
==========================================
- Coverage   61.65%   61.61%   -0.05%     
==========================================
  Files          68       68              
  Lines        9720     9681      -39     
==========================================
- Hits         5993     5965      -28     
+ Misses       3727     3716      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dni dni force-pushed the fix-duplicated-keychecker branch 2 times, most recently from ce20c93 to 0cca7b3 Compare March 21, 2024 16:42
@dni dni marked this pull request as ready for review March 21, 2024 16:42
@dni dni force-pushed the fix-duplicated-keychecker branch from aea699c to 6bb4fd6 Compare March 22, 2024 12:21
@dni dni added this to the 0.12.4 milestone Mar 22, 2024
@dni dni force-pushed the fix-duplicated-keychecker branch 2 times, most recently from a57cf79 to 2a9f0bd Compare March 28, 2024 09:48
@dni dni modified the milestones: 0.12.5, 0.12.6 Apr 11, 2024
@dni dni force-pushed the fix-duplicated-keychecker branch 2 times, most recently from 24c040e to f8942b8 Compare April 17, 2024 11:14
- refactor KeyChecker to be more approachable
- only 1 sql query needed even if you use `get_key_type`
- rename `WalletType` to `KeyType` wallet type was misleading

fix test

sorting
@dni dni force-pushed the fix-duplicated-keychecker branch from f8942b8 to f4ad2cc Compare May 10, 2024 15:48
},
)
assert response.status_code == 404
assert response.status_code == 401
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • add assertion for delete with invoice key:
    response = await client.delete(
        "/api/v1/wallet",
        headers={
            "X-Api-Key": result["inkey"],
            "Content-type": "application/json",
        },
    )

key_value = (
self._api_key
if self._api_key
else request.headers.get("X-API-KEY") or request.query_params["api-key"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

A bit inconsistent:

  • if request.query_params is missing then an exception is raised and HTTP 400 (BAD_REQUEST) is returned
  • but if request.query_params is None or "" then an HTTP 401 (UNAUTHORIZED) is returned
Suggested change
else request.headers.get("X-API-KEY") or request.query_params["api-key"]
else request.headers.get("X-API-KEY") or request.query_paramsget("api-key")

Copy link
Collaborator

Choose a reason for hiding this comment

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

as a consequence the catch block should catch a generic Exception and return an Internal Server Error

async def test_put_empty_request_expected_admin_keys(client):
response = await client.put("/api/v1/wallet/newwallet")
assert response.status_code == 401
assert response.status_code == 400
Copy link
Collaborator

Choose a reason for hiding this comment

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

async def test_post_empty_request_expected_invoice_keys(client):
response = await client.post("/api/v1/payments")
assert response.status_code == 401
assert response.status_code == 400
Copy link
Collaborator

Choose a reason for hiding this comment

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

@arcbtc arcbtc merged commit 6730c6e into dev May 13, 2024
@arcbtc arcbtc deleted the fix-duplicated-keychecker branch May 13, 2024 14:26
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.

3 participants