Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into TEN-1366_Revise_Replication-sim…
Browse files Browse the repository at this point in the history
…plify
  • Loading branch information
markbainix committed Jun 24, 2024
2 parents d4a635f + 554c9d4 commit 59d03d8
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 14 deletions.
44 changes: 41 additions & 3 deletions keywords/webui/smb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,48 @@
from helper.cli import SSH_Command_Line
from helper.global_config import private_config
from helper.webui import WebUI
from keywords.ssh.smb import SSH_SMB as SSHSMB
from keywords.ssh.smb import SSH_SMB as SSH_SMB
from keywords.webui.common import Common as COM


class SMB:
@classmethod
def add_additional_acl_who_entry(cls, who_type: str, name: str = "", permissions: str = "FULL", type_field: str = "ALLOWED") -> None:
"""
This method creates a new entry of the given type, with the given name, permissions and type.
:param who_type: type of who to add. [user/group/everyone]
:param name: Optional for everyone, name of the user or group to add
:param permissions: Optional, defaults to FULL. [FULL/CHANGE/READ]
:param type_field: Optional, defaults to ALLOWED. [ALLOWED/DENIED]
Example:
- SMB.add_additional_acl_who_entry('group', 'admin_group')
- SMB.add_additional_acl_who_entry('everyone')
"""
who_type = who_type.lower()
COM.click_button("add-item-add-entry")
WebUI.delay(0.1)
COM.click_on_element(xpaths.smb.smb_acl_empty_entry_who())
match who_type:
case 'user':
who_type_cap = 'User'
case 'group':
who_type_cap = 'Group'
case 'everyone':
who_type_cap = 'everyone'
COM.click_on_element(xpaths.common_xpaths.option_field(f"ae-who-{who_type}"))
WebUI.delay(0.1)
if who_type != "everyone":
COM.set_input_field(who_type, rf"{name}")
WebUI.delay(0.1)
COM.click_on_element(xpaths.smb.smb_acl_select_field(who_type_cap, "perm"))
COM.click_on_element(xpaths.common_xpaths.option_field(f"ae-perm-{permissions.lower()}"))
WebUI.delay(0.1)
COM.click_on_element(xpaths.smb.smb_acl_select_field(who_type_cap, "type"))
COM.click_on_element(xpaths.common_xpaths.option_field(f"ae-type-{type_field.lower()}"))
WebUI.delay(0.1)

@classmethod
def assert_add_smb_share_button_is_restricted(cls):
"""
Expand Down Expand Up @@ -108,7 +145,7 @@ def assert_guest_delete_file(cls, file: str, share: str) -> bool:
Example:
- SMB.assert_guest_delete_file('myFile', 'myShare')
"""
return SSHSMB.assert_user_can_delete_file(file, share, 'nonexistent', 'nopassword')
return SSH_SMB.assert_user_can_delete_file(file, share, 'nonexistent', 'nopassword')

@classmethod
def assert_guest_put_file(cls, file: str, share: str) -> bool:
Expand All @@ -123,7 +160,7 @@ def assert_guest_put_file(cls, file: str, share: str) -> bool:
Example:
- SMB.assert_guest_put_file('myFile', 'myShare')
"""
return SSHSMB.assert_user_can_put_file(file, share, 'nonexistent', 'nopassword')
return SSH_SMB.assert_user_can_put_file(file, share, 'nonexistent', 'nopassword')

@classmethod
def assert_share_acl_configuration_field_visible(cls, field: str) -> bool:
Expand Down Expand Up @@ -628,3 +665,4 @@ def verify_smb_sessions_page_opens(cls):
COM.click_button('cifs-actions-menu-sessions')
assert COM.is_visible(xpaths.common_xpaths.link_field('breadcrumb-shares')) is True
assert COM.assert_page_header('SMB Status') is True

80 changes: 71 additions & 9 deletions test_cases/webui/active_directory/test_active_directory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import allure
import pytest

import xpaths
from helper.data_config import get_data_list
from helper.global_config import shared_config, private_config
from helper.webui import WebUI
Expand All @@ -13,6 +15,8 @@
from keywords.webui.directory_services import Directory_Services
from keywords.webui.navigation import Navigation
from keywords.webui.permissions import Permissions
from keywords.webui.common_shares import Common_Shares as COMSHARE
from keywords.webui.smb import SMB


@allure.tag('Active Directory', 'Directory Services')
Expand Down Expand Up @@ -101,17 +105,23 @@ def test_setup_active_directory(self, ad_data, setup_dns_for_active_directory):

WebUI.take_percy_snapshot("Active Directory Setup")

@allure.tag("defect_verification", "NAS-129528", 'Percy')
@allure.tag("defect_verification", "NAS-129528", "NAS-129686")
@allure.issue("NAS-129686", "NAS-129686")
def test_setup_active_directory_with_group_cache_disabled(self, ad_data, tear_down_class):
"""
This test case test setup active directory with the group cache disabled.
"""
# Setup SSH usage and dataset
Navigation.navigate_to_dashboard()
API_POST.start_service('ssh')
API_POST.start_service('cifs')
API_PUT.enable_user_ssh_password(private_config['USERNAME'])
API_PUT.enable_user_all_sudo_commands_no_password(private_config['USERNAME'])
API_POST.create_dataset("tank/group_cache_disabled")
API_POST.create_dataset("tank/group_cache_disabled_smb", "SMB")
API_POST.create_dataset("tank/group_cache_disabled_unix")
API_POST.create_dataset("tank/group_cache_disabled_nfsv4", "SMB")
API_POST.create_dataset("tank/group_cache_disabled_POSIX")
API_POST.create_share('smb', "group_cache_disabled_smb", "/mnt/tank/group_cache_disabled_smb")

# Click on the active directory settings button and edit the active directory configuration.
Navigation.navigate_to_directory_services()
Expand All @@ -130,21 +140,68 @@ def test_setup_active_directory_with_group_cache_disabled(self, ad_data, tear_do
assert Common.is_checked("disable-freenas-cache") is True
Common.close_right_panel()

# Navigate to datasets page and edit dataset group with manually typed AD group
# Create SMB share with ACL
Navigation.navigate_to_shares()
assert COMSHARE.assert_share_card_displays('smb') is True
SMB.click_edit_share_acl("group_cache_disabled_smb")
SMB.add_additional_acl_who_entry("group", r"AD03\domain guests")
Common.click_save_button_and_wait_for_right_panel()

# Verify share functionality
SMB.click_edit_share_acl("group_cache_disabled_smb")
# Expected failure below: https://ixsystems.atlassian.net/browse/NAS-129686
assert Common.assert_text_is_visible(r"AD03\domain guests") is True
Common.close_right_panel()
assert SMB.assert_user_can_access('group_cache_disabled_smb', ad_data['username'], ad_data['password']) is True

# Navigate to datasets page and edit unix dataset group with manually typed AD group
Navigation.navigate_to_datasets()
Datasets.select_dataset("group_cache_disabled")
Datasets.select_dataset("group_cache_disabled_unix")
Datasets.click_edit_permissions_button()
Permissions.set_apply_group_checkbox()
Permissions.set_dataset_group(r"AD03\domain guests")
Common.set_input_field('gid', r"AD03\domain guests", True)
Common.click_save_button()

# Verify dataset group has saved in UI and CLI
# Verify unix dataset group has saved in UI and CLI
assert Permissions.assert_dataset_group(r"AD03\domain guests") is True
assert Perm_SSH.verify_getfacl_contains_permissions("/mnt/tank/group_cache_disabled",
assert Perm_SSH.verify_getfacl_contains_permissions("/mnt/tank/group_cache_disabled_unix",
r"# group: AD03\\domain\040guests") is True

# Delete dataset
API_DELETE.delete_dataset("tank/group_cache_disabled")
# Edit POSIX dataset group with manually typed AD group
Datasets.select_dataset("group_cache_disabled_POSIX")
Datasets.click_edit_permissions_button()
Permissions.click_set_acl_button()
Common.assert_dialog_visible('Select a preset ACL')
Common.click_radio_button("use-preset-create-a-custom-acl")
Common.click_button('continue')
Common.assert_page_header('Edit ACL')
Permissions.click_add_item_button()
Permissions.select_ace_who("group")
Common.set_input_field("group", r"AD03\domain guests")
Common.set_checkbox('permissions-read')
Permissions.click_add_item_button()
Permissions.select_ace_who("mask")
Common.set_checkbox('permissions-read')
Permissions.click_save_acl_button()

# Verify POSIX dataset group has saved in UI and CLI
assert Common.is_visible(xpaths.datasets.dataset_permissions_item(r'Group – AD03\domain guests', "Read")) is True
assert Perm_SSH.verify_getfacl_contains_permissions("/mnt/tank/group_cache_disabled_POSIX",
r"group:AD03\\domain\040guests:r--") is True

# Edit nfsv4 dataset group with manually typed AD group
Datasets.select_dataset("group_cache_disabled_nfsv4")
Datasets.click_edit_permissions_button()
Permissions.click_add_item_button()
Permissions.select_ace_who("group")
Common.set_input_field("group", r"AD03\domain guests")
Permissions.click_save_acl_button()

# Verify nfsv4 dataset group has saved in UI and CLI
assert Datasets.is_permissions_advanced_item_visible("Group", r"AD03\domain guests") is True
assert Perm_SSH.verify_getfacl_contains_permissions("/mnt/tank/group_cache_disabled_nfsv4",
r"group:AD03\domain guests:rwxpDdaARWc--s:fd-----:allow",
"NFSv4") is True

def test_setup_active_directory_with_misconfigured_dns(self, ad_data, setup_dns_for_ad_with_a_second_nameserver):
"""
Expand Down Expand Up @@ -183,3 +240,8 @@ def tear_down_class(self, request, ad_data):
elif request.node.report.failed and 'leave_active_directory' in request.node.name:
API_POST.leave_active_directory(ad_data['username'], ad_data['password'])
API_PUT.set_nameservers(ad_data['nameserver1'], ad_data['nameserver2'])
API_DELETE.delete_dataset("tank/group_cache_disabled_unix")
API_DELETE.delete_dataset("tank/group_cache_disabled_nfsv4")
API_DELETE.delete_dataset("tank/group_cache_disabled_POSIX")
API_DELETE.delete_dataset("tank/group_cache_disabled_smb")
API_DELETE.delete_share("smb", "group_cache_disabled_smb")
24 changes: 22 additions & 2 deletions xpaths/smb.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@


def smb_acl_empty_entry_who() -> str:
"""
This function returns the text for the first empty who field in the SMB ACL panel
:return: xpath string for the first empty who field in the SMB ACL panel
"""
return '(//*[contains(@class, "select-placeholder")]/ancestor::ix-select//*[@data-test="select-ae-who"])[1]'


def smb_acl_select_field(entry_type: str, field_type: str) -> str:
"""
This function returns the text for the given share ACL select field
:param entry_type: type of the entry. [user/group]
:param field_type: type of the field. [perm/type]
:return: xpath string for given share ACL select field
"""
return f'//*[contains(text(),"{entry_type}")]/ancestor::ix-list-item//*[@data-test="select-ae-{field_type}"]'


def smb_share_options(name: str) -> str:
"""
This function sets the text for the given share name
This function returns the text for the given share name options button
:param name: name of the given share
:return: xpath string for given share name
:return: xpath string for given share name options button
"""
return f'//*[@data-test="row-{name}"]//*[@data-test="button-samba-options"]'

0 comments on commit 59d03d8

Please sign in to comment.