class SOCKS5DriverAUTHTestCase(TestMethodsMixin, aiounittest.AsyncTestCase): driver_class = Socks5Driver driver_kwargs = { "address": '127.0.0.1', "port": get_free_port(), "login": '******', "password": '******' }
def setUpClass(cls): # Configure mock server. cls.mock_server_port = get_free_port() cls.mock_server = HTTPServer(('localhost', cls.mock_server_port), MockServerRequestHandler) # Start running mock server in a separate thread. # Daemon threads automatically shut down when the main process exits. cls.mock_server_thread = Thread(target=cls.mock_server.serve_forever) cls.mock_server_thread.setDaemon(True) cls.mock_server_thread.start() cls.json_url = 'http://localhost:{port}/'.format(port=cls.mock_server_port)
def setUpClass(cls): setup_config("data/config_openstack.py") body = { "sessionId": None, "desiredCapabilities": { "platform": "some_platform", "browserName": "firefox", "version": "", "javascriptEnabled": True } } session_request_body = json.dumps(body) session_request_headers = { 'content-length': '%s' % len(session_request_body), 'accept-encoding': 'identity', 'Connection': 'close', 'accept': 'application/json', 'user-agent': 'Python-urllib/2.7', 'host': '127.0.0.1:9000', 'content-type': 'application/json;charset=UTF-8', } cls.request = Mock() cls.request.method = "POST" cls.request.path = "/wd/hub/session" cls.request.headers = dict() cls.request.headers.update(session_request_headers) cls.request.data = session_request_body cls.webdriver_server = ServerMock(cls.host, get_free_port()) cls.webdriver_server.start() cls.vmmaster_agent = ServerMock(cls.host, get_free_port()) cls.vmmaster_agent.start() cls.vnc_server = ServerMock(cls.host, get_free_port()) cls.vnc_server.start() cls.app = Flask(__name__) cls.app.database = None cls.app.sessions = None cls.app.database_task_queue = Mock() cls.app.pool = Mock()
def setUp(self): setup_config('data/config_openstack.py') self.host = "localhost" self.port = config.PORT self.address = (self.host, self.port) self.vmmaster = vmmaster_server_mock(self.port) self.assertTrue(server_is_up(self.address)) self.free_port = get_free_port() self.ctx = self.vmmaster.app.app_context() self.ctx.push() from core.db.models import Session, Provider, Endpoint self.session = Session('some_platform') provider = Provider(name='noname', url='nourl') endpoint = Endpoint(Mock(), '', provider) endpoint.ip = 'localhost' self.session.endpoint = endpoint
class Config(object): BASEDIR = os.path.dirname(os.path.realpath(__file__)) PORT = get_free_port() # PostgreSQL dbname DATABASE = "postgresql://*****:*****@localhost/vmmaster_db" ENDPOINT_THREADPOOL_PROCESSES = 1 # screenshots SCREENSHOTS_DIR = os.sep.join([BASEDIR, "screenshots"]) SCREENSHOTS_DAYS = 7 # logging LOG_TYPE = "plain" LOG_LEVEL = "DEBUG" # selenium DEFAULT_PORTS = { "selenium": "4455", "agent": "9000", "vnc": "5900" } PLATFORMS = {} # openstack USE_OPENSTACK = True OPENSTACK_MAX_VM_COUNT = 2 OPENSTACK_PRELOADED = {} OPENSTACK_AUTH_URL = "localhost" OPENSTACK_PORT = 5000 OPENSTACK_CLIENT_VERSION = "v3" OPENSTACK_USERNAME = "******" OPENSTACK_PASSWORD = "******" OPENSTACK_TENANT_NAME = "name" OPENSTACK_TENANT_ID = "id" OPENSTACK_NETWORK_ID = "id" OPENSTACK_NETWORK_NAME = "network" OPENSTACK_ZONE_FOR_VM_CREATE = "" OPENSTACK_PLATFORM_NAME_PREFIX = "test_" OPENSTACK_DEFAULT_FLAVOR = 'flavor' OPENSTACK_DOMAIN_NAME = "test" OPENASTACK_VM_META_DATA = { 'admin_pass': '******' } OPENSTACK_VM_USERDATA_FILE_PATH = "%s/userdata" % os.path.abspath(os.curdir) USE_DOCKER = False BIND_LOCALHOST_PORTS = False DOCKER_MAX_COUNT = 3 DOCKER_PRELOADED = {} DOCKER_BASE_URL = 'unix://var/run/docker.sock' DOCKER_TIMEOUT = 120 DOCKER_NUM_POOLS = 100 DOCKER_NETWORK_NAME = "vmmaster_network" DOCKER_SUBNET = "192.168.1.0/24" DOCKER_GATEWAY = "192.168.1.254" DOCKER_CONTAINER_MEMORY_LIMIT = "1g" DOCKER_CONTAINER_CPU_PERIOD = 100000 DOCKER_CONTAINER_CPU_QUOTA = 50000 DOCKER_CONTAINER_VOLUMES = {} DOCKER_CONTAINER_ENVIRONMENT = {} DNS_LIST = [] DNS_SEARCH_LIST = [ "test" ] PUBLIC_IP = "127.0.0.1" VM_PING_RETRY_COUNT = 3 VM_CREATE_CHECK_PAUSE = 3 VM_CREATE_CHECK_ATTEMPTS = 5 PRELOADER_FREQUENCY = 3 SESSION_TIMEOUT = 5 PING_TIMEOUT = 5 # vm pool GET_VM_TIMEOUT = 5 SCREENCAST_RESOLUTION = (1600, 1200) MAKE_REQUEST_ATTEMPTS_AMOUNT = 5 FLASK_THREAD_POOL_MAX = 10 REACTOR_THREAD_POOL_MAX = 10 WAIT_ACTIVE_SESSIONS = False
class SOCKS5DriverANONTestCase(TestMethodsMixin, aiounittest.AsyncTestCase): driver_class = Socks5Driver driver_kwargs = { "address": '127.0.0.1', "port": get_free_port() }