Skip to content
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

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

gonzalo-bulnes
Copy link
Contributor

@gonzalo-bulnes gonzalo-bulnes commented Apr 27, 2022

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:

  • Remove the custom date string format (that used to be the only one supported by the SecureDrop Client)
  • Use ISO8061 via 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:

  • Linting (make lint) and tests (make test) pass in the development container

If you made changes to securedrop-admin:

  • Linting and tests (make -C admin test) pass in the admin development container

If you made changes to the system configuration:

If you added or removed a file deployed with the application:

  • I have updated AppArmor rules to include the change

If you made non-trivial code changes:

  • I have written a test plan and validated it for this PR

Choose one of the following:

  • I have opened a PR in the docs repo for these changes, or will do so later
  • I would appreciate help with the documentation
  • These changes do not require documentation

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 development
or testing environments, then no diff review is required, and you can skip
(remove) this section.

Choose one of the following:

  • I have performed a diff review and pasted the contents to the packaging wiki
  • I would like someone else to do the diff review

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
@gonzalo-bulnes gonzalo-bulnes force-pushed the delegate-tz-string-formatting-to-datetime branch from 1eff662 to 1aaa7b3 Compare April 27, 2022 21:41
@@ -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"
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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.

Copy link
Member

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().

@gonzalo-bulnes
Copy link
Contributor Author

@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?

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.

2 participants