Skip to content

Commit

Permalink
Deactivate preexisting MFA Zone for MFA user testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sunetfreitag committed Sep 4, 2024
1 parent 27b8aad commit 074d133
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions mfazones-docker/test_mfazones_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,24 @@ def test_mfazones_mfauser(self):
client = Client(options)
client.verify = False
dir = 'MfaTestFolder'
g_logger.info(f'Make and check directory: {dir}')
client.mkdir(dir)
self.assertEqual(client.list().count(dir + '/'), 1)
dirExists = False
dirIsMfaZone = False

try:
client.list(dir)
dirExists = True
except Exception as e:
error_message = str(e)
if "failed with code 403" in error_message:
g_logger.info(f'Expected 403 has occurred')
dirIsMfaZone = True
elif "not found" in error_message:
dirExists = False

if dirExists == False:
g_logger.info(f'Make and check directory: {dir}')
client.mkdir(dir)
self.assertEqual(client.list().count(dir + '/'), 1)

# Log in to the node
nodelogin('localhost', user=user)
Expand Down Expand Up @@ -408,6 +423,17 @@ def test_mfazones_mfauser(self):
g_logger.error(f'Error for node localhost: {e}')
return

if dirIsMfaZone:
try:
g_logger.info(f'Deactivating preexisting MFA Zone')
wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="tab-button-mfazone"]')))
g_driver.implicitly_wait(g_driver_timeout)
mfaZone = g_driver.find_element(By.XPATH, '//*[@id="tab-button-mfazone"]')
mfaZone.click()
except Exception as e:
g_logger.error(f'Error for node localhost: {e}')
return

# Click on MFA Zone
try:
wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="tab-button-mfazone"]')))
Expand Down

0 comments on commit 074d133

Please sign in to comment.