Skip to content

Commit

Permalink
Merge pull request #1631 from atlassian/dca-2396-add-jira-10-2-support
Browse files Browse the repository at this point in the history
Added 2sv Jira
  • Loading branch information
SergeyMoroz0703 authored Dec 11, 2024
2 parents 93bfe82 + 01d3200 commit b22fec2
Show file tree
Hide file tree
Showing 6 changed files with 406 additions and 149 deletions.
1 change: 1 addition & 0 deletions app/extension/jira/extension_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def app_specific_action(webdriver, datasets):
# login_page.go_to()
# login_page.wait_for_login_page_loaded()
# login_page.set_credentials(username=username, password=password)
# login_page.wait_for_dashboard_or_first_login_loaded()
# if login_page.is_first_login():
# login_page.first_login_setup()
# if login_page.is_first_login_second_page():
Expand Down
491 changes: 348 additions & 143 deletions app/jmeter/jira.jmx

Large diffs are not rendered by default.

33 changes: 30 additions & 3 deletions app/locustio/jira/http_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,38 @@ def login_and_view_dashboard(locust):
body = params.login_body
body['os_username'] = user[0]
body['os_password'] = user[1]
legacy_form = False

# Check if 2sv login form
r = locust.get('/login.jsp', catch_response=True)
if 'login-form-remember-me' in r.content:
legacy_form = True


# 100 /login.jsp
locust.post('/login.jsp', body,
TEXT_HEADERS,
catch_response=True)
if legacy_form:
locust.post('/login.jsp', body,
TEXT_HEADERS,
catch_response=True)
logger.locust_info(f"Legacy login flow for user {user[0]}")
else:
logger.locust_info(f"2SV login flow for user {user[0]}")

login_body = {'username': user[0],
'password': user[1],
'rememberMe': 'True',
'targetUrl': ''
}

headers = {
"Content-Type": "application/json"
}

# 15 /rest/tsv/1.0/authenticate
locust.post('/rest/tsv/1.0/authenticate',
json=login_body,
headers=headers,
catch_response=True)

r = locust.get('/', catch_response=True)
if not r.content:
Expand Down
1 change: 1 addition & 0 deletions app/selenium_ui/jira/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def sub_measure():
login_page.set_credentials(
username=datasets['current_session']['username'],
password=datasets['current_session']['password'])
login_page.wait_for_dashboard_or_first_login_loaded()
if login_page.is_first_login():
login_page.first_login_setup()
if login_page.is_first_login_second_page():
Expand Down
26 changes: 23 additions & 3 deletions app/selenium_ui/jira/pages/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class Login(BasePage):
page_loaded_selector = LoginPageLocators.system_dashboard
base_url = UrlManager().host

def __init__(self, driver):
super().__init__(driver)
self.is_2sv_login = False

def is_first_login(self):
return True if self.get_elements(LoginPageLocators.continue_button) else False

Expand All @@ -28,6 +32,10 @@ def wait_for_login_page_loaded(self):
# Jira 10.0.1 has issue when clicking too fast on login button resulting in user is not logged in.
from time import sleep
sleep(1)
if not self.get_elements(LoginPageLocators.login_submit_button):
self.is_2sv_login = True
print("INFO: 2sv login form")


def is_first_login_second_page(self):
return True if self.get_elements(LoginPageLocators.avatar_page_next_button) else False
Expand All @@ -44,9 +52,21 @@ def first_login_second_page_setup(self):
self.wait_until_visible(DashboardLocators.dashboard_window)

def set_credentials(self, username, password):
self.get_element(LoginPageLocators.login_field).send_keys(username)
self.get_element(LoginPageLocators.password_field).send_keys(password)
self.get_element(LoginPageLocators.login_submit_button).click()
login_field = LoginPageLocators.login_field
password_field = LoginPageLocators.password_field
submit_button = LoginPageLocators.login_submit_button
if self.is_2sv_login:
login_field = LoginPageLocators.login_field_2sv
password_field = LoginPageLocators.password_field_2sv
submit_button = LoginPageLocators.login_submit_button_2sv

self.wait_until_visible(login_field).send_keys(username)
self.wait_until_visible(password_field).send_keys(password)
self.wait_until_visible(submit_button).click()

def wait_for_dashboard_or_first_login_loaded(self):
self.wait_until_any_ec_presented((LoginPageLocators.system_dashboard,
LoginPageLocators.continue_button))

def __get_footer_text(self):
return self.get_element(LoginPageLocators.footer).text
Expand Down
3 changes: 3 additions & 0 deletions app/selenium_ui/jira/pages/selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class LoginPageLocators:
login_field = (By.ID, 'login-form-username')
password_field = (By.ID, 'login-form-password')
login_submit_button = (By.ID, 'login-form-submit')
login_field_2sv = (By.ID, 'username-field')
password_field_2sv = (By.ID, 'password-field')
login_submit_button_2sv = (By.ID, 'login-button')
system_dashboard = (By.ID, "dashboard")
footer = (By.ID, 'footer-build-information')

Expand Down

0 comments on commit b22fec2

Please sign in to comment.