예제 #1
0
    def __init__(self,
                 to='',
                 cc='',
                 bcc='',
                 subject='',
                 body=' ',
                 html='',
                 files=None,
                 reply_to='',
                 account=''):
        try:
            self.html = html.encode("utf-8")
            self.files = files
            if html != '':
                self.msg = MIMEMultipart('alternative')
                self.msg.attach(
                    MIMEText(body.encode("utf-8"), 'plain', _charset="utf-8"))
                self.msg.attach(
                    MIMEText(body.encode("utf-8"), 'html', _charset="utf-8"))
            else:
                self.msg = MIMEMultipart()
                self.msg.attach(
                    MIMEText(body.encode("utf-8"), 'plain', _charset="utf-8"))

            self.account = account
            username, password = auth.smtp_login(account=self.account)
            self.msg['From'] = username

            self.build(to, cc=cc, bcc=bcc, reply_to=reply_to, subject=subject)
        except:
            error_result = "Unexpected error in initiating Outlook Connection: %s, %s" \
                           % (sys.exc_info()[0], sys.exc_info()[1])
            print error_result
예제 #2
0
def go_to_concur_user_page():
    """ Use as a quick way to jump to the User Administration in Concur.
    :return: This function provides selenium initiated browsers.
    """
    try:
        baseurl = ''
        username = ''
        pw = ''
        username, pw = auth.bv_credentials()
        baseurl = "https://www.concursolutions.com/companyadmin/view_users.asp"

        baseurl = baseurl
        browser = get_se_browser()
        browser.get('https://bazaarvoice.okta.com/')
        wait(2)
        login_okta(browser, username, pw)
        wait(20)
        browser.get(
            'https://bazaarvoice.okta.com/home/concur/0oaeqjcwmIDXNCEXMUBI/615?fromHome=true'
        )
        wait(1)
        browser.get(baseurl)
        wait(3)

        return browser
    except:
        print "Unexpected error login:", sys.exc_info()[0], sys.exc_info(
        )[1], sys.exc_info()[2]
예제 #3
0
    def create_api_request(
            helpdesk_que='7256000001457777_MyView_7256000001457775',
            from_value=1):
        """ Create the api request for HD. At the moment very minimal
            but can be expanded in the future for creating more specific and different types of requests.
        :param helpdesk_que: This is the view name that can be created in the requests page
        :param from_value: Sets the beginning value in the list returned
        :param filter_request: Defines if the request is for the list of filters.
        :return: string of the URL, dict of the query, and a dict of the header
        """
        # Main HDT api URL
        url = "https://sdpondemand.manageengine.com/api/json/request"
        # Query values go in this json structure
        querystring = {
            "scope":
            "sdpodapi",
            "authtoken":
            auth.hdt_token(),
            "OPERATION_NAME":
            "GET_REQUESTS",
            "INPUT_DATA":
            "{operation:{"
            "Details:{"
            "FILTERBY:'%s', FROM:%s, LIMIT:100}}}" % (helpdesk_que, from_value)
        }

        # Header information
        headers = {
            'cache-control': "no-cache",
        }
        return url, querystring, headers
예제 #4
0
    def create_api_request(object='requisitions',
                           offset='',
                           record_id='',
                           **kwargs):
        """ Create the api request for Lever. At the moment very minimal
            but can be expanded in the future for creating more specific and different types of requests.
        :param object: This is the object name from the lever api
        :param offset: Sets the beginning value in the list returned
        :param record_id: Defines a specific id to retrieve on ly that record.
        :return: string of the URL, dict of the query, and a dict of the header
        """
        if record_id != '':
            record_id = '/' + record_id

        # Main Lever api URL
        url = "https://api.lever.co/v1/%s%s" % (object, record_id)

        querystring = {"includedeactivated": "true", "limit": "100"}

        if offset != '':
            # Query values go in this json structure
            querystring['offset'] = offset
        else:
            pass

        for key, value in kwargs.iteritems():
            querystring[key] = value

        # Header information
        headers = {
            'authorization': "Basic %s" % auth.lever_token(),
            'cache-control': "no-cache",
        }
        return url, querystring, headers
예제 #5
0
    def connect_to_SFDC(environment='prod'):
        user_name, pw, token, sandbox = auth.sfdc_login(environment)
        sf = Salesforce(username=user_name,
                        password=pw,
                        security_token=token,
                        sandbox=sandbox,
                        version='32.0')

        return sf
예제 #6
0
def start_form_fill(environment, first_name, last_name, email, user_name,
                    title, manager):
    baseurl = ''
    username = ''
    pw = ''
    if environment == 'prod':
        username, pw, token, sandbox = auth.sfdc_login('prod')
        baseurl = "https://na3.salesforce.com/005?retURL=%2Fui%2Fsetup%2FSetup%3Fsetupid%3DUsers&setupid=ManageUsers"
    elif environment == ('st' or 'staging'):
        username, pw, token, sandbox = auth.sfdc_login()
        baseurl = "https://cs77.salesforce.com/005?retURL=%2Fui%2Fsetup%2FSetup%3Fsetupid%3DUsers&setupid=ManageUsers"

    browser = get_se_browser()
    browser.get(baseurl)
    browser.implicitly_wait(4)
    login(browser, username, pw)
    wait(10)
    create_user(browser, first_name, last_name, email, user_name, title,
                manager)
예제 #7
0
    def send_email(self,
                   to='',
                   cc='',
                   bcc='',
                   subject='',
                   body=' ',
                   html='',
                   files='',
                   reply_to='',
                   account=''):
        """ Send email with or without variables passed in initiation.
        :param to: list or comma separated string of To emails addresses
        :param cc: list or comma separated string of CC emails addresses
        :param bcc: list or comma separated string of BCC emails addresses
        :param subject: string of the subject for the email
        :param body: HTML or Plain text body of email
        :param html: HTML of the text in the body of the email
        :param files: file address of attachment for the email
        :param reply_to: list or comma separated string of reply_to emails

        """
        # TODO - create user interactive section here.

        if body != ' ':
            self.__init__(to,
                          cc,
                          bcc,
                          subject,
                          body,
                          html,
                          files,
                          reply_to,
                          account=account)

        try:
            username, password = auth.smtp_login(account=self.account)
            self.msg['From'] = username

            all_emails = self.to + self.cc + self.bcc + self.reply_to

            email_connection = OutlookConnection.connect_mail(
                username, password)

            if self.files != '' and self.files is not None:
                self.attach_file()

            email_connection.sendmail(username, all_emails,
                                      self.msg.as_string())

            email_connection.quit()
            print 'Message sent'
        except:
            error_result = "Unexpected error in sending Email: %s, %s" % (
                sys.exc_info()[0], sys.exc_info()[1])
            print error_result
    def create_api_request(from_value=1, query='', open_only=False):
        """ Create the api request for HD. At the moment very minimal
            but can be expanded in the future for creating more specific and different types of requests.
        :param open_only: boolean for open only ticket or all tickets.
        :param query: This is email that is being serached for.
        :param from_value: Sets the beginning value in the list returned
        :return: string of the URL, dict of the query, and a dict of the header
        """
        # print from_value
        # Main HDT api URL
        url = "https://sdpondemand.manageengine.com/app/itdesk/api/v3/requests"

        query_first_part = "{'list_info':{""'start_index':%s," \
                           "'get_total_count':'true'," \
                           "'row_count':100," \
                           "'fields_required':['id','display_id','subject', 'status','attachments'," \
                           "'has_notes','site','responded_time','deleted_on','time_elapsed ','created_time'," \
                           "'category','group','approval_status','first_response_due_by_time'," \
                           "'created_by','priority','due_by_time','template','department'," \
                           "'display_id','description','completed_time','has_attachments'," \
                           "'requester','technician','mode','sla', 'resolution', 'resolved_time', " \
                           "'level','item','subcategory','udf_fields']," % from_value

        if open_only:
            query_in_progress = ",'logical_operator': 'AND'," \
                                "'children':[{'field':'status.in_progress','condition': 'is','value': 'true'," \
                                "'logical_operator': 'AND'}]}]"
        else:
            query_in_progress = "}]"

        if '@' in query:
            query_for_email = "'field':'requester.email_id'," \
                              "'condition':'is'," \
                              "'values':['%s']%s" \
                              "}}" % (query, query_in_progress)

            search_criteria = query_for_email
        else:
            query_for_group = "'field':'group.name','condition':'is','values':%s%s}}" % (
                str(query), query_in_progress)
            search_criteria = query_for_group

        # Query values go in this json structure
        query_string = {
            "input_data":
            query_first_part + "'search_criteria':[{" + search_criteria
        }

        # Header information
        headers = {
            'Accept': "application/vnd.manageengine.sdp.v3+json",
            'Authorization': auth.hdt_token()
        }
        return url, query_string, headers
예제 #9
0
def okta_load(first_name, last_name):
    username, pw = auth.bv_credentials()
    baseurl = "https://bazaarvoice-admin.okta.com/admin/user"

    browser = get_se_browser()
    browser.get(baseurl)
    browser.implicitly_wait(4)

    login_okta(browser, username, pw)
    wait(5)

    okta_fill_out_form(browser, first_name, last_name)
예제 #10
0
def go_to_sfdc_page(environment='', url_ending=''):
    """ Use as a quick way to deploy multiple windows in an environment.
    :param environment: Label as 'prod' and '' will route to staging.
    :param url_ending: The record id is the id that would normally go at the end of the url to get to the webpage.
    :return: Returns nothing. This function provides selenium initiated browsers.
    """
    baseurl = ''
    username = ''
    pw = ''
    if environment == 'prod':
        username, pw, token, sandbox = auth.sfdc_login('prod')
        baseurl = "https://na3.salesforce.com/"
    elif environment == ('st' or 'staging'):
        username, pw, token, sandbox = auth.sfdc_login()
        baseurl = "https://cs77.salesforce.com/"

    baseurl = baseurl + url_ending
    browser = get_se_browser()
    browser.get(baseurl)
    wait(3)
    login(browser, username, pw)

    return browser
예제 #11
0
    def connect_to_aws_elastic_search(host, environment='prod'):
        """ Create the main AWS elastic search connecting object.
        :param environment: the AWS environment you wish to access
        :return: aws elastic search object.
        """
        awsauth = auth.aws_connect()
        es = Elasticsearch(
            hosts=[{'host': host, 'port': 443}],
            http_auth=awsauth,
            use_ssl=True,
            verify_certs=True,
            connection_class=RequestsHttpConnection
        )

        return es
예제 #12
0
    def __init__(self, primary_object='', limit='100', filter='', data=None):
        if data is None:
            self.data = {}
        else:
            self.data = data
        if filter in ['active', 'Active']:
            filter = 'status eq \"ACTIVE\"'

        self.headers = auth.okta_authentication()
        self.primary_object = primary_object
        self.query = {"limit": limit, "filter": filter}
        if self.query['filter'] == '':
            del self.query['filter']
        if self.query['limit'] == '':
            del self.query['limit']
        self.api_url = 'https://bazaarvoice.okta.com/api/v1/' + self.primary_object
예제 #13
0
    def run_test(self, environment='staging'):
        """ Use as a quick way to jump to the Live chat portal in spark.
        :return: This function provides selenium initiated self.browsers.
        """
        try:
            username, pw = auth.spark_credentials()
            self.domain = self.domain[environment]
            baseurl = self.domain + "force.com/cp/cplogin"
            self.browser.get(baseurl)
            wait(8)
            self.login_spark(username, pw)
            wait(9)
            case_url = self.domain + 'force.com/cp/sprkCases?cat=Business+or+Technical+Question&page=LeftNavOncphome'
            self.browser.get(case_url)
            wait(1)
            self.browser.find_element_by_xpath("//span[@class='liveAgent gold']").click()
            wait(10)

            # Determine main window reference
            main_window_handle = None
            while not main_window_handle:
                main_window_handle = self.browser.current_window_handle
            # Switch to Live chat window pop up
            switch_to_pop_up(self.browser, main_window_handle)
            wait(10)
            self.check_for_agent_reply()

            # return self.browser

        except selenium.common.exceptions.ElementNotVisibleException:
            error_message = "Unexpected error login:%s, %s" \
                            % (sys.exc_info()[0], sys.exc_info()[1])
            return error_message
        except Exception:
            # try:
            error_message = "Unexpected error login:%s, %s" \
                            % (sys.exc_info()[0], sys.exc_info()[1])
            # notify_help_desk(self.browser, error_message)
            print error_message
            print "we get this far"
            # except:
            #     error_message = "Catastrophic error: Unexpected error login:%s, %s" \
            #                     % (sys.exc_info()[0], sys.exc_info()[1])
            #     oc.send_email('*****@*****.**', cc='', body=error_message)
            #     self.browser.close()
            return error_message
예제 #14
0
def add_permission_sfdc(browser='', user_id=''):
    """
    :param browser:
    :param user_id:
    :return:
    """
    edit_profile_url_end = '?noredirect=1&isUserEntityOverride=1'
    username = ''
    pw = ''
    try:
        base_url = browser.current_url
        url = base_url + user_id + edit_profile_url_end
        browser.get(url)
    except:
        browser = get_se_browser()
        username, pw, token, sandbox = auth.sfdc_login('')
        base_url = 'https://na3.salesforce.com/'
        url = base_url + user_id + edit_profile_url_end

    element = browser.find_element_by_xpath(
        "//span[contains(.,'Permission Set Assignments[1]')]")
    hover(browser, element)
    browser.find_element_by_xpath(
        "//input[@name='editPermSetAssignments']").click()
예제 #15
0
__author__ = 'Lothilius'

import phue
from os import environ
from se_helpers.actions import wait
from bv_authenticate.Authentication import Authentication as auth

hue_ip, hue_token = auth.hue_bridge()
light_bridge = phue.Bridge(hue_ip, username=hue_token)

light_bridge.connect()

print light_bridge.get_api()

# 'on' : True|False , 'bri' : 0-254, 'sat' : 0-254, 'ct': 154-500
# while True:
light_bridge.set_light(1, parameter={"effect": "none"})
light_bridge.set_light(1, parameter={"hue": 25500})
wait(.5)
light_bridge.set_light(1, parameter={"alert": "select"})
wait(.5)
light_bridge.set_light(1, parameter={"alert": "select"})
wait(.5)
light_bridge.set_light(1, parameter={"alert": "select"})

# light_bridge.set_light(1, parameter={"hue": 25500})

light_bridge.set_light(1, parameter={"effect": "colorloop"})

# wait(2)
# light_bridge.set_light(1, parameter={'xy': [0.15, 0.7]})
예제 #16
0
def main():
    try:
        all_wd_employees = []
        for each in work_day_groups.groups['id'].tolist():
            # Get Users from Okta that are in the list of Workday groups
            mfa_users = Okta_Group_Members(group_id=each)
            mfa_employees = mfa_users.group_members
            all_wd_employees.append(mfa_employees)

        # Union all data frames
        all_wd_employees = pd.concat(all_wd_employees, ignore_index=True)

        # Get Users from Okta that are in mfa-everywhere group
        mfa_users = Okta_Group_Members(group_id=m_f_group)
        mfa_employees = mfa_users.group_members

        # Do an left outer join so all Workday employees and their MFA profiles are matched up
        left_wd_join = pd.merge(left=all_wd_employees,
                                right=mfa_employees[['email', 'login']],
                                how='left',
                                on='email',
                                suffixes=('_wd', '_mfa'))

        # Any Null in login_mfa column are not in MFA group.
        employees_without_mfa = left_wd_join[
            left_wd_join['login_mfa'].isnull()].copy()  # type: pd.DataFrame

        # If employees_without_mfa is not Empty then apply mfa group to user missing the group and publish full list.
        if not employees_without_mfa.empty:
            # Apply mfa group to each user without mfa
            employees_without_mfa['result'] = employees_without_mfa[
                'email'].apply(mfa_users.add_user_to_group)

            # Reduce to Success list
            employees_success = employees_without_mfa[
                employees_without_mfa['result'].str.contains('Success')][[
                    'email', 'firstName'
                ]]

            # Send Email notifiying user of the change
            for each in employees_success.values.tolist():
                mfa_notify(each)
                wait(1)

            left_wd_join = pd.merge(
                left=left_wd_join,
                right=employees_without_mfa[['email', 'result']],
                how='left',
                on='email',
                suffixes=('_wd', '_results'))

            try:
                # Package in to a tde file
                data_file = TDEAssembler(data_frame=left_wd_join,
                                         extract_name='MFA_Employee_data')
                # Set values for publishing the data.
                file_name = str(data_file)
                server_url, username, password, site_id, data_source_name, project = \
                    auth.tableau_publishing(datasource_type='BizApps', data_source_name='MFA_Employee_data')
                # Publish the data
                publish_data(server_url,
                             username,
                             password,
                             site_id,
                             file_name,
                             data_source_name,
                             project,
                             replace_data=True)
            except Exception, e:
                error_result = "Unexpected Error: %s, %s, %s" \
                               % (sys.exc_info()[0], sys.exc_info()[1], e)
                subject = 'Error with MFA true up script. Could not publish user list to Tableau. %s' % basename(
                    __file__)
                print error_result
                outlook().send_email('*****@*****.**',
                                     cc='*****@*****.**',
                                     subject=subject,
                                     body=error_result)
                give_notice = Notifier()
                give_notice.set_red()
                give_notice.wait(30)
                give_notice.flow_the_light()

        # Get Style sheet for the email.
        html = HTMLParser()
        f = open(get_static_file('styleTags.html'), 'r')
        style = f.readlines()
        style = ' '.join(style)
        style = html.unescape(style)
        employees_without_mfa = employees_without_mfa[[
            'id', 'email', 'result'
        ]].to_html(index=False, show_dimensions=True)
        body = '<html><head>%s</head><body>' % style + '<h2>MFA_User_application compiling complete</h2><br><br>' \
               '<h2>List of Users Below</h2>' + html.unescape(employees_without_mfa) + \
               '<br><br></body></html>'

        outlook().send_email(to='*****@*****.**',
                             subject='MFA_User_application Complete',
                             body=body,
                             html=body)
예제 #17
0
    def create_light_bridge_object():
        hue_ip, hue_token = auth.hue_bridge()
        light_bridge = phue.Bridge(hue_ip, username=hue_token)

        return light_bridge
예제 #18
0
__author__ = 'Lothilius'

from selenium import webdriver, common
from selenium.webdriver.support.select import Select
from bv_authenticate.Authentication import Authentication as auth
import sys

baseurl = "https://cs2.salesforce.com/005?retURL=%2Fui%2Fsetup%2FSetup%3Fsetupid%3DUsers&setupid=ManageUsers"

browser = webdriver.Firefox()
username, pw = auth.sfdc_login()


# Login function
def login(browser):
    #Write Username in Username TextBox
    browser.find_element_by_name("username").send_keys(username)

    #Write PW in Password TextBox
    browser.find_element_by_name("pw").send_keys(pw)

    #Click Login button
    browser.find_element_by_css_selector("#Login").click()


# Open the Form to create a new user.
def open_new_record():
    browser.implicitly_wait(4)
    displayed = browser.find_element_by_name("new").is_displayed()
    if not displayed:
        for i in range(0, 3):