Exemplo n.º 1
0
 def get_authenticated_iphone_7_emulation(self):
     code, self.bearer_header = make_iap_request(HOST_URL, CLIENT_ID)
     assert code == 200, 'Did not get 200 creating bearer token: %d' % (
         code)
     self.custom_modified_headers = create_modheaders_plugin(
         remove_headers=[],
         add_or_modify_headers={
             "Authorization": self.bearer_header["Authorization"]
         })
     self.device = {
         'deviceMetrics': {
             'width': 750,
             'height': 1334,
             'pixelRatio': 2.0
         },
         'userAgent':
         'Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 like Mac OS X) \
         AppleWebKit/602.4.6 (KHTML, like Gecko) \
         Version/10.0 Mobile/14D27 Safari/602.1'
     }
     self.chrome_options = webdriver.ChromeOptions()
     self.chrome_options.add_argument("--start-maximized")
     self.chrome_options.add_experimental_option("mobileEmulation",
                                                 self.device)
     self.chrome_options.add_extension(self.custom_modified_headers)
     self.browser = webdriver.Chrome(executable_path='chromedriver',
                                     chrome_options=self.chrome_options)
     return self.browser
Exemplo n.º 2
0
 def get_authenticated_custom_emulation(self):
     code, self.bearer_header = make_iap_request(HOST_URL, CLIENT_ID)
     assert code == 200, 'Did not get 200 creating bearer token: %d' % (
         code)
     self.custom_modified_headers = create_modheaders_plugin(
         remove_headers=[],
         add_or_modify_headers={
             "Authorization": self.bearer_header["Authorization"]
         })
     custom_device = {
         'deviceMetrics': {
             'width': 360,
             'height': 640,
             'pixelRatio': 3.0
         },
         'userAgent':
         'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 \
         Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) \
         Chrome/18.0.1025.166 Mobile Safari/535.19'
     }
     self.chrome_options = webdriver.ChromeOptions()
     self.chrome_options.add_argument("--start-maximized")
     self.chrome_options.add_experimental_option("mobileEmulation",
                                                 custom_device)
     self.chrome_options.add_extension(self.custom_modified_headers)
     self.browser = webdriver.Chrome(executable_path='chromedriver',
                                     chrome_options=self.chrome_options)
     return self.browser
Exemplo n.º 3
0
 def get_authenticated_nexus_5x_emulation(self):
     code, self.bearer_header = make_iap_request(HOST_URL, CLIENT_ID)
     assert code == 200, 'Did not get 200 creating bearer token: %d' % (
         code)
     self.custom_modified_headers = create_modheaders_plugin(
         remove_headers=[],
         add_or_modify_headers={
             "Authorization": self.bearer_header["Authorization"]
         })
     self.device = {
         'deviceMetrics': {
             'width': 1080,
             'height': 1920,
             'pixelRatio': 2.6
         },
         'userAgent':
         'mozilla/5.0 (Linux; Android 6.0.1; \
         Nexus 5x build/mtc19t applewebkit/537.36 (KHTML, like Gecko) \
         Chrome/51.0.2702.81 Mobile Safari/537.36'
     }
     self.chrome_options = webdriver.ChromeOptions()
     self.chrome_options.add_argument("--start-maximized")
     self.chrome_options.add_experimental_option("mobileEmulation",
                                                 self.device)
     self.chrome_options.add_extension(self.custom_modified_headers)
     self.browser = webdriver.Chrome(executable_path='chromedriver',
                                     chrome_options=self.chrome_options)
     return self.browser
Exemplo n.º 4
0
    def get_authenticated_remote_html_validator(self):
        code, self.bearer_header = make_iap_request(HOST_URL, CLIENT_ID)
        assert code == 200, 'Did not get 200 creating bearer token: %d' % (
            code)
        self.custom_modified_headers = create_modheaders_plugin(
            remove_headers=[],
            add_or_modify_headers={
                "Authorization": self.bearer_header["Authorization"]
            })
        self.desired_capabilities = webdriver.DesiredCapabilities.CHROME
        self.desired_capabilities['loggingPrefs'] = {'browser': 'ALL'}

        self.chrome_options = webdriver.ChromeOptions()
        self.chrome_options.add_argument(
            "--disable-plugins --disable-instant-extended-api \
            --headless")
        self.dir = os.path.dirname(__file__)
        self.path = os.path.join(
            self.dir, '../../../qa/utilities/html_validator/Validity.crx')
        self.chrome_options.add_extension(self.path)
        self.desired_capabilities.update(self.chrome_options.to_capabilities())
        self.browser = webdriver.Remote(
            command_executor=SELENIUM,
            desired_capabilities=self.desired_capabilities)
        return self.browser
Exemplo n.º 5
0
def before_all(context):
    if 'live' not in QA_ENV \
        and 'production' not in QA_ENV \
        and 'local' not in QA_ENV:
        code, context.bearer_header = make_iap_request(HOST_URL, CLIENT_ID)
        assert code == 200, 'Did not get 200 creating bearer token: %d' % (
            code
        )
        # Add Bearer headers to browsermob proxy
        context.proxy, context.server = get_proxy_and_server(context.bearer_header)
Exemplo n.º 6
0
    def escaped_login(self, host, id_for_client):
        log.debug('Getting escaped login headers.')
        '''Lighthouse wants escaped double quotes for the headers passed to --extra-headers flag'''

        code, bearer_header = make_iap_request(host, id_for_client)
        assert code == 200, 'Did not get 200 creating bearer token: %d' % (
            code)
        stringified_code = str(bearer_header['Authorization'])
        headers = {
            'Authorization': stringified_code,
        }
        for h in default_headers:
            headers[h] = default_headers[h]
        log.debug('These are the escaped headers:\n%s' %
                  json.dumps(json.dumps(headers)))
        escaped_headers = json.dumps(json.dumps(headers))
        return escaped_headers, headers
Exemplo n.º 7
0
    def get_authenticated_local_ga_chrome(self):
        code, self.bearer_header = make_iap_request(HOST_URL, CLIENT_ID)
        assert code == 200, 'Did not get 200 creating bearer token: %d' % (
            code)
        self.custom_modified_headers = create_modheaders_plugin(
            remove_headers=[],
            add_or_modify_headers={
                "Authorization": self.bearer_header["Authorization"]
            })
        self.desired_capabilities = webdriver.DesiredCapabilities.CHROME
        self.desired_capabilities['loggingPrefs'] = {'browser': 'ALL'}

        self.chrome_options = webdriver.ChromeOptions()
        self.chrome_options.add_extension('%senv/bin/ga_tracker.crx' %
                                          QA_FOLDER_PATH)
        self.chrome_options.add_extension(self.custom_modified_headers)
        self.driver = webdriver.Chrome(chrome_options=self.chrome_options)
        return self.driver
Exemplo n.º 8
0
 def get_headless_authenticated_chrome_driver(self):
     code, self.bearer_header = make_iap_request(HOST_URL, CLIENT_ID)
     assert code == 200, 'Did not get 200 creating bearer token: %d' % (
         code)
     self.custom_modified_headers = create_modheaders_plugin(
         remove_headers=[],
         add_or_modify_headers={
             "Authorization": self.bearer_header["Authorization"]
         })
     self.desired_capabilities = webdriver.DesiredCapabilities.CHROME
     self.desired_capabilities['loggingPrefs'] = {'browser': 'ALL'}
     self.chrome_options = webdriver.ChromeOptions()
     self.chrome_options.add_argument(
         "--disable-plugins --disable-instant-extended-api --headless")
     self.chrome_options.add_extension(self.custom_modified_headers)
     self.desired_capabilities.update(self.chrome_options.to_capabilities())
     self.browser = webdriver.Chrome(
         executable_path='chromedriver',
         desired_capabilities=self.desired_capabilities)
     # Desktop size
     set_defaults(self.browser)
     return self.browser
Exemplo n.º 9
0
import os
import requests
from qa.settings import ALLURE_REPORT_HUB_URL, ALLURE_PROJECT_NAME
from qa.settings import ALLURE_HUB_CLIENT_ID, QA_DIRECTORY
from qa.settings import SLACK_CHANNEL
from qa.utilities.oauth.service_account_auth import make_iap_request
from qa.utilities.slack.webhook import SlackMessage

SEND_FILE_URL = ALLURE_REPORT_HUB_URL + '/upload_file'

code, bearer_header = make_iap_request(ALLURE_REPORT_HUB_URL,
                                       ALLURE_HUB_CLIENT_ID)
assert code == 200, 'Did not get 200 creating bearer token: %d' % (code)

headers = {"Authorization": bearer_header["Authorization"]}

data = {'project': ALLURE_PROJECT_NAME}
print('Project is %s' % data['project'])

directory = os.path.join(QA_DIRECTORY, 'utilities', 'allure', 'allure_results')
print('Send file to: %s' % SEND_FILE_URL)
for file in os.listdir(directory):
    if '.json' in str(file) or 'history' in str(file) or 'properties' in str(
            file):
        print('Sending %s' % file)
        files = {'file': open(os.path.join(directory, file), 'rb')}
        r = requests.post(SEND_FILE_URL,
                          files=files,
                          headers=headers,
                          data=data)
        r.raise_for_status()