2017-04-30 03:02:56 +08:00
|
|
|
#
|
|
|
|
# Copyright (C) 2012 - present Instructure, Inc.
|
|
|
|
#
|
|
|
|
# This file is part of Canvas.
|
|
|
|
#
|
|
|
|
# Canvas is free software: you can redistribute it and/or modify it under
|
|
|
|
# the terms of the GNU Affero General Public License as published by the Free
|
|
|
|
# Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License along
|
|
|
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2012-07-28 07:11:59 +08:00
|
|
|
require File.expand_path(File.dirname(__FILE__) + '/common')
|
|
|
|
|
|
|
|
describe "communication channel selenium tests" do
|
2015-08-08 06:24:05 +08:00
|
|
|
include_context "in-process server selenium tests"
|
2012-07-28 07:11:59 +08:00
|
|
|
|
|
|
|
context "confirm" do
|
|
|
|
it "should register the user" do
|
2013-08-16 04:16:05 +08:00
|
|
|
Setting.set('terms_required', 'false')
|
2012-07-28 07:11:59 +08:00
|
|
|
u1 = user_with_communication_channel(:user_state => 'creation_pending')
|
|
|
|
get "/register/#{u1.communication_channel.confirmation_code}"
|
|
|
|
set_value f('#pseudonym_password'), "asdfasdf"
|
|
|
|
expect_new_page_load {
|
|
|
|
f('#registration_confirmation_form').submit
|
|
|
|
}
|
2016-05-20 05:45:24 +08:00
|
|
|
expect_logout_link_present
|
2012-07-28 07:11:59 +08:00
|
|
|
end
|
|
|
|
|
2017-11-02 00:57:26 +08:00
|
|
|
it "should not show a mysterious error" do
|
|
|
|
Setting.set('terms_required', 'false')
|
|
|
|
u1 = user_with_communication_channel(:user_state => 'creation_pending')
|
|
|
|
get "/register/#{u1.communication_channel.confirmation_code}"
|
|
|
|
f('#registration_confirmation_form').submit
|
|
|
|
wait_for_ajaximations
|
|
|
|
error_boxes = ff('.error_box')
|
|
|
|
text = error_boxes.map(&:text).join
|
|
|
|
expect(text).to include("Must be at least 8 characters")
|
|
|
|
expect(text).to_not include("Doesn't match")
|
|
|
|
end
|
|
|
|
|
2013-07-31 03:50:49 +08:00
|
|
|
it "should require the terms if configured to do so" do
|
|
|
|
u1 = user_with_communication_channel(:user_state => 'creation_pending')
|
|
|
|
get "/register/#{u1.communication_channel.confirmation_code}"
|
2014-10-14 09:36:52 +08:00
|
|
|
expect(f('input[name="user[terms_of_use]"]')).to be_present
|
2013-07-31 03:50:49 +08:00
|
|
|
f('#registration_confirmation_form').submit
|
|
|
|
wait_for_ajaximations
|
|
|
|
assert_error_box 'input[name="user[terms_of_use]"]:visible'
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not require the terms if the user has already accepted them" do
|
|
|
|
u1 = user_with_communication_channel(:user_state => 'creation_pending')
|
|
|
|
u1.preferences[:accepted_terms] = Time.now.utc
|
|
|
|
u1.save
|
|
|
|
get "/register/#{u1.communication_channel.confirmation_code}"
|
2016-05-01 06:23:03 +08:00
|
|
|
expect(f("#content")).not_to contain_css('input[name="user[terms_of_use]"]')
|
2013-07-31 03:50:49 +08:00
|
|
|
end
|
|
|
|
|
2012-12-15 03:12:15 +08:00
|
|
|
it "should allow the user to edit the pseudonym if its already taken" do
|
2012-07-28 07:11:59 +08:00
|
|
|
u1 = user_with_communication_channel(:username => 'asdf@qwerty.com', :user_state => 'creation_pending')
|
2013-08-05 23:40:33 +08:00
|
|
|
u1.accept_terms
|
|
|
|
u1.save
|
2012-07-28 07:11:59 +08:00
|
|
|
# d'oh, now it's taken
|
2016-05-28 03:10:42 +08:00
|
|
|
user_with_pseudonym(:username => 'asdf@qwerty.com', :active_user => true)
|
2012-07-28 07:11:59 +08:00
|
|
|
|
|
|
|
get "/register/#{u1.communication_channel.confirmation_code}"
|
|
|
|
# they can set it...
|
|
|
|
input = f('#pseudonym_unique_id')
|
2014-10-14 09:36:52 +08:00
|
|
|
expect(input).to be_present
|
2012-07-28 07:11:59 +08:00
|
|
|
set_value input, "asdf@asdf.com"
|
|
|
|
set_value f('#pseudonym_password'), "asdfasdf"
|
|
|
|
expect_new_page_load {
|
|
|
|
f('#registration_confirmation_form').submit
|
|
|
|
}
|
|
|
|
|
2016-05-20 05:45:24 +08:00
|
|
|
expect_logout_link_present
|
2012-07-28 07:11:59 +08:00
|
|
|
end
|
2015-10-07 12:27:50 +08:00
|
|
|
|
2016-05-28 03:10:42 +08:00
|
|
|
it 'confirms the communication channels', priority: "2", test_id: 193786 do
|
|
|
|
user_with_pseudonym({active_user: true})
|
|
|
|
create_session(@pseudonym)
|
|
|
|
|
|
|
|
get '/profile/settings'
|
|
|
|
expect(f('.email_channels')).to contain_css('.unconfirmed')
|
|
|
|
f('.email_channels .path').click
|
|
|
|
Notification.create!(name: 'Confirm Email Communication Channel', category: 'Registration')
|
|
|
|
f('#confirm_email_channel .re_send_confirmation_link').click
|
|
|
|
expect(Message.last.subject).to eq('Confirm Email: Canvas')
|
|
|
|
url = Message.last.url
|
|
|
|
|
|
|
|
# get the registration id from the url
|
|
|
|
get '/register/' + url.split('/')[4]
|
|
|
|
expect(f('#flash_message_holder')).to include_text 'Registration confirmed!'
|
|
|
|
get '/profile/settings'
|
|
|
|
# the email id does not have a link anymore
|
|
|
|
expect(f('.email_channels')).not_to contain_link('nobody@example.com')
|
|
|
|
end
|
|
|
|
|
2017-04-05 03:09:25 +08:00
|
|
|
it 'resends sms confirmations properly' do
|
|
|
|
user_with_pseudonym({active_user: true})
|
|
|
|
create_session(@pseudonym)
|
|
|
|
sms_cc = @user.communication_channels.create(:path => "8011235555@example.com", :path_type => "sms")
|
|
|
|
|
|
|
|
get '/profile/settings'
|
|
|
|
expect(f('.other_channels')).to contain_css('.unconfirmed')
|
|
|
|
f('.other_channels .path').click
|
|
|
|
Notification.create!(name: 'Confirm SMS Communication Channel', category: 'Registration')
|
|
|
|
f('#confirm_communication_channel .re_send_confirmation_link').click
|
|
|
|
wait_for_ajaximations
|
|
|
|
|
|
|
|
expect(@user.messages.count).to eq 1
|
|
|
|
m = @user.messages.first
|
|
|
|
expect(m.subject).to eq('Canvas Alert')
|
|
|
|
expect(m.body).to include(sms_cc.confirmation_code)
|
|
|
|
end
|
|
|
|
|
2015-10-07 12:27:50 +08:00
|
|
|
it 'should show the bounce count reset button when a siteadmin is masquerading' do
|
|
|
|
u = user_with_pseudonym(active_all: true)
|
2016-05-28 03:10:42 +08:00
|
|
|
u.communication_channels.create!(:path => 'test@example.com', :path_type => 'email') { |cc| cc.workflow_state = 'active'; cc.bounce_count = 3 }
|
2015-10-07 12:27:50 +08:00
|
|
|
site_admin_logged_in
|
|
|
|
masquerade_as(u)
|
|
|
|
|
|
|
|
get '/profile/settings'
|
|
|
|
|
|
|
|
expect(f('.reset_bounce_count_link')).to be_present
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not show the bounce count reset button when an account admin is masquerading' do
|
|
|
|
u = user_with_pseudonym(active_all: true)
|
2016-05-28 03:10:42 +08:00
|
|
|
u.communication_channels.create!(:path => 'test@example.com', :path_type => 'email') { |cc| cc.workflow_state = 'active'; cc.bounce_count = 3 }
|
2015-10-07 12:27:50 +08:00
|
|
|
admin_logged_in
|
|
|
|
masquerade_as(u)
|
|
|
|
|
|
|
|
get '/profile/settings'
|
|
|
|
|
2016-05-01 06:23:03 +08:00
|
|
|
expect(f("#content")).not_to contain_css('.reset_bounce_count_link')
|
2015-10-07 12:27:50 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not show the bounce count reset button when the channel is not bouncing' do
|
|
|
|
u = user_with_pseudonym(active_all: true)
|
2016-05-28 03:10:42 +08:00
|
|
|
u.communication_channels.create!(:path => 'test@example.com', :path_type => 'email') { |cc| cc.workflow_state = 'active' }
|
2015-10-07 12:27:50 +08:00
|
|
|
site_admin_logged_in
|
|
|
|
masquerade_as(u)
|
|
|
|
|
|
|
|
get '/profile/settings'
|
|
|
|
|
2016-05-01 06:23:03 +08:00
|
|
|
expect(f("#content")).not_to contain_css('.reset_bounce_count_link')
|
2015-10-07 12:27:50 +08:00
|
|
|
end
|
2012-07-28 07:11:59 +08:00
|
|
|
end
|
|
|
|
end
|