-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add service account authentication support #6
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -192,6 +192,18 @@ def _load_credentials(self): | |||||||||
| if self.userless_mode: | ||||||||||
| return | ||||||||||
|
|
||||||||||
| # Check for Service Account first (bypasses cache) | ||||||||||
| key_path = self.options.get('service_account') | ||||||||||
| if key_path: | ||||||||||
| self.printer.debug_msg(f'Loading Service Account from {key_path}\n') | ||||||||||
|
||||||||||
| self.printer.debug_msg(f'Loading Service Account from {key_path}\n') | |
| self.printer.debug_msg( | |
| f'Loading Service Account from {utils.shorten_path(key_path)}\n' | |
| ) |
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrapping all exceptions here loses the original traceback, which makes service-account failures harder to debug. Consider exception chaining (e.g., raising GcalcliError(...) from the caught exception) so the root cause is preserved.
| ) | |
| ) from e |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,41 @@ | ||||||
|
|
||||||
| import pytest | ||||||
| from gcalcli.gcal import GoogleCalendarInterface | ||||||
|
Comment on lines
+2
to
+3
|
||||||
| import pytest | |
| from gcalcli.gcal import GoogleCalendarInterface |
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8 blank-line spacing: top-level functions should be preceded by two blank lines. As written, def test_service_account_loading comes immediately after the imports with only one blank line, which will fail ruff (E302).
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains trailing whitespace on blank/comment lines (e.g., around the blank lines after mock_creds / gcal = ...). ruff will flag this as W291/W293 and fail linting; please strip trailing spaces (or run the formatter).
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8 blank-line spacing: there should be two blank lines between top-level function definitions. Add an extra blank line between these tests to satisfy ruff (E305).
Copilot
AI
Feb 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_service_account_skips_oauth_cache doesn't currently assert that the OAuth cache is actually bypassed (it only asserts the service-account creds are set). Consider using tmp_path as data_path, creating a fake oauth cache file, and asserting it isn't read (e.g., monkeypatch gcalcli.gcal.pickle.load/Path.open to fail if invoked, or assert data_file_path('oauth') isn't called).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
load_service_account()duplicates the calendar scope string used inauthenticate(). To avoid future drift, consider defining a module-level constant (e.g.,CALENDAR_SCOPES) and reusing it in both places.