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

Prepare for a smooth transition for new Deleted User #1397

Merged
merged 4 commits into from
Jan 25, 2022

Conversation

sssoleileraaa
Copy link
Contributor

@sssoleileraaa sssoleileraaa commented Jan 19, 2022

Description

Fixes #1143
Closes #1157

This PR removes the /user api call and instead uses the /users endpoint to update and manage the current user as well as all other users. Since an API call is removed and a new one is introduced, the functional test cassettes needed to be regenerated (see the cassettes section in the README for more details if needed).

Followup: Once freedomofpress/securedrop#6225 is released, we can remove the old way of creating users based on a reply's journalist_uuid. For now, I left this in to continue to support showing replies associated with no corresponding user account on the server (/users doesn't actually return any user for replies with a "deleted" UUID)

Test Plan

  • Confirm Deleted user is not fully removed from client database after a sync #1143 is fixed
  • Checkout this PR branch and confirm that deleted users continue to show up (you can run make dev to create a dev server with a deleted user- look for the sparkle icon in the journalist badge next to replies)
  • Change the name of the current journalist (change username, firstname, lastname) and confirm change in the corresponding journalist account badge and reply badge
  • Repeat step above for a journalist that is not currently logged into the client

Future-proof test

Checklist

If these changes modify code paths involving cryptography, the opening of files in VMs or network (via the RPC service) traffic, Qubes testing in the staging environment is required. For fine tuning of the graphical user interface, testing in any environment in Qubes is required. Please check as applicable:

  • I have tested these changes in the appropriate Qubes environment
  • I do not have an appropriate Qubes OS workstation set up (the reviewer will need to test these changes)
  • These changes should not need testing in Qubes

If these changes add or remove files other than client code, the AppArmor profile may need to be updated. Please check as applicable:

  • I have updated the AppArmor profile
  • No update to the AppArmor profile is required for these changes
  • I don't know and would appreciate guidance

If these changes modify the database schema, you should include a database migration. Please check as applicable:

  • I have written a migration and upgraded a test database based on main and confirmed that the migration applies cleanly
  • I have written a migration but have not upgraded a test database based on main and would like the reviewer to do so
  • I need help writing a database migration
  • No database schema changes are needed

@sssoleileraaa sssoleileraaa requested a review from a team as a code owner January 19, 2022 21:02
@sssoleileraaa sssoleileraaa changed the title sync users with server before working with replies Prepare for a smooth transition for new Deleted User Jan 19, 2022
Copy link
Member

@legoktm legoktm left a comment

Choose a reason for hiding this comment

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

Just did a code review for now, I'll test it tomorrow.

securedrop_client/api_jobs/sync.py Show resolved Hide resolved
securedrop_client/api_jobs/sync.py Show resolved Hide resolved
securedrop_client/api_jobs/sync.py Show resolved Hide resolved
securedrop_client/db.py Outdated Show resolved Hide resolved
Allie Crevier added 2 commits January 20, 2022 09:50
Allie Crevier added 2 commits January 20, 2022 10:00
Signed-off-by: Allie Crevier <allie@freedom.press>
Copy link
Contributor

@conorsch conorsch left a comment

Choose a reason for hiding this comment

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

Works well for me! Tested against a server running on current head of develop, the syncing was accurate. Notably, both the username and uuid were set to "deleted".

After switching the server to use PR freedomofpress/securedrop#6225 and repeating local testing, the sync of all attributes was still accurate, with the notable difference that the original uuid for the first deleted user in the client db was preserved. Creating and deleting multiple users did not create additional "deleted" users, nor did it overwrite the uuid of of the special "deleted" user in the client db, as expected.

@conorsch
Copy link
Contributor

I've approved, but am intentionally not merging, so that @legoktm can take a close look in tandem with related functionality in freedomofpress/securedrop#6225.

Copy link
Member

@legoktm legoktm left a comment

Choose a reason for hiding this comment

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

Went through the test plan and everything LGTM! And it helped me find a bug in my PR: freedomofpress/securedrop#6225 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants