Esempio n. 1
0
def logout_and_in():
    """Log out and then back in again, using the email and password from the
    last registered account. Returns to the initial url after login."""
    url = get_current_url()
    logout()
    login(_LAST_EMAIL, _LAST_PASSWORD)
    go_to(url)
Esempio n. 2
0
def assert_device_preferences_not_displayed():
    go_to(urls.EDIT)
    fails(assert_element, tag="input", name="twofactor_required", value="True")
    fails(assert_element, tag="input", name="twofactor_required",
          value="False")
    fails(assert_element, tag="input", name="warn_about_backup_device",
          checked="checked")
    def test_sign_out_link(self):
        expected = 'https://avant-qa-screening.herokuapp.com/'
        self.verify_landing_dash_page_links(0, expected, False)

        # clean up steps (this test only) logs back in
        go_to('https://avant-qa-screening.herokuapp.com/users/sign_in')
        set_email_field(self.valid_email)
        set_password_field(self.valid_pw)
        set_log_in_button()
def go_to(url=''):
    protocol = os.environ.get('MAGENTO_PROTOCOL', 'http')
    domain = os.environ.get('MAGENTO_DOMAIN_SUFFIX', '.localhost')

    vtuple = get_version()
    hostname = os.environ.get('MAGENTO_HOSTNAME',
        'magento-' + '-'.join(str(v) for v in vtuple))

    a.go_to('%s://%s%s/%s' % (protocol, hostname, domain, url))
Esempio n. 5
0
    def test_sign_out_link(self):
        expected = 'https://avant-qa-screening.herokuapp.com/'
        self.verify_landing_dash_page_links(0, expected, False)

        # clean up steps (this test only) logs back in
        go_to('https://avant-qa-screening.herokuapp.com/users/sign_in')
        set_email_field(self.valid_email)
        set_password_field(self.valid_pw)
        set_log_in_button()
Esempio n. 6
0
def get_device_preferences_elements():
    go_to(urls.EDIT)
    always_radio = get_element(tag="input", name="twofactor_required",
                               value="True")
    as_needed_radio = get_element(tag="input", name="twofactor_required",
                                  value="False")
    warn_backup_checkbox = get_element(tag="input",
                                       name="warn_about_backup_device")
    return always_radio, as_needed_radio, warn_backup_checkbox
Esempio n. 7
0
def check_2f_for_url(url):
    # are we redirected?
    go_to(url)
    wait_for(assert_title, 'Log in')
    login()
    go_to(url)
    # should be redirected
    assert_url('/two_factor_auth?next=%s' % quote(url))
    logout()
Esempio n. 8
0
 def cleanup():
     go_to(urls.DEVICES)
     # cleanup assumes the user is logged in, otherwise we get a circular
     # dependency between helpers and devices
     msg = 'Can not cleanup devices if user is not logged in.'
     assert '+login' not in get_current_url(), msg
     while get_elements_by_css('#device-list td.name'):
         name = get_elements_by_css('#device-list td.name')[0].text
         print 'Deleting a device:', name
         delete_device()
Esempio n. 9
0
 def test_YUI3_unit_tests(self):
     # Load the page and then wait for #suite to contain
     # 'done'.  Read the results in '#test_results'.
     go_to(self.test_url)
     wait_for(assert_text, 'suite', 'done')
     results = json.loads(get_element(id='test_results').text)
     if results['failed'] != 0:
         message = '%d test(s) failed.\n\n%s' % (
             results['failed'], yui3.get_failed_tests_message(results))
         self.fail(message)
Esempio n. 10
0
 def test_YUI3_unit_tests(self):
     # Load the page and then wait for #suite to contain
     # 'done'.  Read the results in '#test_results'.
     go_to(self.test_url)
     wait_for(assert_text, 'suite', 'done')
     results = json.loads(get_element(id='test_results').text)
     if results['failed'] != 0:
         message = '%d test(s) failed.\n\n%s' % (
             results['failed'], yui3.get_failed_tests_message(results))
         self.fail(message)
Esempio n. 11
0
 def test_existing_user(self):
     email, pw = create_valid_account()
     stop()  # cleanup step
     go_to(self.chk_url)
     set_email_field(email)
     set_password_field(pw)
     set_password_confirmation_field(pw)
     set_sign_up_button()
     expected = "1 error prohibited this user from being saved:\nEmail has already been taken"
     self.verify_error_explanation(expected)
     stop()  # cleanup step
Esempio n. 12
0
def assert_backup_device_warning():
    go_to(urls.EDIT)
    assert_checkbox_value(get_warn_about_backup_device_checkbox(), True)
    warning = get_backup_device_warning_div()
    # ensure a single message is shown
    messages = warning.find_elements_by_tag_name('p')
    assert len(messages) == 1
    assert_text_contains(
        messages[0], 'We strongly recommend having two authentication devices')
    assert_text_contains(
        messages[0], 'Click to add a backup device.')
Esempio n. 13
0
 def test_existing_user(self):
     email, pw = create_valid_account()
     stop() # cleanup step
     go_to(self.chk_url)
     set_email_field(email)
     set_password_field(pw)
     set_password_confirmation_field(pw)
     set_sign_up_button()
     expected = "1 error prohibited this user from being saved:\nEmail has already been taken"
     self.verify_error_explanation(expected)
     stop() # cleanup step
Esempio n. 14
0
def _get_paper_device_codes(counter):
    url = get_current_url()
    restore = False
    if not re.match(r'.*/device-print/\d+$', url):
        assert_url('/device-list')
        click_link(get_element(tag='a', text='View Codes'))
        restore = True

    codes = [e.text for e in
             get_elements_by_css('ol.codelist li')][counter:]
    if restore:
        go_to('/device-list')
    return codes
Esempio n. 15
0
def register_account(email_address=None, displayname="My Name",
                     password="******", fetch_email=True, verify=None):
    """Register an account and verify the token by default.
    If `register_account` creates the email address for you then it returns
    the email address.

    If you pass in an `email_address` then the verification token is returned.
    """
    global _LAST_EMAIL, _LAST_PASSWORD

    if email_address is None:
        email_address = mail.make_unique_test_email_address()

    vcode = None

    create_account = u1testutils.sso.sst.pages.CreateAccount(open_page=True)

    user = data.User(displayname, email_address, password)
    create_account.create_ubuntu_sso_account(user)

    vcode = None
    if 'allow_unverified' in config.flags:
        u1testutils.sso.sst.pages.YourAccount(user.full_name)
        # default is not to verify for ALLOW_UNVERIFIED
        if verify is None:
            verify = False
        if verify:
            vlink = sso_mail.get_verification_link_for_address(email_address)
            go_to(vlink)
            validate_email = \
                u1testutils.sso.sst.pages.CompleteEmailValidation()
            validate_email.confirm()
    else:
        mail_sent = u1testutils.sso.sst.pages.AccountCreationMailSent()
        # old flow requries verify, usually
        if verify is None:
            verify = True
        if verify:
            vcode = sso_mail.get_verification_code_for_address(email_address)
            # TODO add the site not recognized parameter and use the right
            # public method.
            mail_sent._confirm_email(vcode)

    _LAST_EMAIL = email_address
    _LAST_PASSWORD = password

    return email_address
Esempio n. 16
0
def add_device(name='My device'):
    # Go to the authentication devices page
    go_to(urls.DEVICES)
    # Click on "Add a new authentication device" link
    click_add_new_device_link()
    # Choose "Generic HOTP device" and click add device
    set_radio_value('type_generic')
    click_add_device_button()

    # Add correctly generated OTP key
    aes_key = get_element(name='hex_key').get_attribute('value')
    valid_otp = hotp.hotp(aes_key, 0)
    write_textfield(get_element(tag='input', name='otp'), valid_otp)
    # Add a name
    write_textfield(get_element(tag='input', name='name'), name)
    # Click "Add device"
    click_add_device_button()
    store_device(name, aes_key)
    return aes_key
Esempio n. 17
0
def delete_device():
    go_to(urls.DEVICES)
    # Fetch the name of the device we will be deleting
    name = get_elements_by_css('#device-list td.name')[0].text
    # Click on the delete button
    click_delete_button()

    # if we need to 2F auth this action
    if exists_element(id='id_oath_token'):
        authenticate()

    # Click on ok
    click_button(get_element(tag='button', text='Delete this device'))
    remove_device(name)

    # Check we are back on the device-list page
    assert_url('/device-list')
    # Check that our device has been deleted
    fails(get_element, 'device-list')
from acceptance import helpers, urls


config.set_base_url_from_env()

edit_account_anchor = {'data-qa-id': 'edit_account'}

# Create an account and logout.
email_address = helpers.register_account(
    displayname="Fred Jones",
    verify=True
)
helpers.logout()

# Request the password reset.
go_to(urls.HOME)
assert_title('Log in')
click_link('forgotpw-link')
write_textfield('id_email', email_address)
# Even though the recaptcha field is ignored for our tests, we do
# want to verify that it is on the page.
write_textfield('recaptcha_response_field', 'ignored')
click_button(get_element(name='continue'))

assert_element(**{'data-qa-id': 'forgot_password_step_2'})

# Fetch and verify the confirmation code.
vcode = mail.get_verification_code_for_address(email_address)
write_textfield(get_element(name='confirmation_code'), vcode)
click_button(get_element(css_class='btn'))
Esempio n. 19
0
from u1testutils import mail
from u1testutils.sst import config

from acceptance import helpers, urls


config.set_base_url_from_env()

# Create an account with multiple emails.
email_address = helpers.register_account(displayname="Fred Jones", verify=True)
other_email_address = mail.make_unique_test_email_address()
helpers.add_email(other_email_address, verify=True)
edit_account_anchor = {'data-qa-id': 'edit_account'}

# Verify the current preferred email and change it.
go_to(urls.EDIT)
assert_element(**edit_account_anchor)
assert_dropdown_value('id_preferred_email', email_address)
set_dropdown_value('id_preferred_email', other_email_address)
click_button(get_element(name='update'))

# Verify that it was changed (we re-load the page to be sure it's not
# some unexpected validation error):
go_to(urls.EDIT)
assert_element(**edit_account_anchor)
assert_dropdown_value('id_preferred_email', other_email_address)

# XXX Julien would also like this test to trigger an email being sent so
# we can verify that the email is actually sent to the preferred
# address.
Esempio n. 20
0
    skip,
    skip_production,
)


config.set_base_url_from_env()
skip_production()
# XXX: skip if staging until the test can be made to reliably pass
if is_staging():
    skip()

toggled_elements = ast.literal_eval(toggled_elements)
disabled_elements = ast.literal_eval(disabled_elements)
returned_sreg = ast.literal_eval(returned_sreg)

go_to(urls.CONSUMER)
wait_for(assert_title, 'Django OpenID Example Consumer')
toggle_checkbox('id_sreg')
set_radio_value(radio_nickname)
set_radio_value(radio_fullname)
set_radio_value(radio_email)
set_radio_value(radio_language)
click_button(get_element(value='Begin'))

wait_for(assert_title, 'Log in')
write_textfield('id_email', settings.SSO_TEST_ACCOUNT_EMAIL)
write_textfield('id_password', settings.SSO_TEST_ACCOUNT_PASSWORD)
click_button(get_element_by_css('*[data-qa-id="ubuntu_login_button"]'))

wait_for(assert_title_contains, 'Authenticate to')
# Check the elements specified in the .csv list
Esempio n. 21
0
    assert_title_contains,
    click_button,
    get_element,
    go_to,
    wait_for,
)
from u1testutils import mail
from u1testutils.sso import mail as sso_mail
from u1testutils.sst import config

from acceptance import helpers, urls


config.set_base_url_from_env()

go_to(urls.NEW_ACCOUNT)
assert_title('Create account')

email_address = mail.make_unique_test_email_address()
helpers.fill_registration_form(email_address)
click_button(get_element(name='continue'))

if 'allow_unverified' not in sst_config.flags:
    assert_title_contains('Account creation mail sent')
    assert_text_contains(
        get_element(id='content'),
        r'just emailed .* \(from .*\) to confirm your address\.',
        regex=True)

    link = sso_mail.get_verification_link_for_address(email_address)
Esempio n. 22
0
 def setUp(self):
     # open the sign_up page directly
     self.chk_url = 'https://avant-qa-screening.herokuapp.com/users/sign_up'
     go_to(self.chk_url)
# The token generated when creating a new account should not be able to
# be used with other email addresses.
from sst.actions import (
    assert_element,
    go_to,
)
from u1testutils.sst import config

from acceptance import helpers, urls


config.set_base_url_from_env()

email_address_for_token = helpers.register_account(displayname="Fred Stone")

# Now that we're logged in with the new account, we try creating
# another new account...but are redirected back to our details.
go_to(urls.NEW_ACCOUNT)
assert_element(**{'data-qa-id': 'edit_account'})
Esempio n. 24
0
 def setUpClass(self):
     self.chk_url = 'https://avant-qa-screening.herokuapp.com/users/sign_in'
     go_to(self.chk_url)
     set_sign_up_link()
     self.valid_email, self.valid_pw = create_valid_account()
     stop()
    assert_element,
    click_button,
    get_element,
    go_to,
)
from sst import config as sst_config
from u1testutils import mail
from u1testutils.sst import config

from acceptance import helpers, urls


config.set_base_url_from_env()
email_address = helpers.register_account()

# We logout now and verify that we can't create a second email account
# with the same email address.
go_to(urls.LOGOUT)
go_to(urls.NEW_ACCOUNT)
helpers.fill_registration_form(email_address)
click_button(get_element(name='continue'))

if 'allow_unverified' in sst_config.flags:
    assert_element(text='Invalid Email')
else:
    # In this case, the email sent should be a warning with a link to the
    # forgot password page.
    email = mail.get_latest_email_sent_to(email_address)
    mail.email_subject_includes(email, "Warning")
    mail.email_body_includes(email, "/+forgot_password")
Esempio n. 26
0
__author__ = 'y981821'

from sst import actions, config
config.browser_type = 'firefox'
actions.go_to('https://staging.sem.yellow.co.nz')
Esempio n. 27
0
 def setUpClass(self):
     self.chk_url = 'https://avant-qa-screening.herokuapp.com/users/sign_in'
     go_to(self.chk_url)
     set_sign_up_link()
     self.valid_email, self.valid_pw = create_valid_account()
     stop()
Esempio n. 28
0
 def setUpClass(self):
     go_to('https://avant-qa-screening.herokuapp.com/users/sign_in')
     set_sign_up_link()
     self.valid_email, self.valid_pw = create_valid_account()
     self.h1 = get_h1()
     set_edit_profile_link()
Esempio n. 29
0
from u1testutils.sst import config

from acceptance import helpers, urls

from identityprovider.utils import get_current_brand


if get_current_brand() == 'ubuntuone':
    skip(
        'The ubuntuone brand does client side validation'
    )

config.set_base_url_from_env()

# Create and verify account A
helpers.register_account()

# Add and verify 2nd email
go_to(urls.EMAILS)
wait_for(assert_title_contains, "'s email addresses")
write_textfield('id_newemail', address)
click_button(get_element(name='continue'))

# Check the outcome
if valid:
    wait_for(assert_title, 'Validate your email address')
    mail.delete_msgs_sent_to(address)
else:
    wait_for(assert_title, 'Add an email')
    assert_text_contains(get_element(name='newemailform'), 'Invalid email.')
Esempio n. 30
0
)

from identityprovider.utils import get_current_brand


config.set_base_url_from_env()

# Create account or login, then add a device
helpers.login_or_register_account(device_cleanup=True)
aes_key = add_device('logout_deep_pages')

# Logout and back in so we are no longer 2f-authenticated
helpers.logout_and_in()

# Create a device to get a deep page and then start to delete it
go_to(urls.DEVICES)
click_delete_button()
authenticate()
assert_url_contains('/device-removal/\d+', regex=True)

# logout by clicking on link
click_link('logout-link')

# no link present in ubuntuone brand
if get_current_brand() != 'ubuntuone':
    assert_element(href="/+login")

# make sure we're logged out
go_to(urls.HOME)
assert_title('Log in')
    write_textfield,
    wait_for,
)
from u1testutils.sso import mail
from u1testutils.sst import config

from acceptance import helpers


config.set_base_url_from_env()

# Register a new account and request a password reset.
email_address = helpers.register_account(displayname="Fred Jones", verify=True)
helpers.request_password_reset(email_address)

# Fetch and verify the confirmation code.
link = mail.get_verification_link_for_address(email_address)
go_to(link)

# Reset the password and verify that we're logged in.
assert_title('Reset password')
write_textfield('id_password', "Admin007")
write_textfield('id_passwordconfirm', "Admin007")
click_button(get_element(name='continue'))
assert_element(**{'data-qa-id': 'edit_account'})

# Now try to use the link a second time.
helpers.logout()
go_to(link)
wait_for(assert_title, "Unauthorized confirmation code")
Esempio n. 32
0
 def setUpClass(self):
     self.chk_url = "https://avant-qa-screening.herokuapp.com/"
     go_to(self.chk_url)
     self.h1 = get_h1()
Esempio n. 33
0
 def setUp(self):
     # open the sign_up page directly
     self.chk_url = 'https://avant-qa-screening.herokuapp.com/users/sign_up'
     go_to(self.chk_url)
Esempio n. 34
0
 def setUp(self):
     go_to(self.chk_url)
Esempio n. 35
0
# Create an account
email_address = helpers.register_account()

# Make sure we are not logged in
helpers.logout()

# Authenticate via the api so that an application can be created
url = ('%s/api/1.0/authentications?ws.op=authenticate&token_name=%s' %
       (get_base_url(), TOKEN_NAME))
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, url, email_address, PASSWORD)
opener = urllib2.build_opener(urllib2.HTTPBasicAuthHandler(password_mgr))
urllib2.install_opener(opener)

req = urllib2.Request(url)
f = urllib2.urlopen(req)
data = f.read()

# now test that the app is there and that  we can delete it
helpers.login(email_address, PASSWORD)
go_to(urls.APPLICATIONS)
assert_text_contains('content', TOKEN_NAME)
delete_buttons = get_elements(css_class='btn-sm', name='Delete')
# delete application token
click_button(delete_buttons[0])
# log back in and should have no app
helpers.logout()
helpers.login(email_address, PASSWORD)
go_to(urls.APPLICATIONS)
fails(assert_text_contains, 'content', TOKEN_NAME)
Esempio n. 36
0
 def setUp(self):
     go_to(self.chk_url)
Esempio n. 37
0

# Set to Production, Staging, VPS, Developer etc..
config.set_base_url_from_env()

helpers.skip_unless_staging_or_production()

# We use the base URL to switch the LP version of SSO here
#   Will work for Staging/Production/VPS etc
base_url = get_base_url()
lp_base_url = base_url.replace('ubuntu.com', 'launchpad.net')
set_base_url(lp_base_url)

# Goes to LP skinned version of SSO to login then,
#   uses the logout button to logout
go_to(urls.HOME)
write_textfield('id_email', settings.SSO_TEST_ACCOUNT_EMAIL)
write_textfield('id_password', settings.SSO_TEST_ACCOUNT_PASSWORD)
click_button(get_element(name='continue'))
click_button(get_element(name='logout'))
assert_element(href="/+login")
go_to(urls.HOME)
assert_title('Log in')

# Goes to LP skinned version of SSO to login then,
#   uses the /+logout URL to logout
write_textfield('id_email', settings.SSO_TEST_ACCOUNT_EMAIL)
write_textfield('id_password', settings.SSO_TEST_ACCOUNT_PASSWORD)
click_button(get_element(name='continue'))
go_to(urls.LOGOUT)
assert_element(href="/+login")