Skip to content

Conversation

@nasthagiri
Copy link
Contributor

@nasthagiri nasthagiri commented Dec 8, 2019

This PR removes unused and unneeded endpoints and functionality related to account activation, specifically user_api's duplicative activate_account function, which was only used by tests. As part of this effort, a few surrounding tests and functionality were refactored and removed:

  • change_setting endpoint: Removed since it's not used anywhere in the codebase and not called in production.
  • user_authn.test_views.py: Refactored, moving password-related tests to test_password.py.

References:

@nasthagiri nasthagiri requested review from a team December 8, 2019 21:54
@nasthagiri nasthagiri force-pushed the arch/account-activation-cleanup branch 6 times, most recently from a3590b7 to 63a1a1d Compare December 9, 2019 04:12
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to Reviewers: The tests in this file were simplified to use the users created in ModuleStoreTestCase instead of needing to create and activate new ones. The focus of these tests are not to end-to-end test account creation/activation, but other functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to Reviewers: I updated these tests in order to merge test functionality that was in AccountActivationAndPasswordChangeTest in openedx/core/djangoapps/user_api/accounts/tests/test_api.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to Reviewers: I double-checked in New Relic that this API has been called 0 times since 6 weeks ago on Stage, Prod, and Edge. I believe it's a much older endpoint since user_api was created.

I'd like to move the remaining (email and activation) account-related views to user_api in a subsequent PR. Then, student will only contain functionality for the student dashboard and roles.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to Reviewers: Thanks to @robrap's temporary metrics, we can verify that this CMS path is not needed. Also, @robrap's parallel effort to remove Studio's own account login/registration pages help eliminate this path.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still seeing some /activate/ calls from cms (mostly Edge, but some Prod) which invokes this code.
See

SELECT request.uri, appName from Transaction where request.uri like '/activate/%' and appName like '%-cms'

And

SELECT * from Transaction where student_activate_account = 'cms'

I do not know why these are happening. Older activation emails? I do know the redirect to 'dashboard` definitely blows up when called from Studio.

Could we redirect /activate calls from cms to lms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the decoupled commit related to the removal of student_activate_account. That should unblock this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to Reviewers: Thanks to @robrap's metric here, we've verified that activate_account is used only in tests and not in production.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to Reviewers: These tests are actually for testing Password Change functionality. I have moved them to test_password.py. Also, they do not need account-activation functionality for tests to pass.

Copy link
Contributor

@dianakhuang dianakhuang left a comment

Choose a reason for hiding this comment

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

This looks good to me. Hooray for cleanup!

Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

Great clean-up. I just have questions about activate_account_studio.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still seeing some /activate/ calls from cms (mostly Edge, but some Prod) which invokes this code.
See

SELECT request.uri, appName from Transaction where request.uri like '/activate/%' and appName like '%-cms'

And

SELECT * from Transaction where student_activate_account = 'cms'

I do not know why these are happening. Older activation emails? I do know the redirect to 'dashboard` definitely blows up when called from Studio.

Could we redirect /activate calls from cms to lms?

Copy link
Contributor

Choose a reason for hiding this comment

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

Possible clean-up for a follow-up PR:
When looking at the file, I noticed the following assertNotContains: https://github.com/edx/edx-platform/blob/63a1a1db97e857d28f708117239440eb388c8758/openedx/core/djangoapps/user_authn/views/tests/test_logistration.py#L602
We had some tests that I fixed that used assertNotContains, but no parallel test with assertContains, and the thing that wasn't being found was because it was bogus code, not because some flag was working appropriately.

Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

I'm marking as "Request Changes" to ensure my earlier comment about activate_account_studio is handled before merging. Thanks.

I also updated the subject. Unfortunately, once you have an Approval from someone, it looks pretty merge-able.

@robrap robrap changed the title Account Activation cleanup [DO NOT MERGE] Account Activation cleanup Dec 9, 2019
@nasthagiri nasthagiri force-pushed the arch/account-activation-cleanup branch from 63a1a1d to f539a51 Compare December 11, 2019 01:37
@edx-status-bot
Copy link

Your PR has finished running tests. There were no failures.

@nasthagiri nasthagiri changed the title [DO NOT MERGE] Account Activation cleanup Account Activation cleanup Dec 11, 2019
@nasthagiri nasthagiri merged commit 022a011 into master Dec 11, 2019
@nasthagiri nasthagiri deleted the arch/account-activation-cleanup branch December 11, 2019 02:26
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

Nice!

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production on Monday, December 16, 2019.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

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.

6 participants