Skip to content

Commit

Permalink
Adding Read-Only Share Admin Directory Services test
Browse files Browse the repository at this point in the history
  • Loading branch information
ericbsd committed May 24, 2024
1 parent 09076e7 commit 530c5e9
Show file tree
Hide file tree
Showing 8 changed files with 869 additions and 23 deletions.
10 changes: 4 additions & 6 deletions helper/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

def create_timestamp() -> str:
now = datetime.now()
timestamp = now.strftime("%Y_%m_%d-%H_%M_%S")
return timestamp
return now.strftime("%Y_%m_%d-%H_%M_%S")


real_workdir = workdir.replace("\\", "/").replace("C:", "/mnt/c")
Expand Down Expand Up @@ -46,10 +45,9 @@ def allure_environment():
file.write(f'short_version={version_short}\n')
file.write(f'short_version={version_short}\n')
for _ in range(10):
if "percy_threading" not in str(threading.enumerate()):
if shared_config['PERCY_URL']:
file.write(f"percy_report={shared_config['PERCY_URL']}\n")
break
if "percy_threading" not in str(threading.enumerate()) and shared_config['PERCY_URL']:
file.write(f"percy_report={shared_config['PERCY_URL']}\n")
break
WebUI.delay(1)


Expand Down
120 changes: 120 additions & 0 deletions keywords/api/ldap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
from helper.api import GET, PUT, Response
from helper.global_config import shared_config
from keywords.api.common import API_Common


class API_LDAP:

@classmethod
def get_ldap_config(cls) -> Response:
"""
This method gets LDAP configuration.
:return: The API request response.
Example:
- API_Ldap.get_ldap_config()
"""
return GET('/ldap')

@classmethod
def get_ldap_state(cls) -> Response:
"""
This method gets LDAP state.
:return: The API request response.
Example:
- API_Ldap.get_ldap_state()
"""
return GET('/ldap/get_state')

@classmethod
def get_ldap_schema_choices(cls) -> Response:
"""
This method gets LDAP schema choices.
:return: The API request response.
Example:
- API_Ldap.get_ldap_schema_choices()
"""
return GET('/ldap/schema_choices')

@classmethod
def get_ldap_ssl_choices(cls) -> Response:
"""
This method gets LDAP ssl choices.
:return: The API request response.
Example:
- API_Ldap.get_ldap_ssl_choices()
"""
return GET('/ldap/ssl_choices')

@classmethod
def configure_ldap(cls, basedn: str, binddn: str, bindpw: str, hostname: str, ssl: str = 'ON') -> dict:
"""
This method configures LDAP.
:param basedn: the base dn
:param binddn: the bind dn
:param bindpw: the bind password
:param hostname: the hostname
:param ssl: the ssl ON or OFF
:return: the API request response.
Example:
- API_Ldap.configure_ldap('basedn', 'binddn', 'bindpw', 'hostname', 'OFF')
"""
payload = {
"basedn": basedn,
"binddn": binddn,
"bindpw": bindpw,
"hostname": [hostname],
"ssl": ssl,
"enable": True
}
return cls.update_ldap(payload)

@classmethod
def disable_ldap(cls) -> dict:
"""
This method disables LDAP.
:return: The API request response.
Example:
- API_Ldap.disable_ldap()
"""
return cls.update_ldap({'enable': False})

@classmethod
def enable_ldap(cls) -> dict:
"""
This method enables LDAP.
:return: The API request response.
Example:
- API_Ldap.enable_ldap()
"""
return cls.update_ldap({'enable': True})

@classmethod
def update_ldap(cls, payload: dict) -> dict:
"""
This method updates the LDAP configuration.
:param payload: is the payload for the api call.
:return: the API request response.
Example:
- API_Ldap.update_ldap(payload)
"""
response = PUT('/ldap', payload)
assert response.status_code == 200, response.text
job_result = API_Common.wait_on_job(response.json()['job_id'], shared_config['EXTRA_LONG_WAIT'])
assert job_result['state'] == 'SUCCESS', job_result['results']
return job_result['results']
2 changes: 1 addition & 1 deletion keywords/webui/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ def delete_file(cls, path: str, filename: str) -> None:
Example:
- Common.delete_file('C:/path', 'myfile.txt')
"""
file = Path(path + '/' + filename)
file = Path(f'{path}/{filename}')
file.unlink(True)

@classmethod
Expand Down
Loading

0 comments on commit 530c5e9

Please sign in to comment.