def get_git_project(path_with_namespace):
     r1 = None
     getURL = Constants.Default.URL.GitLab.Projects.TEXT + \
         path_with_namespace
     logger.debug("Get project URL: " + getURL)
     headers = dict()  # Create header for post request.
     headers['Content-type'] = 'application/json'
     headers['PRIVATE-TOKEN'] = settings.GITLAB_TOKEN
     try:
         r1 = requests.get(getURL, headers=headers, verify=False)
         counter = 0
         while r1.status_code == 404 or r1.content == b'[]' and \
             counter <= Constants.\
                 GitLabConstants.RETRIES_NUMBER:
             time.sleep(session.wait_until_time_pause)
             r1 = requests.get(getURL, headers=headers, verify=False)
             logger.debug("trying to get the git project, " +
                          "yet to succeed (try #%s)" % counter)
             counter += 1
         Helper.internal_assert(r1.status_code, 200)
         if r1.content == b'[]':
             logger.error("Got an empty list as a response.")
             raise
         logger.debug("Project exists on APIGitLab!")
         content = r1.json()  # Change it from list to dict.
         return content
     except BaseException:
         if r1 is None:
             logger.error("Failed to get project from APIGitLab.")
         else:
             logger.error(
                 "Failed to get project from APIGitLab, " +
                 "see response >>> %s %s \n %s" %
                 (r1.status_code, r1.reason, str(r1.content, 'utf-8')))
         raise
    def get_jenkins_job(job_name):
        r1 = None
        counter = 0
        getURL = settings.JENKINS_URL + "job/" + job_name
        logger.debug("Get APIJenkins job URL: " + getURL)
        try:
            r1 = requests.get(getURL,
                              auth=HTTPBasicAuth(settings.JENKINS_USERNAME,
                                                 settings.JENKINS_PASSWORD))
            while r1.status_code != 200 and counter <= \
                    Constants.GitLabConstants.RETRIES_NUMBER:
                r1 = requests.get(
                    getURL,
                    auth=HTTPBasicAuth(settings.JENKINS_USERNAME,
                                       settings.JENKINS_PASSWORD))
                time.sleep(session.wait_until_time_pause)
                logger.debug("try to get jenkins job (try #%s)" % counter)
                counter += 1
            Helper.internal_assert(r1.status_code, 200)
            logger.debug("Job was created on APIJenkins!")
        except BaseException:
            msg = None

            if r1 is None:
                msg = "APIJenkins didn't create job for %s" % job_name
            else:
                msg = "APIJenkins didn't create job for %s, " +\
                    "see response >>> %s %s" % (
                        job_name, r1.status_code, r1.reason)

            logger.error(msg)
            raise Exception(msg)
 def test_ecomp_dropdown_ordering(self):
     new_ecomp_release = None
     try:
         new_ecomp_release = {
             "uuid": uuid.uuid4(),
             "name": Helper.rand_string()
         }
         DB.VirtualFunction.change_ecomp_release_weight(10, 0)
         DB.VirtualFunction.insert_ecomp_release(new_ecomp_release['uuid'],
                                                 new_ecomp_release['name'])
         Frontend.User.login(self.user_content['el_email'],
                             Constants.Default.Password.TEXT)
         Frontend.DetailedView.search_vf_and_go_to_detailed_view(
             self.user_content['engagement_manual_id'],
             self.user_content['vfName'])
         Frontend.DetailedView.click_on_update_ecomp_release()
         Helper.internal_assert(
             Frontend.General.get_meta_order_of_element(
                 Constants.Dashboard.DetailedView.ECOMP.Dropdown.
                 UniversalRelease.ID % new_ecomp_release['name']), 0)
     finally:
         if new_ecomp_release:
             DB.VirtualFunction.delete_ecomp_release(
                 new_ecomp_release['uuid'], new_ecomp_release['name'])
         DB.VirtualFunction.change_ecomp_release_weight(0, 10)
Beispiel #4
0
 def set_ssh(user_content, sshKey=None):  # Set SSH key to user.
     r1 = None
     if sshKey is None:
         logger.debug("About to generate an ssh key for the user: %s" %
                      user_content['email'])
         sshKey = Helper.generate_sshpub_key()
     postURL = settings.ICE_EM_URL + '/v1/engmgr/users/ssh'
     logger.debug("Post user URL: " + postURL)
     headers = dict()  # Create header for post request.
     headers['Content-type'] = 'application/json'
     headers['Authorization'] = user_content['session_token']
     post_data = dict()  # Create JSON data for post request.
     post_data['ssh_key'] = sshKey
     try:
         r1 = requests.post(
             postURL, json=post_data, headers=headers, verify=False)
         Helper.internal_assert(r1.status_code, 200)
         logger.debug(
             "SSH Key was added successfully")
         if not APIBridge.is_gitlab_ready(user_content):
             raise
         return sshKey
     except BaseException:
         if r1 is None:
             logger.error("Failed to add public SSH key.")
         else:
             logger.error(
                 "POST request failed to add SSH key to user, " +
                 "see response >>> %s %s" %
                 (r1.status_code, r1.reason))
         raise
 def get_git_user_ssh_key(git_user_id):
     r1 = None
     getURL = Constants.Default.URL.GitLab.Users.TEXT + \
         str(git_user_id) + "/keys"
     logger.debug("Get user URL: " + getURL)
     headers = dict()  # Create header for post request.
     headers['Content-type'] = 'application/json'
     headers['PRIVATE-TOKEN'] = settings.GITLAB_TOKEN
     try:
         r1 = requests.get(getURL, headers=headers, verify=False)
         Helper.internal_assert(r1.status_code, 200)
         if r1.content == '[]':
             logger.error("Got an empty list as a response.")
             raise
         logger.debug("Got %s %s and received user's public key." %
                      (r1.status_code, r1.reason))
         content = r1.json()  # Change it from list to dict.
         gitPubKey = content[0]['key']
         return gitPubKey
     except BaseException:
         if r1 is None:
             logger.error("Failed to get user's public key " +
                          "from APIGitLab.")
         else:
             logger.error(
                 "Failed to get user's public key from APIGitLab, " +
                 "see response >>> %s %s \n %s" %
                 (r1.status_code, r1.reason, str(r1.content, 'utf-8')))
         raise
Beispiel #6
0
 def get_to_create_new_ns_modal_via_overview():
     Click.id(Constants.Dashboard.Overview.NextSteps.Add.ID,
              wait_for_page=True)
     Wait.text_by_css(Constants.Dashboard.Checklist.AddNS.CSS,
                      Constants.Dashboard.Overview.NextSteps.Add.TITLE)
     Helper.internal_assert(Constants.Dashboard.Checklist.AddNS.TITLE,
                            Get.by_css(Constants.FEGeneral.CSS.H2))
Beispiel #7
0
 def assigned_one_NS_to_user(user_content):
     nextStepsNumber = int(
         Get.by_id("next-steps-header").split('(')[1][:-1])
     if (nextStepsNumber != 0):
         logger.error("assigned ns: " + str(nextStepsNumber))
         logger.error(
             "APIUser should not have assigned next steps at first login.")
         raise
     if (Get.by_id("next-steps-list") !=
             "No next steps are assigned to you."):
         logger.error(
             "No assigned next steps and text 'No next steps are " +
             "assigned to you.' was not found.")
         raise
     token = "token " + APIUser.login_user(user_content['el_email'])
     user_content['session_token'] = token
     logger.debug(
         "Adding new next step (via api) and assigning it to user " +
         user_content['full_name'])
     APIVirtualFunction.add_next_step(user_content)
     logger.debug("Refresh page and look for changes in assigned " +
                  "next steps section:")
     FEGeneral.refresh()
     logger.debug("    > Check if number has changed in 'Assigned To You'")
     FEUser.logout()
     FEUser.login(user_content['email'], Constants.Default.Password.TEXT)
     text = Get.by_id("next-steps-header", True)
     Helper.internal_assert(text, "Assigned To You (1)")
 def validate_target_lab_entry(date):
     Wait.text_by_css(Constants.Dashboard.DetailedView.TargetLabEntry.CSS,
                      Constants.Dashboard.DetailedView.TargetLabEntry.TEXT,
                      wait_for_page=True)
     actualDate = Get.by_css(
         Constants.Dashboard.DetailedView.TargetLabEntry.CONTENT_CSS)
     Helper.internal_assert(actualDate, date)
Beispiel #9
0
    def signup_invited_user(
            company,
            invited_email,
            invite_token,
            invite_url,
            user_content,
            is_contact_user="******",
            activate=False,
            wait_for_gitlab=True):
        r1 = None
        postURL = settings.ICE_EM_URL + '/v1/engmgr/signup'
        logger.debug("Post signup URL: " + postURL)
        if is_contact_user == "true":
            fullName = re.sub("http.*full_name=", "", invite_url)
            fullName = re.sub("&.*", "", fullName)
            logger.debug(
                "Invited contact full name is (according to url): " + fullName)
        else:
            fullName = Helper.rand_string('randomString')

        post_data = dict()  # Create JSON data for post request.
        post_data['company'] = company
        post_data['email'] = invited_email
        post_data['full_name'] = fullName
        post_data['invitation'] = invite_token
        post_data['is_contact_user'] = is_contact_user
        post_data['password'] = "******"
        post_data['phone_number'] = "+1201" + \
            Helper.rand_string("randomNumber", 6)
        post_data['regular_email_updates'] = "False"
        post_data['terms'] = "True"
        try:
            requests.get(invite_url, verify=False)
            r1 = requests.post(
                postURL, json=post_data, verify=False)
            Helper.internal_assert(r1.status_code, 200)
            logger.debug("Invited user signed-up successfully!")

            user_data = r1.json()
            if activate:
                APIUser.activate_user(
                    user_data['uuid'], user_data["user"]["activation_token"])

            if wait_for_gitlab:
                if not APIBridge.is_gitlab_ready(user_content):
                    raise
            return post_data
        except BaseException:
            if r1 is None:
                logger.error("Failed to sign up the invited team member.")
            else:
                logger.error(
                    "POST request failed to sign up the invited " +
                    "team member, see response >>> %s %s \n %s" %
                    (r1.status_code, r1.reason, str(
                        r1.content, 'utf-8')))
            raise
Beispiel #10
0
 def validate_feedback(description, user_email):
     query = "SELECT user_id FROM ice_feedback where " +\
         "description = '{desc}'".format(
             desc=description)
     feedback_user_uuid = DBGeneral.select_query(query)
     query = "SELECT id FROM ice_user_profile  where " +\
         "email = '{email}'".format(
             email=user_email)
     user_uuid = DBGeneral.select_query(query)
     Helper.internal_assert(user_uuid, feedback_user_uuid)
Beispiel #11
0
 def verify_num_of_existing_ids(requested_num_of_ids, id_prefix):
     existing_id_objects_in_page = 0
     ids = session.ice_driver.find_elements_by_xpath('//*[@id]')
     for id in ids:
         if id_prefix in id.get_attribute('id'):
             # Print id.tag_name (id name as string).
             logger.debug(id.get_attribute('id'))
             existing_id_objects_in_page += 1
     Helper.internal_assert(existing_id_objects_in_page,
                            requested_num_of_ids)
     logger.debug("verify_num_of_existing_ids succeeded")
Beispiel #12
0
 def create_new_checklist(newObj):
     try:
         newObjWithChecklist = None
         vfName = newObj[0]
         uuid = newObj[1]
         inviteEmail = newObj[2]
         # Fetch one AT&T user ID.
         vfuuid = DBGeneral.select_where("uuid", "ice_vf", "name", vfName,
                                         1)
         engagement_id = DBVirtualFunction.select_eng_uuid(vfName)
         engLeadEmail = DBUser.select_el_email(vfName)
         logger.debug("EL email: " + engLeadEmail)
         engagement_manual_id = DBGeneral.select_where(
             "engagement_manual_id", "ice_engagement", "uuid",
             engagement_id, 1)
         #    Click on all default next steps
         myVfName = engagement_manual_id + ": " + vfName
         actualVfNameid = "clickable-" + myVfName
         actualVfName = Get.by_id(actualVfNameid)
         Helper.internal_assert(myVfName, actualVfName)
         #    NEXT STEP ID
         Click.id(actualVfNameid, wait_for_page=True)
         FEOverview.complete_defaults_nextsteps(engagement_id)
         inviterURL = Constants.Default.InviteURL.Signup.TEXT + \
             vfuuid + "&inviter_uuid=" + uuid + "&email=" + inviteEmail
         #             time.sleep(2)
         FEGeneral.re_open(inviterURL)
         FEGeneral.form_validate_email(inviteEmail)
         #    Login with EL role
         FEGeneral.re_open(Constants.Default.LoginURL.TEXT)
         FEUser.login(engLeadEmail, Constants.Default.Password.TEXT)
         Wait.id(Constants.Dashboard.Statuses.Title.ID)
         Wait.id(engagement_manual_id)  # cheklist
         #    VALIDATE SCROLLING
         actualVfName = Get.by_id(actualVfNameid)
         myVfName = engagement_manual_id + ": " + vfName
         #             Wait.id(actualVfNameid)
         Wait.id(engagement_manual_id, wait_for_page=True)
         Click.id(actualVfNameid, wait_for_page=True)
         #    Create new checklist
         checklistName = FEChecklist.create_checklist(
             engagement_id, vfName, actualVfName, engagement_manual_id)
         checklistUuid = DBGeneral.select_where("uuid", "ice_checklist",
                                                "name", checklistName, 1)
         newObjWithChecklist = [
             checklistUuid, engLeadEmail, engagement_manual_id,
             actualVfNameid, myVfName, checklistName
         ]
         return newObjWithChecklist
     # If failed - count the failure and add the error to list of errors.
     except Exception as e:
         errorMsg = "Failed to create checklist." + str(e)
         raise Exception(errorMsg, "create_new_checklist")
Beispiel #13
0
 def get_export_dasboard_excel(token, keywords=""):
     postUrl = settings.EM_REST_URL + \
         "engagement/export/?stage=All&keyword=" + keywords
     headers = {"Authorization": token}
     r1 = requests.get(postUrl, headers=headers, verify=False)
     Helper.internal_assert(r1.status_code, 200)
     if (r1.status_code == 200):
         logger.debug("APIUser activated successfully!")
         return r1.content
     else:
         raise Exception("Failed to activate user >>> %s %s" %
                         (r1.status_code, r1.reason))
         return False
Beispiel #14
0
 def reject_checklist(newObj, checklistName):
     Click.xpath("//button[2]")
     vfName = newObj[0]
     engLeadFullName = DBUser.get_el_name(vfName)
     Enter.text_by_name(
         Constants.Dashboard.Checklist.Reject.Modal.Comment.NAME,
         "Reject state By :" + engLeadFullName)
     Helper.internal_assert("Checklist: " + checklistName,
                            Get.by_css("span.state-title.ng-binding"))
     Wait.text_by_id(Constants.Dashboard.Checklist.Reject.Modal.Button.ID,
                     Constants.Dashboard.Checklist.Reject.Modal.Button.TEXT)
     Click.id(Constants.Dashboard.Checklist.Reject.Modal.Button.ID)
     Wait.modal_to_dissappear()
Beispiel #15
0
 def add_nsteps(checklistUuid, actualVfNameid, myVfName, checklistName,
                newFileNames):
     Click.id(actualVfNameid, wait_for_page=True)
     checklistUuid = DBChecklist.select_where_cl_not_archive(
         "uuid", "ice_checklist", "name", newFileNames[0], 1)
     Click.id("checklist-" + checklistUuid, wait_for_page=True)
     Wait.text_by_id(Constants.Dashboard.Checklist.Name.ID, newFileNames[0])
     FEChecklist.add_next_step_updated(checklistName, newFileNames[1])
     #         vALIDATE SCROLLING
     actualVfNameid = "clickable-" + myVfName
     actualVfName = Get.by_id(actualVfNameid, wait_for_page=True)
     if actualVfName != '':
         Helper.internal_assert(myVfName, actualVfName)
Beispiel #16
0
 def verify_existing_files_in_list(items_list, id_to_search_for):
     element = session.ice_driver.find_elements_by_id(id_to_search_for)
     element_attribute_items = json.loads(element[0].get_attribute('name'))
     Helper.internal_assert(len(items_list),
                            len(element_attribute_items) - 1)
     extracted_files_list = list()
     for file in element_attribute_items:
         extracted_files_list.append(file['File'])
     for item in items_list:
         if item not in extracted_files_list:
             Helper.assertTrue(
                 False, "%s does not exist over the client's side" % item)
     logger.debug("verify_existing_files_in_list succeeded, " +
                  "All vf repo files are available for choosing.")
Beispiel #17
0
 def test_complete_next_steps(self):
     user_content = API.VirtualFunction.create_engagement(
         wait_for_gitlab=False)
     steps_uuids = DB.VirtualFunction.return_expected_steps(
         user_content['engagement_uuid'],
         Constants.EngagementStages.INTAKE,
         user_content['email'])
     Frontend.User.login(
         user_content['email'], Constants.Default.Password.TEXT)
     Frontend.Overview.click_on_vf(user_content)
     for step_uuid in steps_uuids:
         Frontend.Overview.complete_next_step_and_wait_for_it_to_disappear(
             step_uuid)
     Helper.internal_assert(Frontend.Overview.get_list_of_next_steps(), [])
Beispiel #18
0
 def check_cl_after_lineitem_added():
     template_name = Constants.Dashboard.LeftPanel.\
         EditChecklistTemplate.HEAT
     user_content = APIVirtualFunction.create_engagement()
     FEUser.login(Constants.Users.Admin.EMAIL,
                  Constants.Default.Password.TEXT)
     vfName = user_content['vfName']
     engagement_id = DBChecklist.fetchEngByVfName(vfName)
     engLeadEmail = DBUser.select_el_email(vfName)
     engagement_manual_id = DBChecklist.fetchEngManIdByEngUuid(
         engagement_id)
     FEOverview.click_on_vf(user_content)
     FEGeneral.re_open(Constants.Default.LoginURL.TEXT)
     FEUser.login(engLeadEmail, Constants.Default.Password.TEXT,
                  engagement_manual_id)
     Click.id(
         Constants.Dashboard.LeftPanel.EditChecklistTemplate.DASHBOARD_ID)
     Enter.text_by_id(
         Constants.Dashboard.LeftPanel.EditChecklistTemplate.SEARCH_ENG_ID,
         vfName)
     Click.id("test_" + vfName)
     checklistName = FEChecklist.create_checklist(engagement_id, vfName,
                                                  None,
                                                  engagement_manual_id)
     FEUser.go_to_admin()
     result = DBChecklist.fetchChecklistByName(checklistName)
     FEUser.go_to_admin()
     FEChecklistTemplate.click_on_template_name_on_navigation(
         Constants.Dashboard.LeftPanel.EditChecklistTemplate.HEAT,
         template_name)
     Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate.
              EDIT_LINE_ITEM_BTN)
     Enter.text_by_id(
         Constants.Dashboard.LeftPanel.EditChecklistTemplate.
         EDIT_LINE_ITEM_NAME,
         "test_lineitem_added_and_audit_log_on_dupl_cl-NAME")
     Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate.
              EDIT_LINE_ITEM_BTN)
     FEChecklistTemplate.click_on_save_and_assert_success_msg()
     Click.id(
         Constants.Dashboard.LeftPanel.EditChecklistTemplate.DASHBOARD_ID)
     Enter.text_by_id(
         Constants.Dashboard.LeftPanel.EditChecklistTemplate.SEARCH_ENG_ID,
         vfName)
     Click.id("test_" + vfName)
     Click.id("checklist-" + str(result))
     Helper.internal_assert(
         "1. automation",
         session.ice_driver.find_element_by_xpath("//li[@id='']").text)
Beispiel #19
0
    def test_e2e_checklist_positive_test(self):
        newObj, user_content = API.User.create_new_user_content()
        newObjWithChecklist = Frontend.Checklist.create_new_checklist(newObj)
        checklistUuid = newObjWithChecklist[0]
        engLeadEmail = newObjWithChecklist[1]
        engagement_manual_id = newObjWithChecklist[2]
        actualVfNameid = newObjWithChecklist[3]
        checklistName = newObjWithChecklist[5]
        DB.Checklist.state_changed("uuid", checklistUuid,
                                   Constants.ChecklistStates.Review.TEXT)
        DB.Checklist.update_decisions(checklistUuid, checklistName)

        Frontend.User.relogin(engLeadEmail, Constants.Default.Password.TEXT,
                              engagement_manual_id)
        Frontend.Checklist.click_on_checklist(user_content, checklistName)
        Frontend.Checklist.validate_reject_is_enabled()
        Frontend.Checklist.review_state_actions_and_validations(
            checklistName, user_content['vfName'], "review")

        Frontend.Checklist.cl_to_next_stage(actualVfNameid)
        engPeerReviewerLeadEmail = DB.Checklist.get_pr_email(checklistUuid)
        Frontend.User.relogin(engPeerReviewerLeadEmail,
                              Constants.Default.Password.TEXT)
        Frontend.Checklist.click_on_checklist(user_content, checklistName)
        Frontend.Checklist.validate_reject_is_enabled()
        Frontend.Checklist.review_state_actions_and_validations(
            checklistName, user_content['vfName'], "PEER")

        Frontend.Checklist.cl_to_next_stage(actualVfNameid)
        engPeerReviewerLeadEmail = DB.Checklist.get_admin_email(checklistUuid)
        Frontend.User.relogin(engPeerReviewerLeadEmail,
                              Constants.Default.Password.TEXT)
        Frontend.Checklist.search_by_vfname_for_not_local(user_content)
        Frontend.Checklist.click_on_checklist(user_content, checklistName)
        Frontend.Checklist.validate_reject_is_enabled()
        Frontend.Checklist.approval_state_actions_and_validations(
            checklistName, newObj, "APPROVAL")

        Frontend.Checklist.cl_to_next_stage(actualVfNameid)
        Frontend.User.relogin(engLeadEmail, Constants.Default.Password.TEXT)
        ownerLeadEmail = DB.Checklist.get_owner_email(checklistUuid)
        Helper.internal_assert(engLeadEmail, ownerLeadEmail)
        Frontend.Checklist.click_on_checklist(user_content, checklistName)
        Frontend.Checklist.approval_state_actions_and_validations(
            checklistName, newObj, "HANDOFF")

        Frontend.Checklist.cl_to_next_stage(actualVfNameid)
        Frontend.Checklist.click_on_checklist(user_content, checklistName)
Beispiel #20
0
 def test_validate_duplicate_invite(self):
     user_content = []
     for _ in range(3):
         user_content.append(
             API.VirtualFunction.create_engagement(wait_for_gitlab=False))
     Frontend.User.login(user_content[0]['email'],
                         Constants.Default.Password.TEXT)
     engName = user_content[0][
         'engagement_manual_id'] + ": " + user_content[0]['vfName']
     vf_left_nav_id = "clickable-" + engName
     Click.id(vf_left_nav_id)
     Frontend.Wizard.invite_team_members_modal(user_content[1]['email'])
     enguuid = DB.General.select_where(
         "uuid", "ice_engagement", "engagement_manual_id",
         user_content[0]['engagement_manual_id'], 1)
     invitation_token = DB.User.select_invitation_token(
         "invitation_token", "ice_invitation", "engagement_uuid", enguuid,
         user_content[1]['email'], 1)
     inviterURL = Constants.Default.InviteURL.Login.TEXT + invitation_token
     Frontend.General.re_open(inviterURL)
     title_id = "title-id-" + engName
     Frontend.User.login(user_content[1]['email'],
                         Constants.Default.Password.TEXT, title_id)
     vf_left_nav_id = "clickable-" + engName
     Click.id(vf_left_nav_id)
     actualVfName = Get.by_id(vf_left_nav_id)
     Helper.internal_assert(engName, actualVfName)
     Wait.text_by_id(Constants.Dashboard.Overview.Title.ID, engName)
     Frontend.User.logout()
     Frontend.User.login(user_content[0]['email'],
                         Constants.Default.Password.TEXT)
     engName = user_content[0][
         'engagement_manual_id'] + ": " + user_content[0]['vfName']
     vf_left_nav_id = "clickable-" + engName
     Click.id(vf_left_nav_id)
     Click.id(Constants.Dashboard.Overview.TeamMember.ID)
     Wait.text_by_css(
         Constants.Dashboard.Wizard.Title.CSS,
         Constants.Dashboard.Wizard.InviteTeamMembers.Title.TEXT)
     Enter.text_by_name("email", user_content[1]['email'])
     Wait.text_by_css(
         Constants.SubmitButton.CSS,
         Constants.Dashboard.Wizard.InviteTeamMembers.Button.TEXT)
     Click.css(Constants.SubmitButton.CSS)
     Wait.id(Constants.Toast.ID)
     Helper.internal_assert(Get.by_id(Constants.Toast.ID),
                            "Invite couldn't be created")
 def invite_and_validate_limit(user_content, vf_left_nav_id):
     Click.id(Constants.Dashboard.LeftPanel.AddEngagement.ID)
     FEWizard.add_vf()
     Click.id(Constants.Dashboard.Wizard.CloseButton.ID, wait_for_page=True)
     Click.id(vf_left_nav_id)
     Click.id(Constants.Dashboard.Overview.TeamMember.ID)
     Wait.text_by_css(
         Constants.Dashboard.Wizard.Title.CSS,
         Constants.Dashboard.Wizard.InviteTeamMembers.Title.TEXT)
     Enter.text_by_name("email", user_content[1]['email'])
     Wait.text_by_css(
         Constants.SubmitButton.CSS,
         Constants.Dashboard.Wizard.InviteTeamMembers.Button.TEXT)
     Click.css(Constants.SubmitButton.CSS)
     Wait.id(Constants.Toast.ID)
     Helper.internal_assert(Get.by_id(Constants.Toast.ID),
                            "Invite couldn't be created")
Beispiel #22
0
 def test_filter_next_steps_by_associated_files_via_pr(self):
     user_content = API.VirtualFunction.create_engagement()
     API.GitLab.git_clone_push(user_content)
     user_content['session_token'] = "token " + \
         API.User.login_user(user_content['el_email'])
     API.Checklist.create_checklist(user_content)
     next_step_uuid = API.VirtualFunction.add_next_step(
         user_content, [
             Constants.Dashboard.Overview.NextSteps.
             FilterByFileDropDown.FILE0_LINK_TEXT])
     Frontend.User.login(
         user_content['pr_email'], Constants.Default.Password.TEXT)
     Frontend.Overview.click_on_vf(user_content)
     Frontend.Overview.next_steps_filter_by_files()
     Helper.internal_assert(
         Frontend.Overview.get_next_step_description(0),
         DB.VirtualFunction.select_next_step_description(next_step_uuid))
 def test_aic_dropdown_ordering(self):
     new_aic_version = None
     try:
         DB.VirtualFunction.change_aic_version_weight(10, 0)
         new_aic_version = DB.VirtualFunction.insert_aic_version()
         Frontend.User.login(self.user_content['el_email'],
                             Constants.Default.Password.TEXT)
         Frontend.DetailedView.search_vf_and_go_to_detailed_view(
             self.user_content['engagement_manual_id'],
             self.user_content['vfName'])
         Frontend.DetailedView.click_on_update_aic_version()
         Helper.internal_assert(
             Frontend.General.get_meta_order_of_element(
                 Constants.Dashboard.DetailedView.AIC.Dropdown.
                 UniversalVersion.ID % new_aic_version['version']), 0)
     finally:
         if new_aic_version:
             DB.VirtualFunction.delete_aic_version(new_aic_version['uuid'])
         DB.VirtualFunction.change_aic_version_weight(0, 10)
Beispiel #24
0
 def update_account(user_content):
     r1 = None
     token = APIUser.login_user(user_content['email'])
     user_content['session_token'] = 'token ' + token
     sshKey = Helper.generate_sshpub_key()
     putURL = settings.ICE_EM_URL + '/v1/engmgr/users/account'
     logger.debug("Put user URL: " + putURL)
     headers = dict()  # Create header for put request.
     headers['Content-type'] = 'application/json'
     headers['Authorization'] = user_content['session_token']
 #   headers['Authorization'] = user_content['activation_token']
     put_data = dict()  # Create JSON data for put request.
     user_content['vendor'] = user_content['company']['name']
     if user_content['vendor'] == "AT&amp;T":
         put_data['company'] = "AT&T"
     else:
         put_data['company'] = user_content['vendor']
     put_data['email'] = user_content['email']
     put_data['full_name'] = user_content['full_name']
     put_data['password'] = ""
     put_data['phone_number'] = "+1201" + \
         Helper.rand_string("randomNumber", 6)
     put_data['ssh_key'] = sshKey
     try:
         r1 = requests.put(
             putURL, json=put_data, headers=headers, verify=False)
         Helper.internal_assert(r1.status_code, 200)
         logger.debug(
             "SSH Key was added successfully to user " +
             user_content['full_name'])
         if not APIBridge.is_gitlab_ready(user_content):
             raise
         return sshKey
     except BaseException:
         if r1 is None:
             logger.error("Failed to add public SSH key to user.")
         else:
             logger.error(
                 "PUT request failed to add SSH key to user, see " +
                 "response >>> %s %s \n %s" %
                 (r1.status_code, r1.reason, str(
                     r1.content, 'utf-8')))
         raise
Beispiel #25
0
 def create_vf(token):
     r1 = None
     postUrl = settings.EM_REST_URL + "vf/"
     targetVersion = DBGeneral.select_from("uuid", "ice_deployment_target",
                                           1)
     ecompRelease = DBGeneral.select_from("uuid", "ice_ecomp_release", 1)
     headers = dict()  # Create header for post request.
     headers['Content-type'] = 'application/json'
     headers['Authorization'] = 'token ' + token
     jdata = [{
         "virtual_function":
         Helper.rand_string("randomString"),
         "version":
         Helper.rand_string("randomString") +
         Helper.rand_string("randomNumber"),
         "target_lab_entry_date":
         time.strftime("%Y-%m-%d"),
         "target_aic_uuid":
         targetVersion,
         "ecomp_release":
         ecompRelease,
         "is_service_provider_internal":
         False
     }]
     try:
         r1 = requests.post(postUrl,
                            json=jdata,
                            headers=headers,
                            verify=False)
         Helper.internal_assert(r1.status_code, 200)
         logger.debug("Virtual Function created successfully!")
         content = r1.content[1:-1]
         return content
     except BaseException:
         if r1 is None:
             logger.debug("Failed to create VF >>> request failed!")
         else:
             logger.debug(
                 "Failed to create VF >>> %s %s \n %s" %
                 (r1.status_code, r1.reason, str(r1.content, 'utf-8')))
         raise
Beispiel #26
0
 def test_starred_recent_searchbar(self):
     actualVfName = Get.by_id(self.left_panel_eng_id)
     Helper.internal_assert(self.eng_title, actualVfName)
     Click.id(self.left_panel_eng_id)
     Wait.id("title-id-" + self.eng_title)
     Helper.internal_assert(
         self.user_content['engagement_manual_id'] +
         ":",
         Get.by_id(
             "title-id-" +
             self.eng_title))
     Click.id(Constants.Dashboard.Overview.Star.ID, wait_for_page=True)
     Wait.id("title-id-" + self.eng_title)
     Click.id(Constants.Dashboard.Overview.Star.ID, wait_for_page=True)
     Wait.id("title-id-" + self.eng_title, wait_for_page=True)
     Helper.internal_assert(
         self.eng_title, Get.by_id(self.left_panel_eng_id))
     Enter.text_by_xpath(
         "//input[@type='text']",
         self.user_content['engagement_manual_id'],
         wait_for_page=True)
     Wait.text_by_css(
         Constants.Dashboard.LeftPanel.SearchBox.Results.CSS,
         self.eng_title)
     Click.css(
         Constants.Dashboard.LeftPanel.SearchBox.Results.CSS,
         wait_for_page=True)
Beispiel #27
0
 def add_next_step(user_content, files=[]):
     r1 = None
     postURL = settings.ICE_EM_URL + '/v1/engmgr/engagements/' + \
         user_content['engagement_uuid'] + '/nextsteps'
     logger.debug("Post add next step URL: " + postURL)
     headers = dict()  # Create header for post request.
     headers['Content-type'] = 'application/json'
     headers['Authorization'] = user_content['session_token']
     data = dict()  # Create JSON data for post request.
     files_list = list()
     if isinstance(files, list):
         for file in files:
             files_list.append(file)
     else:
         files_list.append(files)
     data['files'] = files_list
     data['assigneesUuids'] = [user_content['uuid']]
     data['duedate'] = str(datetime.date.today())
     data['description'] = "API test - add next step."
     list_data = []
     list_data.append(data)
     try:
         r1 = requests.post(postURL,
                            json=list_data,
                            headers=headers,
                            verify=False)
         Helper.internal_assert(r1.status_code, 200)
         logger.debug("Next step was added to the engagement!")
         ns_uuid = r1.json()
         return ns_uuid[0]['uuid']
     except BaseException:
         if r1 is None:
             logger.error("Failed to add next step to VF " +
                          user_content['vfName'])
         else:
             logger.error(
                 "Failed to add next step to VF " + user_content['vfName'] +
                 ", see response >>> %s %s.\nContent: %s" %
                 (r1.status_code, r1.reason, str(r1.content, 'utf-8')))
         raise
 def update_ecomp_release(EcompName):
     count = 0
     try:
         Click.id(Constants.Dashboard.DetailedView.ValidationDetails.PLUS)
         Wait.text_by_id(
             Constants.Dashboard.Modal.TITLE_ID,
             Constants.Dashboard.DetailedView.ValidationDetails.TITLE,
             wait_for_page=True)
         Click.id(Constants.Dashboard.DetailedView.ECOMP.Dropdown.ID,
                  wait_for_page=True)
         Select(
             session.ice_driver.find_element_by_id(
                 Constants.Dashboard.DetailedView.ECOMP.Dropdown.ID)
         ).select_by_visible_text(EcompName)
         Click.id(Constants.Dashboard.DetailedView.ValidationDetails.
                  ECOMPRelease.ID_ECOMP + EcompName,
                  wait_for_page=True)
         count += 1
         Wait.id(Constants.Dashboard.DetailedView.ValidationDetails.
                 ECOMPRelease.ID_ECOMP + Constants.Dashboard.DetailedView.
                 ValidationDetails.ECOMPRelease.UNKNOW,
                 wait_for_page=True)
         Select(
             session.ice_driver.find_element_by_id(
                 Constants.Dashboard.DetailedView.ECOMP.Dropdown.ID)
         ).select_by_visible_text(Constants.Dashboard.DetailedView.
                                  ValidationDetails.ECOMPRelease.UNKNOW)
         Click.id(Constants.Dashboard.DetailedView.ValidationDetails.
                  ECOMPRelease.ID_ECOMP + Constants.Dashboard.DetailedView.
                  ValidationDetails.ECOMPRelease.UNKNOW,
                  wait_for_page=True)
         count += 1
         Click.id(Constants.Dashboard.DetailedView.ValidationDetails.SAVE,
                  wait_for_page=True)
         Helper.internal_assert(count, 2)
     # If failed - count the failure and add the error to list of errors.
     except BaseException:
         errorMsg = "Failed in update_ecomp_release ."
         raise Exception(errorMsg)
Beispiel #29
0
 def get_engagement(user_content):
     r1 = None
     postUrl = settings.EM_REST_URL + 'single-engagement/' + \
         str(user_content['engagement_uuid'],)
     headers = dict()  # Create header for post request.
     headers['Content-type'] = 'application/json'
     headers['Authorization'] = user_content['session_token']
     try:
         r1 = requests.get(postUrl, headers=headers, verify=False)
         Helper.internal_assert(r1.status_code, 200)
         logger.debug("Retrieved the Engagement successfully!")
         content = r1.content
         return json.loads(content)
     except BaseException:
         if r1 is None:
             logger.debug(
                 "Failed to Retrieve the Engagement >>> request failed!")
         else:
             logger.debug(
                 "Failed to Retrieve the Engagement >>> %s %s \n %s" %
                 (r1.status_code, r1.reason, str(r1.content, 'utf-8')))
         raise
Beispiel #30
0
 def update_account_injec_script(user_content):
     r1 = None
     putURL = settings.ICE_EM_URL + '/v1/engmgr/users/account'
     logger.debug("Put user URL: " + putURL)
     headers = dict()  # Create header for put request.
     headers['Content-type'] = 'application/json'
     headers['Authorization'] = user_content['session_token']
     put_data = dict()  # Create JSON data for put request.
     if user_content['vendor'] == "AT&amp;T":
         put_data['company'] = "AT&T"
     else:
         put_data['company'] = user_content['vendor']
     put_data['email'] = user_content['email']
     script = "<script>;</script>"
     put_data['full_name'] = script
     put_data['password'] = ""
     put_data['phone_number'] = "+1201" + \
         Helper.rand_string("randomNumber", 6)
     try:
         r1 = requests.put(
             putURL, json=put_data, headers=headers, verify=False)
         Helper.internal_assert(r1.status_code, 200)
         msg = "Testing for Cross site scripting successfully : " + \
             user_content['full_name'] + \
             "stattus Code = " + str(r1.status_code)
         logger.debug(msg)
         if not APIBridge.is_gitlab_ready(user_content):
             raise
         return True
     except BaseException:
         if r1 is None:
             logger.error("Failed to add public SSH key to user.")
         else:
             logger.error(
                 "PUT request failed to add SSH key to user, " +
                 "see response >>> %s %s \n %s" %
                 (r1.status_code, r1.reason, str(
                     r1.content, 'utf-8')))
         raise