Sign inSign up

edujgurjc/ess-test

By edujgurjc

Updated almost 7 years ago

Image
0

245

edujgurjc/ess-test repository overview

DOCKERFILE:

FROM dockernash/test-tjob-ess:latest

COPY tjob.py /tjob.py

tjob.py:

import unittest from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from pprint import pprint import os import sys import requests from urlparse import urlparse import time

flag="" class PythonOrgSearch(unittest.TestCase):

def setUp(self):
	essApiUrl=os.environ['ET_ESS_API']
	essProxyApiUrl=os.environ['ET_ESS_HTTPPROXY_API']

	print("ESS API URL is: "+str(essApiUrl))
	print("ESS HTTP API URL is: "+str(essProxyApiUrl))
	eusUrl=os.environ['ET_EUS_API']
	print("EUS URL is: "+str(eusUrl))

	ess_mitm_proxy_url=essProxyApiUrl.lstrip("http://")

	options = webdriver.ChromeOptions()
	options.add_argument('--proxy-server='+ess_mitm_proxy_url)
	capabilities = options.to_capabilities()
    self.driver = webdriver.Remote(command_executor=eusUrl, desired_capabilities=capabilities)
#debug
#proxies = {'http': ess_mitm_proxy_url+":8080",'https': ess_mitm_proxy_url+":8080"}
#requests.get('http://example.org', proxies=proxies)

    #self.driver = webdriver.Chrome(desired_capabilities=capabilities)
	#self.driver = webdriver.Firefox()

def test_search_in_python_org(self):
	driver = self.driver
	essApiUrl=os.environ['ET_ESS_API']
	print("ESS API URL is: "+str(essApiUrl))


	if flag == "fullteaching-login":
		driver.get("https://52.50.3.12/#/")
		login_launch = driver.find_element_by_xpath("//*[@id=\"navigation-bar\"]/div/ul/li[2]/a")
		login_launch.click()
		username = driver.find_element_by_id("email")
		username.send_keys("[email protected]")
		password = driver.find_element_by_id("password")
		password.send_keys("pass")
		login_btn = driver.find_element_by_id("log-in-btn")
		login_btn.click()
		time.sleep(5)
		settings_btn = driver.find_element_by_id("settings-button")
		settings_btn.click()
		re=requests.post(essApiUrl+"/start/",json={"sites": ["https://52.50.3.12"]})
	elif flag == "fullteaching-home":
		driver.get("https://52.50.3.12/#/")
		re=requests.post(essApiUrl+"/start/",json={"sites": ["https://52.50.3.12"]})
	else:
		driver.get("https://example.com")
		driver.get("https://example.org")
		re=requests.post(essApiUrl+"/start/",json={"sites": ["https://example.com","https://example.org"]})
	#Checking the status of the scan
	if "starting-ess" in re.text:
	    req=requests.get(essApiUrl+'/status/')
	    status=req.text
	    while ("not-yet" in status or "scan-timelimit-exceeded" in status):
            if "scan-timelimit-exceeded" in status:
                    print("Time Limit Exceeded")
                    break
            else:
                    time.sleep(5)
                    req=requests.get(ess_url+'/ess/api/r4/status/')
                    status=req.text

def tearDown(self):
    pass

if name == "main": if len(sys.argv)>1: flag=sys.argv[1] del sys.argv[1] unittest.main()

Tag summary

Content type

Image

Digest

Size

47 MB

Last updated

almost 7 years ago

docker pull edujgurjc/ess-test