Fix an error during logout from pgAdmin when using OAuth2 authentication with the query tool open.

This commit is contained in:
Yogesh Mahajan
2025-01-22 21:05:06 +05:30
committed by GitHub
parent ab98e5f6bb
commit 5ee0328063
3 changed files with 7 additions and 81 deletions

View File

@@ -76,10 +76,13 @@ def init_app(app):
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,

View File

@@ -72,88 +72,9 @@ class PGDataypeFeatureTest(BaseFeatureTest):
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');

View File

@@ -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?']" \