Skip to content

Commit

Permalink
Fixed the error occurring during logout from pgadmin when using OAuth…
Browse files Browse the repository at this point in the history
…2 authnecation with query tool open.#8299
  • Loading branch information
yogeshmahajan-1903 committed Jan 22, 2025
1 parent 133a59c commit d276b05
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 81 deletions.
5 changes: 4 additions & 1 deletion web/pgadmin/authenticate/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ def oauth_logout():

if not current_user.is_authenticated:
return redirect(get_safe_post_logout_redirect())

# Logout the user first to avoid crypt key issue while
# cancelling existing query tool transactions
logout_user()
for key in list(session.keys()):
session.pop(key)

logout_user()
if logout_url:
return redirect(logout_url.format(
redirect_uri=request.url_root,
Expand Down
79 changes: 0 additions & 79 deletions web/regression/feature_tests/pg_datatype_validation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,88 +72,9 @@ def before(self):

self.database_version = self.server_information['server_version']

# For this test case we need to set "Insert bracket pairs?"
# SQL Editor preference to 'false' to avoid codemirror
# to add matching closing bracket by it self.
self._update_preferences()

# close the db connection
connection.close()

def _update_preferences(self):
retry = 2
while retry > 0:
try:
file_menu = self.page.find_by_css_selector(
NavMenuLocators.file_menu_css)
file_menu.click()

self.page.retry_click(
(By.CSS_SELECTOR,
NavMenuLocators.preference_menu_item_css),
(By.XPATH,
NavMenuLocators.specified_preference_tree_node
.format('Browser'))
)

wait = WebDriverWait(self.page.driver, 10)

browser_node = self.page.find_by_xpath(
NavMenuLocators.specified_preference_tree_node.
format('Browser'))
if self.page.find_by_xpath(
NavMenuLocators.specified_pref_node_exp_status.
format('Browser')).\
get_attribute('aria-expanded') == 'false':
ActionChains(self.driver).\
double_click(browser_node).perform()

self.page.retry_click(
(By.XPATH, NavMenuLocators.
specified_sub_node_of_pref_tree_node.
format('Browser', 'Display')),
(By.XPATH,
NavMenuLocators.show_system_objects_pref_label_xpath))

# Wait till the preference dialogue
# box is displayed by checking the
# visibility of Show System Object label
wait.until(EC.presence_of_element_located(
(By.XPATH,
NavMenuLocators.show_system_objects_pref_label_xpath))
)

maximize_button = self.page.find_by_css_selector(
NavMenuLocators.maximize_pref_dialogue_css)
maximize_button.click()

specified_preference_tree_node_name = 'Query Tool'
sql_editor = self.page.find_by_xpath(
NavMenuLocators.specified_preference_tree_node.
format(specified_preference_tree_node_name))
if self.page.find_by_xpath(
NavMenuLocators.specified_pref_node_exp_status.
format(specified_preference_tree_node_name)).\
get_attribute('aria-expanded') == 'false':
ActionChains(self.driver).\
double_click(sql_editor).perform()

option_node = \
self.page.find_by_xpath("//*[@id='treeContainer']"
"//div//span[text()='Editor']")
option_node.click()

switch_box_element = self.page.find_by_xpath(
NavMenuLocators.insert_bracket_pair_switch_btn)

switch_box_element.click()

# save and close the preference dialog.
self.page.click_modal('Save')
break
except Exception:
retry -= 1

def _create_enum_type(self):
query = """CREATE TYPE public.rainbow AS ENUM ('red', 'orange',
'yellow','green','blue','purple');
Expand Down
4 changes: 3 additions & 1 deletion web/regression/feature_utils/locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ class NavMenuLocators:

specified_sub_node_of_pref_tree_node = \
"//*[@id='treeContainer']//div//span[text()='{1}']"

insert_bracket_pair_switch_btn = \
"//label[text()='Insert bracket pairs?']//following::div[1]//span"
("//div[label[text()='Insert bracket pairs?']]/"
"following-sibling::div//input")

copy_sql_to_query_tool_switch_btn = \
"//label[text()='Copy SQL from main window to query tool?']" \
Expand Down

0 comments on commit d276b05

Please sign in to comment.