1 require 'integration_helper'
2 require 'selenium-webdriver'
5 class UserManageAccountTest < ActionDispatch::IntegrationTest
7 headless = Headless.new
9 Capybara.current_driver = :selenium
12 # test manage_account page
13 def verify_manage_account user
15 within('.navbar-fixed-top') do
16 find('a', text: "#{user['email']}").click
17 within('.dropdown-menu') do
18 find('a', text: 'Manage account').click
22 # now in manage account page
23 assert page.has_text?('Virtual Machines'), 'No text - Virtual Machines'
24 assert page.has_text?('Repositories'), 'No text - Repositories'
25 assert page.has_text?('SSH Keys'), 'No text - SSH Keys'
26 assert page.has_text?('Current Token'), 'No text - Current Token'
28 assert page.has_text?('The Arvados API token is a secret key that enables the Arvados SDKs to access Arvados'), 'No text - Arvados API token'
30 click_link 'Add new SSH key'
32 within '.modal-content' do
33 assert page.has_text?('Public Key'), 'No text - Public Key'
34 assert page.has_button?('Cancel'), 'No button - Cancel'
35 assert page.has_button?('Submit'), 'No button - Submit'
37 page.find_field('public_key').set 'first test with an incorrect ssh key value'
39 assert page.has_text?('Public key does not appear to be a valid ssh-rsa or dsa public key'), 'No text - Public key does not appear to be a valid'
41 public_key_str = api_fixture('authorized_keys')['active']['public_key']
42 page.find_field('public_key').set public_key_str
43 page.find_field('name').set 'added_in_test'
45 assert page.has_text?('Public key already exists in the database, use a different key.'), 'No text - Public key already exists'
47 new_key = SSHKey.generate
48 page.find_field('public_key').set new_key.ssh_public_key
49 page.find_field('name').set 'added_in_test'
53 # key must be added. look for it in the refreshed page
54 assert page.has_text?('added_in_test'), 'No text - added_in_test'
56 within('.navbar-fixed-top') do
57 find('a', text: "#{user['email']}").click
58 within('.dropdown-menu') do
59 assert page.has_no_link?('Manage profile'), 'Found link - Manage profile'
66 ['inactive', api_fixture('users')['inactive']],
67 ['inactive_uninvited', api_fixture('users')['inactive_uninvited']],
68 ['active', api_fixture('users')['active']],
69 ['admin', api_fixture('users')['admin']],
70 ].each do |token, user|
71 test "test manage account for user #{token}" do
72 visit page_with_token(token)
73 verify_manage_account user