-
Notifications
You must be signed in to change notification settings - Fork 81
Purge non-verified user #3417
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
Merged
Merged
Purge non-verified user #3417
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
867c19e
use SQL's NOW() fct to log creation of a new user account (validated …
sjanssen2 c94ccb9
at -> on
sjanssen2 ca55a2f
add new col
sjanssen2 b8f959a
adding a new page for admins to easily list all users not yet validat…
sjanssen2 09e1a50
flake8
sjanssen2 cf92fa4
fix tests
sjanssen2 7c880df
Merge branch 'dev' of github.com:qiita-spots/qiita into purge_nonveri…
sjanssen2 cf462aa
move DB changes to patch
sjanssen2 73b66be
revert file
sjanssen2 2de7acc
no change here
sjanssen2 1e7ad50
execute merge manually
sjanssen2 ec90003
moving data insertion to test_db_sql patch
sjanssen2 71b97f3
account for additional test users
sjanssen2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,10 @@ def test_get(self): | |
{'email': '[email protected]', 'name': 'Shared'}, | ||
{'email': '[email protected]', 'name': 'Admin'}, | ||
{'email': '[email protected]', 'name': 'Demo'}, | ||
{'email': '[email protected]', 'name': 'Dude'} | ||
{'email': '[email protected]', 'name': 'Dude'}, | ||
{'email': '[email protected]', 'name': 'JustNow'}, | ||
{'email': '[email protected]', 'name': 'Oldie'}, | ||
{'email': '[email protected]', 'name': 'TooLate'} | ||
]} | ||
self.assertEqual(obs, exp) | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,10 @@ COMMENT ON COLUMN qiita.qiita_user.creation_timestamp IS 'The date the user acco | |
-- for testing: provide creation date for one of the existing users | ||
|
||
UPDATE qiita.qiita_user SET creation_timestamp = '2015-12-03 13:52:42.751331-07' WHERE email = '[email protected]'; | ||
|
||
-- Jun 20, 2024 | ||
-- Add some non-verified users to the test DB to test new admin page: /admin/purge_users/ | ||
|
||
INSERT INTO qiita.qiita_user VALUES ('[email protected]', 5, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'JustNow', 'NonVeriUser', '1634 Edgemont Avenue', '303-492-1984', NULL, NULL, NULL, false, NULL, NULL, NULL, NOW()); | ||
INSERT INTO qiita.qiita_user VALUES ('[email protected]', 5, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Oldie', 'NonVeriUser', '172 New Lane', '102-111-1984', NULL, NULL, NULL, false, NULL, NULL, NULL, NOW() - INTERVAL '1 YEAR'); | ||
INSERT INTO qiita.qiita_user VALUES ('[email protected]', 5, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'TooLate', 'NonVeriUser', '564 C Street', '508-492-222', NULL, NULL, NULL, false, NULL, NULL, NULL, NOW() - INTERVAL '30 DAY'); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,9 +9,13 @@ | |
from unittest import main | ||
from wtforms.validators import ValidationError | ||
from wtforms import StringField | ||
from mock import Mock | ||
from json import loads | ||
|
||
from qiita_pet.test.tornado_test_base import TestHandlerBase | ||
from qiita_pet.handlers.user_handlers import UserProfile | ||
from qiita_pet.handlers.base_handlers import BaseHandler | ||
from qiita_db.user import User | ||
|
||
|
||
class TestUserProfile(TestHandlerBase): | ||
|
@@ -124,5 +128,32 @@ def test_get(self): | |
self.assertEqual(response.code, 200) | ||
|
||
|
||
class TestPurgeUsersAJAXHandler(TestHandlerBase): | ||
def setUp(self): | ||
super().setUp() | ||
BaseHandler.get_current_user = Mock(return_value=User("[email protected]")) | ||
|
||
def test_get(self): | ||
response = self.get('/admin/purge_usersAjax/?_=1718805487494') | ||
obs_users_table = loads(response.body.decode('ascii')) | ||
obs_users = {user['email'] for user in obs_users_table} | ||
self.assertIn('[email protected]', obs_users) | ||
self.assertIn('[email protected]', obs_users) | ||
self.assertNotIn('[email protected]', obs_users) | ||
|
||
def test_post_removeBoth(self): | ||
# remove both users | ||
response = self.post('/admin/purge_users/', | ||
{'action': 'Remove', | ||
'selected': ['[email protected]', | ||
'[email protected]']}) | ||
self.assertEqual(response.code, 200) | ||
|
||
# test that zero users are listed now | ||
response = self.get('/admin/purge_usersAjax/?_=1718805487495') | ||
obs_users_table = loads(response.body.decode('ascii')) | ||
self.assertEqual(obs_users_table, []) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sorry for not catching this before but could you move these lines to patches/test_db_sql/92.sql. The issue is that if we leave them here they will also be inserted in the main deployment but in
patches/test_db_sql
they will only be applied to the test environment.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.
FWIW, I think this is the source of the error.
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.
I changed that, makes total sense to me. I also know a guy who complained about test data leftovers in a fresh production DB ;-)