コード例 #1
0
ファイル: devices.py プロジェクト: miing/mci_migo
def rename_device(name, new_name):
    click_link(get_element(tag='a', text_regex='Rename'))
    # find name textfield
    elem = get_element(tag='input', name='name', value=name)
    # and update it
    write_textfield(elem, new_name)
    # and submit the form
    click_button(get_element(tag='button', text='Rename'))
コード例 #2
0
    def add_billing_address(self):
        # from the account page
        manage_link = a.get_element_by_xpath("//a[text()='Manage Addresses']")
        a.click_link(manage_link)

        fill_user_form(self._data, version=self._version)
        button = a.get_element_by_xpath("//button[@title='Save Address']")
        a.click_button(button)
コード例 #3
0
ファイル: devices.py プロジェクト: miing/mci_migo
def authenticate(name=None):
    cache = _get_device_cache()
    if name is None:
        # Just pick the first device we find
        name = cache.keys()[0]
    device = cache[name]

    if device.codes is None:
        otp = hotp.hotp(device.aes_key, device.counter)
        device.counter += 1
    else:
        otp = device.codes.pop(0)

    write_textfield('id_oath_token', otp)
    click_button(get_element(type='submit'))
コード例 #4
0
    def login(self):
        go_to('admin/')
        a.assert_title_contains('Admin')

        fill_user_form(self._data)
        button = a.get_element_by_xpath("//input[@title='Login']")
        a.click_button(button)

        # do away with messages if any
        close = None
        try:
            close = a.get_element_by_xpath(
                "//div[@id='message-popup-window']"
                "//a[@title='close']")
        except AssertionError:
            pass
        if close:
            a.click_link(close)
コード例 #5
0
    def login(self):
        if self._version >= (1, 9, 0, 0):
            self._account_menu_1_9('Log In')
        else:
            a.click_link(a.get_element(text='Log In'))

        # fill in data on login screen
        data = {
            'email': self._data['email_address'],
            'pass': self._data['password'],
        }
        fill_user_form(data, version=self._version)

        button = a.get_element_by_xpath("//button[@title='Login']")
        a.click_button(button)

        e = a.get_element_by_xpath("//p[@class='welcome-msg']")
        assert e.text.upper() == u'WELCOME, MARY BERNARD!', \
            "Login failed: %r" % e.text
コード例 #6
0
ファイル: devices.py プロジェクト: miing/mci_migo
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')
コード例 #7
0
    def register(self):
        if self._version >= (1, 9, 0, 0):
            self._account_menu_1_9('Register')
        else:
            a.click_link(a.get_element(text='My Account'))
            button = a.get_element_by_xpath(
                "//button[@title='Create an Account']")
            a.click_button(button)


        # fill in data for mary and register
        fill_user_form(self._data, version=self._version)

        if self._version >= (1, 9, 0, 0):
            title = 'Register'
        else:
            title = 'Submit'
        button = a.get_element_by_xpath("//button[@title='%s']" % title)
        a.click_button(button)
コード例 #8
0
helpers.skip_unless_staging_or_production()
helpers.login_to_test_account()

go_to("https://bitbucket.org/account/signin/")
click_link(get_element(text="OpenID log in"))


def openid_link_is_visible():
    return get_element(href="#openid", title="OpenID").is_displayed()
wait_for(openid_link_is_visible)

click_link(get_element(href="#openid", title="OpenID"))
wait_for(lambda: get_element(tag='input', id='openid-url').is_displayed())

input = get_element(tag='input', id='openid-url')
input.clear()
input.send_keys(get_base_url())
submit_button = get_element_by_css(
    'div.buttons.selected button[type=submit]')
click_button(submit_button)

wait_for(get_element, type='submit', name='yes', css_class='btn')
click_button(get_element(type='submit', name='yes', css_class='btn'))

wait_for(assert_url_contains, 'bitbucket.org')

go_to(urls.HOME)
link = get_elements_by_css('#visited-sites tbody td a')[0]

assert get_link_url(link) == "https://bitbucket.org/"
コード例 #9
0
ファイル: devices.py プロジェクト: miing/mci_migo
def enter_otp(otp):
    write_textfield('id_oath_token', otp)
    click_button(get_element(type='submit'))
コード例 #10
0
    write_textfield,
    wait_for,
)
from sst import config as sst_config
from u1testutils import mail
from u1testutils.sst import config

from acceptance import helpers

if 'allow_unverified' in sst_config.flags:
    skip("allow_unverified means this test is irrelevant")

config.set_base_url_from_env()

email_address_for_token = mail.make_unique_test_email_address()
token = helpers.register_account(email_address_for_token)

# Now we create a second account and try to use the original
# verification code/token.
another_email = mail.make_unique_test_email_address()
helpers.logout()
helpers.register_account(another_email, verify=False)
write_textfield(get_element(name='confirmation_code'), token)
sleep(1)  # we have no idea why this is needed but bad things happen if omitted
click_button(get_element(css_class='btn'))

# We are still on the 'Enter confirmation code' page, and have been told
# that the confirmation code we used is unknown.
wait_for(assert_title_contains, 'Enter confirmation code')
exists_element(id='confirmation_code_error')
コード例 #11
0
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4

from sst import actions as a

import common
import data

admin = common.Admin(data.admin)
admin.login()

admin.navigate('Customers', 'Manage Customers')
admin.customer_edit_by_email(data.user['email_address'][1])

# for some reason there are two buttons? I can only find one in the source
buttons = a.get_elements(title='Delete Customer')
# wait=False lets us interact with the alert
a.click_button(buttons[0], wait=False)
# confirm the dialog when clicking to delete
a.accept_alert('Are you sure you want to do this?')

admin.logout()
コード例 #12
0
ファイル: helpers.py プロジェクト: miing/mci_migo
def _set_twofactor(required):
    go_to(urls.EDIT)
    set_radio_value(get_element(tag="input", name="twofactor_required",
                                value=required))
    click_button(get_update_preferences_button())
コード例 #13
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.
コード例 #14
0
ファイル: login_requireds.py プロジェクト: miing/mci_migo
    get_element_by_css,
    go_to,
    wait_for,
    write_textfield,
)
from u1testutils.sst import config

from acceptance import urls


config.set_base_url_from_env()

go_to(urls.HOME)
wait_for(assert_title, 'Log in')

if email:
    print 'Sending e-mail'
    write_textfield('id_email', '*****@*****.**')
if password:
    print 'Sending password'
    write_textfield('id_password', 'bogus')

click_button(get_element_by_css('*[data-qa-id="ubuntu_login_button"]'))
wait_for(assert_title, 'Log in')

el = get_element(id='login-form')
els = el.find_elements_by_class_name('error')
els = [e for e in els if e.text == 'Required field.']

assert len(els) == errors
コード例 #15
0
ファイル: personless_account.py プロジェクト: miing/mci_migo
go_to(urls.NEW_ACCOUNT)
assert_title('Create account')
helpers.register_account(email_address, password=account_password)

wait_for(assert_element, **{'data-qa-id': 'edit_account'})

# Depending whether we're on Production or Staging different tests
if get_base_url() == 'https://login.ubuntu.com':   # Production
    # shop
    go_to('http://shop.canonical.com')
    wait_for(assert_title, 'Canonical Store')
    click_link(get_element(href="https://shop.canonical.com/login.php"))
    wait_for(get_element, id='id_email')
    write_textfield('id_email', email_address)
    write_textfield('id_password', account_password)
    click_button(get_element(name='continue'))
    click_button(get_element(name='yes'))
    wait_for(get_element, name='email_address')
    assert_element(value=email_address)

    # launchpad
    go_to('https://launchpad.net/~canonical-isd-hackers/+archive/internal-qa/'
          '+index')
    click_button(get_element(name='yes'))
    assert_element(tag='h1', text='Not allowed here')

    # wiki
    go_to('http://wiki.canonical.com')
    click_link(get_element(id="login"))
    go_to('https://wiki.canonical.com/CDO/ISD/Developers/StandupNotes')
    assert_element(tag='strong', text='You are not allowed to view this page.')
コード例 #16
0
ファイル: emails_invalid.py プロジェクト: miing/mci_migo
    go_to,
    skip
)
from u1testutils.sst import config

from acceptance import helpers, urls

from identityprovider.utils import get_current_brand


# the reason why this test is incompatible
# with the u1 brand is because of the
# input email type usage. Firefox will
# prevent user from submitting the form
# if the email is not valid
if get_current_brand() == 'ubuntuone':
    skip('Test not compatible with ubuntuone brand')

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

# Attempt to create a new account using invalid emails
go_to(urls.NEW_ACCOUNT)
helpers.fill_registration_form(
    invalid_email,
    displayname='test name',
    password=settings.SSO_TEST_ACCOUNT_PASSWORD
)
click_button(get_element(name="continue"))
assert_element(text='Invalid email.')
コード例 #17
0
# Create an account
email_address = helpers.register_account(password=password)

# Login with the api to get a token
response = client.login(email=email_address, password=password,
                        token_name='test')
assert_equal(response.status_code, 201)
login_token = response.json()

# Add a new email
go_to(urls.EMAILS)
assert_title_contains("email addresses")
new_email = mail.make_unique_test_email_address()
write_textfield('id_newemail', new_email)
click_button(get_element(name='continue'))

# Find the invalidation link
link = sso_mail.get_invalidation_link_for_address(new_email)
assert link is not None, 'Invalidation link should not be None.'

# Invalidate the new email address
go_to(link)
assert_title_contains('Email invalidation')

click_button(get_element(name='invalidate'))
assert_title_contains('Email invalidated')

# The login token should now be invalid, meaning we can only get public data
response = client.account_details(login_token['openid'], login_token)
body = response.json()
コード例 #18
0
    assert_title,
    browser,
    click_button,
    get_element,
    get_elements_by_css,
    get_link_url,
    go_to,
)
from u1testutils.sst import config

from acceptance import helpers, urls


config.set_base_url_from_env(default_to='https://login.ubuntu.com/')

helpers.production_only()

helpers.login_to_test_account()

go_to("https://one.ubuntu.com/services/plan/subscribe_basic/")
if 'Confirm Subscription' in browser.title:
    click_button(get_element(type='submit', name='subscribe'))

assert_title("Ubuntu One : Dashboard")

go_to(urls.HOME)

link = get_elements_by_css('#visited-sites tbody td a')[0]

assert get_link_url(link) == "https://one.ubuntu.com/"
コード例 #19
0
    get_element,
    go_to,
)
from u1testutils import mail
from u1testutils.sst import config

from acceptance import helpers, urls

from identityprovider.utils import get_current_brand


EMAIL = mail.make_unique_test_email_address()
NAME = 'Some Name'

config.set_base_url_from_env()
go_to(urls.NEW_ACCOUNT)
assert_title('Create account')
helpers.fill_registration_form(EMAIL, displayname=NAME, password=password)
click_button(get_element(name='continue'))

assert_url(urls.NEW_ACCOUNT)
assert_text('id_displayname', NAME)
assert_text('id_email', EMAIL)

if get_current_brand() == 'ubuntuone':
    msg = 'Password with at least 8 characters'
    assert_attribute('id_password', 'placeholder', msg)
else:
    msg = 'Password must be at least 8 characters long.'
    assert_text(get_element(css_class='formHelp'), msg)
コード例 #20
0
config.set_base_url_from_env()
helpers.skip_unless_staging_or_production()
helpers.login_to_test_account()

go_to("http://askubuntu.com/users/authenticate/")
if exists_element(id='more-options-link'):
    get_element(id='more-options-link').click()

    def openid_input_is_displayed():
        return get_element(id='openid_identifier').is_displayed()

    wait_for(openid_input_is_displayed)

write_textfield('openid_identifier', get_base_url())
click_button('submit-button')

wait_for(get_element, type='submit', name='yes', css_class='btn')
click_button(get_element(type='submit', name='yes', css_class='btn'))

wait_for(assert_url_contains, 'askubuntu.com')
if exists_element(type="submit", value="Confirm and Create New Account"):
    click_button(get_element(type="submit",
                             value="Confirm and Create New Account"))
    wait_for(assert_title, "Ask Ubuntu - Stack Exchange")

go_to(urls.HOME)
link = get_elements_by_css('#visited-sites tbody td a')[0]

assert get_link_url(link) == "http://askubuntu.com/users/authenticate/"
コード例 #21
0
ファイル: SREG_opt_out.py プロジェクト: miing/mci_migo
# 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
if toggled_elements is not None:
    for optional_sreg_element in toggled_elements:
        toggle_checkbox(optional_sreg_element)
if disabled_elements is not None:
    for required_sreg_element in disabled_elements:
        assert_element(id=required_sreg_element, disabled="disabled")
click_button(get_element(name='yes'))
コード例 #22
0
# setup
config.set_base_url_from_env()
helpers.login_or_register_account(device_cleanup=True)

# the test: no warnings if no device
go_to(urls.EDIT)
fails(helpers.get_backup_device_warning_div)
add_device('the single device')

# the test: show warning if missing backup device
helpers.assert_backup_device_warning()

# disable the warn_about_backup_device setting
set_checkbox_value(helpers.get_warn_about_backup_device_checkbox(), False)
click_button(helpers.get_update_preferences_button())
assert_checkbox_value(helpers.get_warn_about_backup_device_checkbox(), False)

# no more warning because user does not want to be warned
fails(helpers.get_backup_device_warning_div)

# re enable the warn_about_backup_device setting
set_checkbox_value(helpers.get_warn_about_backup_device_checkbox(), True)
click_button(helpers.get_update_preferences_button())
assert_checkbox_value(helpers.get_warn_about_backup_device_checkbox(), True)
helpers.assert_backup_device_warning()

# add a second device, ensure that the warning is no longer shown
add_device('the backup device')
fails(helpers.get_backup_device_warning_div)
コード例 #23
0
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)

    vcode = sso_mail.get_verification_code_for_address(email_address)

    write_textfield(get_element(name='confirmation_code'), vcode)
    click_button(get_element(css_class='btn'))

# We know that the confirmation code worked if we are now looking at the
# logged-in details page for the user.
コード例 #24
0
ファイル: devices.py プロジェクト: miing/mci_migo
def click_add_device_button():
    click_button(get_element(tag='button', text_regex='Add device'))
コード例 #25
0
ファイル: delete_app.py プロジェクト: miing/mci_migo
# 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)
コード例 #26
0
    get_element,
    write_textfield,
)
from u1testutils.sst import config

from acceptance import helpers


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

# Login so we can change the password
helpers.login(
    settings.SSO_TEST_ACCOUNT_EMAIL, settings.SSO_TEST_ACCOUNT_PASSWORD)

# Change the password on the account and logout
write_textfield('id_password', new_password)
write_textfield('id_passwordconfirm', new_password)
click_button(get_element(name="update"))
assert_element(text='Your account details have been successfully updated')
click_link('logout-link')

# Login with the new password
helpers.login(settings.SSO_TEST_ACCOUNT_EMAIL, password=new_password)

# Change the password back
write_textfield('id_password', settings.SSO_TEST_ACCOUNT_PASSWORD)
write_textfield('id_passwordconfirm', settings.SSO_TEST_ACCOUNT_PASSWORD)
click_button(get_element(name="update"))
assert_element(text='Your account details have been successfully updated')
コード例 #27
0
    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()


resulting_teams = ast.literal_eval(resulting_teams)

go_to(urls.CONSUMER)
wait_for(assert_title, 'Django OpenID Example Consumer')

toggle_checkbox('id_teams')
write_textfield('id_request_teams', team_names)
click_button(get_element(value='Begin'))

login_from_redirect()

wait_for(assert_title, 'Django OpenID Example Consumer')
assert_text_contains(get_element(tag='div', css_class='message success'),
                     'OpenID authentication succeeded')

# Check the results of the team requests from the list in the .csv
for i, team in enumerate(resulting_teams):
    assert_text(get_elements_by_xpath("//li")[i], team)
コード例 #28
0
user.login()

# search for tv
a.write_textfield('search', 'tv')
common.click_button_by_title('Search')

# click it
common.click_button_by_title('Add to Cart', multiple=True)

common.click_button_by_title('Proceed to Checkout', multiple=True)

a.wait_for(a.assert_displayed, 'checkout-step-billing')

a.click_button(a.get_element_by_xpath(
    "//div[@id='checkout-step-billing']"
    "//button[@title='Continue']"))

# in 1.4 it doesn't automatically proceed to shipping method
# because Use Billing Address is not active
if common.get_version() < (1, 5, 0, 0):
    check = a.get_element_by_xpath("//input[@id='shipping:same_as_billing']")
    a.wait_for(a.assert_displayed, check)
    check.click()
    # we need the right continue button, so roll by hand
    button = a.get_element_by_xpath(
        "//form[@id='co-shipping-form']//button[@title='Continue']")
    button.click()

a.wait_for(a.assert_displayed, 'checkout-step-shipping_method')