Skip to content

Commit 5ee0328

Browse files
Fix an error during logout from pgAdmin when using OAuth2 authentication with the query tool open.
1 parent ab98e5f commit 5ee0328

File tree

3 files changed

+7
-81
lines changed

3 files changed

+7
-81
lines changed

web/pgadmin/authenticate/oauth2.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,13 @@ def oauth_logout():
7676

7777
if not current_user.is_authenticated:
7878
return redirect(get_safe_post_logout_redirect())
79+
80+
# Logout the user first to avoid crypt key issue while
81+
# cancelling existing query tool transactions
82+
logout_user()
7983
for key in list(session.keys()):
8084
session.pop(key)
8185

82-
logout_user()
8386
if logout_url:
8487
return redirect(logout_url.format(
8588
redirect_uri=request.url_root,

web/regression/feature_tests/pg_datatype_validation_test.py

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -72,88 +72,9 @@ def before(self):
7272

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

75-
# For this test case we need to set "Insert bracket pairs?"
76-
# SQL Editor preference to 'false' to avoid codemirror
77-
# to add matching closing bracket by it self.
78-
self._update_preferences()
79-
8075
# close the db connection
8176
connection.close()
8277

83-
def _update_preferences(self):
84-
retry = 2
85-
while retry > 0:
86-
try:
87-
file_menu = self.page.find_by_css_selector(
88-
NavMenuLocators.file_menu_css)
89-
file_menu.click()
90-
91-
self.page.retry_click(
92-
(By.CSS_SELECTOR,
93-
NavMenuLocators.preference_menu_item_css),
94-
(By.XPATH,
95-
NavMenuLocators.specified_preference_tree_node
96-
.format('Browser'))
97-
)
98-
99-
wait = WebDriverWait(self.page.driver, 10)
100-
101-
browser_node = self.page.find_by_xpath(
102-
NavMenuLocators.specified_preference_tree_node.
103-
format('Browser'))
104-
if self.page.find_by_xpath(
105-
NavMenuLocators.specified_pref_node_exp_status.
106-
format('Browser')).\
107-
get_attribute('aria-expanded') == 'false':
108-
ActionChains(self.driver).\
109-
double_click(browser_node).perform()
110-
111-
self.page.retry_click(
112-
(By.XPATH, NavMenuLocators.
113-
specified_sub_node_of_pref_tree_node.
114-
format('Browser', 'Display')),
115-
(By.XPATH,
116-
NavMenuLocators.show_system_objects_pref_label_xpath))
117-
118-
# Wait till the preference dialogue
119-
# box is displayed by checking the
120-
# visibility of Show System Object label
121-
wait.until(EC.presence_of_element_located(
122-
(By.XPATH,
123-
NavMenuLocators.show_system_objects_pref_label_xpath))
124-
)
125-
126-
maximize_button = self.page.find_by_css_selector(
127-
NavMenuLocators.maximize_pref_dialogue_css)
128-
maximize_button.click()
129-
130-
specified_preference_tree_node_name = 'Query Tool'
131-
sql_editor = self.page.find_by_xpath(
132-
NavMenuLocators.specified_preference_tree_node.
133-
format(specified_preference_tree_node_name))
134-
if self.page.find_by_xpath(
135-
NavMenuLocators.specified_pref_node_exp_status.
136-
format(specified_preference_tree_node_name)).\
137-
get_attribute('aria-expanded') == 'false':
138-
ActionChains(self.driver).\
139-
double_click(sql_editor).perform()
140-
141-
option_node = \
142-
self.page.find_by_xpath("//*[@id='treeContainer']"
143-
"//div//span[text()='Editor']")
144-
option_node.click()
145-
146-
switch_box_element = self.page.find_by_xpath(
147-
NavMenuLocators.insert_bracket_pair_switch_btn)
148-
149-
switch_box_element.click()
150-
151-
# save and close the preference dialog.
152-
self.page.click_modal('Save')
153-
break
154-
except Exception:
155-
retry -= 1
156-
15778
def _create_enum_type(self):
15879
query = """CREATE TYPE public.rainbow AS ENUM ('red', 'orange',
15980
'yellow','green','blue','purple');

web/regression/feature_utils/locators.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ class NavMenuLocators:
6363

6464
specified_sub_node_of_pref_tree_node = \
6565
"//*[@id='treeContainer']//div//span[text()='{1}']"
66+
6667
insert_bracket_pair_switch_btn = \
67-
"//label[text()='Insert bracket pairs?']//following::div[1]//span"
68+
("//div[label[text()='Insert bracket pairs?']]/"
69+
"following-sibling::div//input")
6870

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

0 commit comments

Comments
 (0)