-
Notifications
You must be signed in to change notification settings - Fork 71
THREESCALE-12410: Remove :api signup type
#4293
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -237,10 +237,6 @@ def minimal_signup? | |
| signup.minimal? | ||
| end | ||
|
|
||
| def api_signup? | ||
| signup.api? | ||
| end | ||
|
|
||
|
Comment on lines
-240
to
-243
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This, and |
||
| def cas_signup? | ||
| signup.cas? | ||
| end | ||
|
|
@@ -437,10 +433,6 @@ def minimal? | |
| signup_type == :minimal | ||
| end | ||
|
|
||
| def api? | ||
| signup_type == :api | ||
| end | ||
|
|
||
| def open_id? | ||
| @user.open_id.present? | ||
| end | ||
|
|
@@ -450,19 +442,19 @@ def oauth2? | |
| end | ||
|
|
||
| def created_by_provider? | ||
| signup_type == :created_by_provider | ||
| %i[created_by_provider api].include?(signup_type) | ||
| end | ||
|
|
||
| def cas? | ||
| @user.cas_identifier.present? | ||
| end | ||
|
|
||
| def machine? | ||
| minimal? || api? || created_by_provider? || open_id? || cas? || oauth2? | ||
| minimal? || created_by_provider? || open_id? || cas? || oauth2? | ||
| end | ||
|
|
||
| def by_user? | ||
| not machine? | ||
| !machine? | ||
| end | ||
|
|
||
| private | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,6 +100,17 @@ def provider_params | |
| assert_equal true, body['success'] | ||
| end | ||
|
|
||
| test 'post without password or open_id rejected' do | ||
| prepare_master_account | ||
| post :create, params: provider_params.except(:open_id) | ||
|
|
||
| assert_response :unprocessable_entity | ||
| body = JSON.parse(response.body) | ||
|
|
||
| assert_not body['success'] | ||
| assert body['errors']['user']['password'].present? | ||
| end | ||
|
|
||
|
Comment on lines
+103
to
+113
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests about partner users are not directly related to the changes, but they ensure no regressions are caused. We need them. |
||
| test 'post with weak password rejected when strong passwords enabled' do | ||
| prepare_master_account | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -273,6 +273,43 @@ def test_accessible_services | |
| assert created_by_provider_user.errors[:password].blank? | ||
| end | ||
|
|
||
| test 'by_user? returns true only for :new_signup, nil, and :partner signup types' do | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we also test how
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here: b006abf |
||
| user = User.new | ||
|
|
||
| %i[new_signup partner].each do |type| | ||
| user.signup_type = type | ||
| assert user.signup.by_user? | ||
| end | ||
|
|
||
| user.signup_type = nil | ||
| assert user.signup.by_user? | ||
|
|
||
| %i[minimal api created_by_provider].each do |type| | ||
| user.signup_type = type | ||
| assert_not user.signup.by_user? | ||
| end | ||
| end | ||
|
|
||
| test 'by_user? returns false when user has SSO identifiers regardless of signup type' do | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be part of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mind changing it, but if I do, I'll lose the approval and have to run tests again just for this. I'm gonna wait for @mayorova's comments, if she requests more changes I'll change this as well.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I must finally give you a token with approve privileges so you stop complaining about approvals.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, please do!!!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No other comments so far :) |
||
| user = User.new | ||
| user.signup_type = :new_signup | ||
|
|
||
| user.open_id = 'some-open-id' | ||
| assert_not user.signup.by_user? | ||
| user.open_id = nil | ||
|
|
||
| user.stubs(:any_sso_authorizations?).returns(true) | ||
| assert_not user.signup.by_user? | ||
| user.unstub(:any_sso_authorizations?) | ||
|
|
||
| user.authentication_id = 'some-auth-id' | ||
| assert_not user.signup.by_user? | ||
| user.authentication_id = nil | ||
|
|
||
| user.cas_identifier = 'some-cas-id' | ||
| assert_not user.signup.by_user? | ||
| end | ||
|
|
||
| test 'reset password' do | ||
| user = FactoryBot.create(:simple_user, username: 'person', password: 'superSecret1234#') | ||
| user.activate! | ||
|
|
||
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.
Users created via API will have the
:created_by_providertype from now on. However, we still have about 50k users in the DB with the:apitype, and I don't plan to migrate them in any way. See other my other comments to see how I handled this.