-
Notifications
You must be signed in to change notification settings - Fork 686
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
Delegate date strings formatting to datetime.isoformat() #6413
base: develop
Are you sure you want to change the base?
Conversation
The SecureDrop SDK now supports date stings in ISO8061 format, so we can stop relying on custom-defined formats. The custom JSON formatter made this a one-line change! 🎉 @legoktm
1eff662
to
1aaa7b3
Compare
@@ -26,7 +26,7 @@ | |||
|
|||
def assert_valid_timestamp(timestamp: str) -> None: | |||
"""verify the timestamp is encoded in the format we want""" | |||
dt_format = "%Y-%m-%dT%H:%M:%S.%fZ" | |||
dt_format = "%Y-%m-%dT%H:%M:%S.%f+00:00" |
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.
Can we use datetime.fromisoformat()
to match securedrop-sdk? Looking at https://github.com/freedomofpress/securedrop-sdk/blob/31ea11e3f9d8c243c0fbe2a19bbdd4f75bd32bd0/sdclientapi/timestamps.py
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.
Yes, we can! I left this one as-is because I like having distinct implementations for the tests and the code under test. I found that using the format string made particularly clear the expectation in the test file. But all that being said, I'd say as a securedrop
repo maintainer it's your call, and I don't personally have strong feelings about it.
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.
Maybe both then? I would like to make sure we're at least testing with what the sdk is actually using, which is now fromisoformat()
.
@legoktm I'm trying to gather again the context around this PR. It seems like one of the API responses contains timestamps without time zone information (specific error in CI). I believe that's a legit test suite error and that we want to fix the API response to conform to the new convention, does that seem right to you? |
Status
Work in progress
Description of Changes
This is the server part of #6257 (see Proposed plan section in the description).
Changes proposed in this pull request:
datetime.isoformat()
instead (should be easier to use consistently too)Testing
How should the reviewer test this PR?
To be defined...
Deployment
No special considerations for deployment come to mind.
Checklist
If you made changes to the server application code:
make lint
) and tests (make test
) pass in the development containerIf you made changes to
securedrop-admin
:make -C admin test
) pass in the admin development containerIf you made changes to the system configuration:
If you added or removed a file deployed with the application:
If you made non-trivial code changes:
Choose one of the following:
If you added or updated a production code dependency:
Production code dependencies are defined in:
admin/requirements.in
admin/requirements-ansible.in
securedrop/requirements/python3/securedrop-app-code-requirements.in
If you changed another
requirements.in
file that applies only to developmentor testing environments, then no diff review is required, and you can skip
(remove) this section.
Choose one of the following: