예제 #1
0
    def role_delete(self, companyname, rolename, expectation):

        self.start_test(locals())

        self.login_company_admin()

        self.choose_company(companyname=companyname)

        self.role_manage_enter()

        found_role = self.role_search(rolename)

        if expectation != "pass":
            self.assert_true(found_role == {}, "Should not find role: " + rolename)
        else:
            self.assertTrue(found_role != {}, "Can not find role: " + rolename)

            all_deleted = False
            authority = Authority()
            while not all_deleted:
                delete_selector = found_role["delete_selector"]
                self.role_delete_action(delete_selector)
                self.remove_authority_record(
                    email_list=authority.get_email_list(bycolumn="role", value=rolename, company=companyname),
                    role={companyname: [rolename]})
                # self.remove_role_record(company=companyname, custome_role=[rolename])

                time.sleep(6)  # wait for refresh
                found_role = self.role_search(rolename)
                if found_role == {}:
                    all_deleted = True

        self.logout(COMPANYADMIN_ACCOUNT)

        self.end_test(self._testMethodName)
예제 #2
0
    def user_delete(self, companyname, username, expectation):

        self.start_test(locals())

        self.login_company_admin()

        self.choose_company(companyname=companyname)

        self.user_manage_enter()

        found_user = self.user_search(username)

        if expectation != "pass":
            self.assertTrue(found_user == {})
        else:
            self.assertTrue(found_user != {})

            all_deleted = False
            authority = Authority()
            while not all_deleted:
                delete_selector = found_user["delete_selector"]
                self.user_delete_action(delete_selector)
                self.remove_authority_record(email_list=[username], company=[companyname])
                time.sleep(10)  # wait refresh
                found_user = self.user_search(username)
                if found_user == {}:
                    all_deleted = True

        self.logout(COMPANYADMIN_ACCOUNT)

        self.end_test(self._testMethodName)
예제 #3
0
class TestRead(RoleManageBase):
    TNB = COMPANYADMIN_ROLE_READ_TNB
    datafile = COMPANYADMIN_ROLE_READ_DATA_FILE

    test_data_read_normal = utilities.gen_testdata(datafile,
                                                   delimiter=',',
                                                   header=0,
                                                   scenario='normal')

    @parameterized.expand(test_data_read_normal)
    @pytest.mark.scenario_regression_companyadmin(TNB + 1)
    def test_read_normal(self, companyname, rolename, expectation):
        self.role_read(companyname, rolename, expectation)

    authority = Authority()
    test_data_read_check_authority_info = authority.get_role_authority_info()

    @parameterized.expand(test_data_read_check_authority_info,
                          skip_on_empty=True
                          )  # skip_on_empty=True doesn't work
    @pytest.mark.scenario_regression_companyadmin(TNB + 2)
    @pytest.mark.scenario_regression(TNB + 1)
    def test_read_check_authority_info(self, company, role, email_list):
        self.check_authority_info(company=company,
                                  role=role,
                                  email_list=email_list,
                                  expectation="pass")
예제 #4
0
class TestRead(UserManageBase):
    TNB = COMPANYADMIN_USER_READ_TNB
    datafile = COMPANYADMIN_USER_READ_DATA_FILE

    authority = Authority()
    test_data_read_check_authority_info = authority.get_user_authority_info()

    @parameterized.expand(test_data_read_check_authority_info,
                          skip_on_empty=True)
    @pytest.mark.scenario_regression_companyadmin(TNB + 2)
    @pytest.mark.scenario_regression(TNB + 1)
    def test_read_check_authority_info(self, email, company_list, site_dict,
                                       role_dict):
        self.check_authority_info(email=email,
                                  company_list=company_list,
                                  site_dict=site_dict,
                                  role_dict=role_dict,
                                  expectation="pass")

    test_data_read_normal = utilities.gen_testdata(datafile,
                                                   delimiter=',',
                                                   header=0,
                                                   scenario='normal')

    @parameterized.expand(test_data_read_normal)
    @pytest.mark.scenario_regression_companyadmin(TNB + 1)
    def test_read_normal(self, companyname, username, expectation):
        self.user_read(companyname, username, expectation)
예제 #5
0
    def site_delete(self, companyname, sitename, expectation):

        self.start_test(locals())

        self.login_company_admin()

        self.choose_company(companyname=companyname)

        self.site_manage_enter()

        time.sleep(10)  # too slow
        found_site = self.site_search(sitename)

        if expectation != "pass":
            self.assert_true(found_site == {},
                             "Should not find site: " + sitename)
        else:
            self.assertTrue(found_site != {}, "Can not find site: " + sitename)

            all_deleted = False
            authority = Authority()
            while not all_deleted:
                delete_selector = found_site["delete_selector"]
                self.site_delete_action(delete_selector)
                self.remove_authority_record(
                    email_list=authority.get_email_list(bycolumn="site",
                                                        value=sitename,
                                                        company=companyname),
                    site={companyname: [sitename]})

                # after delete, user list does not show
                self.refresh_page()
                self.site_manage_enter()

                found_site = self.site_search(sitename)
                if found_site == {}:
                    all_deleted = True

        self.logout(COMPANYADMIN_ACCOUNT)

        self.end_test(self._testMethodName)
예제 #6
0
    def verify_companyadmin_password_email(self):

        self.start_test(locals())

        # get email_list
        authority = Authority()
        email_list = authority.get_email_list(bycolumn="role",
                                              value=ROLE_COMPANY_ADMIN)

        print("Start to check email and password for:  " + str(email_list))

        valuedict = self.verify_password_email(email_list)
        self.assert_true(
            valuedict != [],
            "Did not send email or password to: " + str(email_list))

        for item in valuedict:
            authority.add_authority(email=item["email"],
                                    password=item["password"])
        print(str(authority.df))
        authority.commit()

        self.end_test(self._testMethodName)
예제 #7
0
    def remove_authority_record(self,
                                email_list,
                                password=None,
                                status=None,
                                company: list = None,
                                site: dict = None,
                                role: dict = None):
        print("At remove_authority_record \n " + str(locals()))

        if email_list is None:
            return
        email_list = list(set(email_list))
        authority = Authority()
        for email in email_list:
            authority.remove_authority(email,
                                       company=company,
                                       site=site,
                                       role=role)
        print("At remove_authority_record, to save to file: ")
        print(str(authority.df))
        authority.commit()
예제 #8
0
    def add_authority_record(self,
                             email_list,
                             password=None,
                             status=None,
                             company: list = None,
                             site: dict = None,
                             role: dict = None):
        #print("At add_authority_record \n " + str(locals()))

        if email_list is None:
            return
        email_list = list(set(email_list))
        authority = Authority()
        for email in email_list:
            authority.add_authority(email,
                                    password=password,
                                    status=status,
                                    company=company,
                                    site=site,
                                    role=role)
        #print(str(authority.df))
        authority.commit()
예제 #9
0
    def company_update(self, companyname, valuedict, expectation):

        self.start_test(locals())

        companyname, key, value, expectation = self.process_update_input(
            companyname, valuedict, expectation)

        self.login_sysadmin()

        found_company = self.company_search(companyname)
        if found_company == {}:
            self.assertTrue(False, "Cannot find company: " + companyname)

        found_correct = found_company["companyname"] == companyname \
                        and self.get_text(found_company["name_selector"]) == found_company["companyname"] \
                        and self.get_text(found_company["id_selector"]) == found_company["id"]
        print("Found info: \n" + str(found_company))
        self.assert_true(
            found_correct,
            "Found info doesn't match what show on user interface \n" +
            "Try to find: " + companyname + "\n But find " +
            str(found_company))

        edit_selector = str(found_company["edit_selector"])

        if True:
            self.company_update_start(edit_selector)
            authority = Authority()

            company = companyname
            if "companyname" in key:
                company = str(value["companyname"])
                self.company_create_update_set_companyname(company)
                email_list = authority.get_email_list(bycolumn="company",
                                                      value=companyname)
                for email in email_list:
                    authority.update_authority_list_value_column(
                        email=email,
                        column="company",
                        value=[companyname],
                        action="remove")
                    authority.update_authority_list_value_column(
                        email=email,
                        column="company",
                        value=[company],
                        action="add")

            if "status" in key:
                status = str(value["status"])
                self.company_create_update_set_status(status)
            else:
                status = None

            if "email" in key:
                email_list = str(value["email"])
                email_list = utilities.str_to_list(email_list)
                if expectation == "illegal_email_msg":
                    fail_msg = "The email address is invalid"
                else:
                    fail_msg = None
                self.company_create_update_set_email(email_list=email_list,
                                                     fail_msg=fail_msg,
                                                     expectation=expectation)

                # deal with user profile
                # email list connected with target company
                existing_connected_email_list = authority.get_email_list(
                    bycolumn="company", value=company)

                to_add_connection_email_list = [
                    i for i in email_list
                    if i not in existing_connected_email_list
                ]
                print("To_add_connection_email_list:   " +
                      str(to_add_connection_email_list))
                for email in to_add_connection_email_list:
                    authority.add_authority(email=email, company=[company])

                to_delete_email_list = [
                    i for i in existing_connected_email_list
                    if i not in email_list
                ]
                print("To_delete_email_list:   " +
                      str(to_delete_email_list))  #remove connection
                for email in to_delete_email_list:
                    authority.update_authority_list_value_column(
                        email=email,
                        column="company",
                        value=[company],
                        action="remove")
            else:
                email_list = None

            self.company_create_update_submit(expectation)

            if expectation == "pass":
                self.verify_company_info(company, status, email_list)
                print("start to update user profile with: \n" +
                      str(authority.df))
                authority.commit()

        self.logout()

        self.end_test(self._testMethodName)
예제 #10
0
 def login_company_admin(self, username=COMPANYADMIN_ACCOUNT):
     authority = Authority()
     password = authority.get_user_info(email=COMPANYADMIN_ACCOUNT,
                                        column="password")
     self.login(username=COMPANYADMIN_ACCOUNT, password=password)
예제 #11
0
 def login_application_user(self, username=APPLICATION_USER_ACCOUNT):
     authority = Authority()
     password = authority.get_user_info(email=APPLICATION_USER_ACCOUNT,
                                        column="password")
     self.login(username=APPLICATION_USER_ACCOUNT, password=password)