Test "Verify that github non-nda user cannot create access group" (#415)
This commit is contained in:
Родитель
4afc47d7db
Коммит
626d6745f0
|
@ -6,12 +6,15 @@ from pypom import Page
|
|||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support import expected_conditions as expected
|
||||
|
||||
from pages.github import Github
|
||||
|
||||
|
||||
class Auth0(Page):
|
||||
|
||||
_email_locator = (By.ID, 'field-email')
|
||||
_enter_locator = (By.ID, 'enter-initial')
|
||||
_send_email_locator = (By.CSS_SELECTOR, 'button[data-handler=send-passwordless-link]')
|
||||
_login_with_github_button_locator = (By.CSS_SELECTOR, 'button[data-handler="authorise-github"]')
|
||||
|
||||
def __new__(cls, driver, base_url, **kwargs):
|
||||
if 'mozillians.org' in base_url:
|
||||
|
@ -25,6 +28,10 @@ class Auth0(Page):
|
|||
self.wait.until(expected.visibility_of_element_located(
|
||||
self._send_email_locator)).click()
|
||||
|
||||
def click_login_with_github(self):
|
||||
self.find_element(*self._login_with_github_button_locator).click()
|
||||
return Github(self.selenium, self.base_url)
|
||||
|
||||
|
||||
class Legacy(Page):
|
||||
|
||||
|
|
|
@ -60,6 +60,12 @@ class Base(Page):
|
|||
self.selenium.get(login_link)
|
||||
self.wait.until(lambda s: self.is_user_loggedin)
|
||||
|
||||
def login_with_github(self, username, password, secret):
|
||||
self.click_sign_in_button()
|
||||
auth0 = Auth0(self.selenium, self.base_url)
|
||||
github = auth0.click_login_with_github()
|
||||
github.login_with_github(username, password, secret)
|
||||
|
||||
def create_new_user(self, email):
|
||||
self.login(email)
|
||||
from pages.register import Register
|
||||
|
@ -139,6 +145,12 @@ class Base(Page):
|
|||
self.find_element(*self._logout_menu_item_locator).click()
|
||||
self.wait.until(lambda s: not self.is_logout_menu_item_present)
|
||||
|
||||
def click_groups_menu_item(self):
|
||||
self.click_options()
|
||||
self.find_element(*self._groups_menu_item_locator).click()
|
||||
from pages.groups_page import GroupsPage
|
||||
return GroupsPage(self.selenium, self.base_url)
|
||||
|
||||
class Footer(Page):
|
||||
|
||||
_about_mozillians_link_locator = (By.CSS_SELECTOR, '.footer-nav.details > li:nth-child(1) > a')
|
||||
|
|
|
@ -13,6 +13,11 @@ class CreateGroupPage(Base):
|
|||
_create_group_name = (By.NAME, 'name')
|
||||
_create_group_form = (By.CSS_SELECTOR, 'form.add-group')
|
||||
_create_group_submit_button = (By.CSS_SELECTOR, 'form.add-group .btn-primary')
|
||||
_access_group_radio_button = (By.ID, 'id_is_access_group_0')
|
||||
|
||||
@property
|
||||
def is_access_group_present(self):
|
||||
return self.is_element_present(*self._access_group_radio_button)
|
||||
|
||||
def create_group_name(self, group_name):
|
||||
self.wait.until(expected.visibility_of_element_located(
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import pyotp
|
||||
from pypom import Page
|
||||
from selenium.webdriver.common.by import By
|
||||
|
||||
|
||||
class Github(Page):
|
||||
|
||||
_github_username_field_locator = (By.ID, 'login_field')
|
||||
_github_password_field_locator = (By.ID, 'password')
|
||||
_github_sign_in_button_locator = (By.CSS_SELECTOR, '.btn.btn-primary.btn-block')
|
||||
_github_passcode_field_locator = (By.CSS_SELECTOR, 'input[id="otp"]')
|
||||
_github_enter_passcode_button_locator = (By.CSS_SELECTOR, '.btn-primary')
|
||||
|
||||
def login_with_github(self, username, password, secret):
|
||||
self.find_element(*self._github_username_field_locator).send_keys(username)
|
||||
self.find_element(*self._github_password_field_locator).send_keys(password)
|
||||
self.find_element(*self._github_sign_in_button_locator).click()
|
||||
passcode = pyotp.TOTP(secret).now()
|
||||
self.find_element(*self._github_passcode_field_locator).send_keys(passcode)
|
||||
self.find_element(*self._github_enter_passcode_button_locator).click()
|
|
@ -24,3 +24,9 @@ class GroupsPage(Base):
|
|||
|
||||
def is_group_deletion_alert_present(self):
|
||||
return self.is_element_displayed(*self._alert_message_locator)
|
||||
|
||||
def create_group(self, group_name):
|
||||
create_group = self.click_create_group_main_button()
|
||||
create_group.create_group_name(group_name)
|
||||
group = create_group.click_create_group_submit()
|
||||
return group
|
||||
|
|
|
@ -9,3 +9,4 @@ pytest-selenium==1.11.4
|
|||
pytest-variables==1.7.1
|
||||
pytest-xdist==1.22.0
|
||||
requests==2.18.4
|
||||
pyotp==2.2.6
|
||||
|
|
|
@ -56,6 +56,11 @@ def unvouched_user(stored_users):
|
|||
return stored_users['unvouched']
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def github_non_nda_user(stored_users):
|
||||
return stored_users['github_non_nda']
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def login_link(username):
|
||||
mail = restmail.get_mail(username)
|
||||
|
|
|
@ -18,9 +18,9 @@ class TestGroup:
|
|||
home_page.login(vouched_user['email'])
|
||||
|
||||
# Create a new group
|
||||
group_name = str(uuid.uuid4())
|
||||
settings = home_page.header.click_settings_menu_item()
|
||||
group = settings.create_group(group_name)
|
||||
group_name = 'moz-group-{0}'.format(uuid.uuid4())
|
||||
groups_page = home_page.header.click_groups_menu_item()
|
||||
group = groups_page.create_group(group_name)
|
||||
|
||||
# New group data
|
||||
new_group_description = 'This is an automated group.'
|
||||
|
@ -45,9 +45,9 @@ class TestGroup:
|
|||
home_page.login(vouched_user['email'])
|
||||
|
||||
# Create a new group
|
||||
group_name = str(uuid.uuid4())
|
||||
settings = home_page.header.click_settings_menu_item()
|
||||
group = settings.create_group(group_name)
|
||||
group_name = 'moz-group-{0}'.format(uuid.uuid4())
|
||||
groups_page = home_page.header.click_groups_menu_item()
|
||||
group = groups_page.create_group(group_name)
|
||||
|
||||
# Delete should only work with acknowledgement
|
||||
delete_form = group.description.delete_group
|
||||
|
@ -63,9 +63,9 @@ class TestGroup:
|
|||
home_page.login(vouched_user['email'])
|
||||
|
||||
# Create a new group
|
||||
group_name = str(uuid.uuid4())
|
||||
settings = home_page.header.click_settings_menu_item()
|
||||
group = settings.create_group(group_name)
|
||||
group_name = 'moz-group-{0}'.format(uuid.uuid4())
|
||||
groups_page = home_page.header.click_groups_menu_item()
|
||||
group = groups_page.create_group(group_name)
|
||||
|
||||
# Change group type to reveal criteria
|
||||
group_type = group.access.group_type
|
||||
|
@ -79,9 +79,9 @@ class TestGroup:
|
|||
home_page.login(vouched_user['email'])
|
||||
|
||||
# Create a new group
|
||||
group_name = str(uuid.uuid4())
|
||||
settings = home_page.header.click_settings_menu_item()
|
||||
group = settings.create_group(group_name)
|
||||
group_name = 'moz-group-{0}'.format(uuid.uuid4())
|
||||
groups_page = home_page.header.click_groups_menu_item()
|
||||
group = groups_page.create_group(group_name)
|
||||
|
||||
# Invite a new member
|
||||
invite = group.invitations.invite
|
||||
|
@ -93,3 +93,12 @@ class TestGroup:
|
|||
invitations = group.invitations.invitations_list
|
||||
random_profile = randrange(len(invitations.search_invitation_list))
|
||||
assert new_member in invitations.search_invitation_list[random_profile].name
|
||||
|
||||
@pytest.mark.credentials
|
||||
def test_github_non_nda_user_cannot_create_access_group(self, base_url, selenium, github_non_nda_user):
|
||||
home_page = Home(selenium, base_url).open()
|
||||
home_page.login_with_github(github_non_nda_user['username'], github_non_nda_user['password'],
|
||||
github_non_nda_user['secret'])
|
||||
groups_page = home_page.header.click_groups_menu_item()
|
||||
create_group_page = groups_page.click_create_group_main_button()
|
||||
assert not create_group_page.is_access_group_present
|
||||
|
|
|
@ -174,11 +174,8 @@ class TestProfile:
|
|||
|
||||
home_page = Home(selenium, base_url).open()
|
||||
home_page.login(vouched_user['email'])
|
||||
settings = home_page.header.click_settings_menu_item()
|
||||
groups = settings.groups.click_find_group_link()
|
||||
create_group = groups.click_create_group_main_button()
|
||||
create_group.create_group_name(group_name)
|
||||
edit_group = create_group.click_create_group_submit()
|
||||
groups_page = home_page.header.click_groups_menu_item()
|
||||
edit_group = groups_page.create_group(group_name)
|
||||
|
||||
search_listings = edit_group.header.search_for(group_name)
|
||||
|
||||
|
@ -188,7 +185,7 @@ class TestProfile:
|
|||
groups_page = group_info.delete_group()
|
||||
groups_page.wait_for_alert_message()
|
||||
|
||||
home_page.header.click_settings_menu_item()
|
||||
search_listings = home_page.header.search_for(group_name)
|
||||
|
||||
assert not search_listings.is_element_present(By.LINK_TEXT, group_name)
|
||||
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
"username": "",
|
||||
"email": "",
|
||||
"name": ""
|
||||
},
|
||||
"github_non_nda_user": {
|
||||
"username": "",
|
||||
"password": "",
|
||||
"secret": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче