Skip to content

Don't raise UsernamePasswordMissingError if Authorization header present#185

Open
gy-mate wants to merge 5 commits intometaodi:developfrom
gy-mate:session-auth-header
Open

Don't raise UsernamePasswordMissingError if Authorization header present#185
gy-mate wants to merge 5 commits intometaodi:developfrom
gy-mate:session-auth-header

Conversation

@gy-mate
Copy link

@gy-mate gy-mate commented Jul 19, 2025

Also, update the exception message and unit tests.
This eliminates the need for implementing custom auth methods like the one described here: #183 (comment).

Fixes #183.

Also, update the exception message and unit tests.
@gy-mate gy-mate force-pushed the session-auth-header branch from 79f4096 to 2e3ef81 Compare July 20, 2025 00:31
@gy-mate gy-mate marked this pull request as ready for review July 20, 2025 00:32
@gy-mate
Copy link
Author

gy-mate commented Sep 8, 2025

@metaodi Could you please review this PR? Many thanks in advance! :)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts osmapi’s authentication pre-check to allow authenticated requests when a custom requests.Session already provides an Authorization header (e.g., bearer tokens), and updates test expectations for the revised error message (Fixes #183).

Changes:

  • Update OsmApiSession._http_request to treat an Authorization header as sufficient to avoid raising UsernamePasswordMissingError.
  • Revise the UsernamePasswordMissingError message to mention missing username/password and missing Authorization header.
  • Update unit tests to assert the new error message.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
osmapi/http.py Adjusts the “missing credentials” guard to allow session-provided Authorization headers; updates raised message.
tests/node_test.py Updates expected error message; removes session mocking in one test (now less isolated).
tests/changeset_test.py Updates expected error message in multiple no-auth test cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gy-mate
Copy link
Author

gy-mate commented Mar 8, 2026

@metaodi I've implemented all changes that @copilot requested!

# Conflicts:
#	tests/changeset_test.py
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.

OsmApi with a Session & auth header: UsernamePasswordMissingError

2 participants