def test_create_weblab_environment(self):
     settings = prepare_system(
         "*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings
     )
     self._settings = settings
     base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL])
     create_weblab_environment(base_url, settings)
Пример #2
0
    def test_create_weblab_environment_thorough(self):

        settings = prepare_system("*****@*****.**", "admin",
                                  "Administrador", "password",
                                  "*****@*****.**", self.wcloud_settings)
        self._settings = settings
        base_url = os.path.join(flask_app.config["DIR_BASE"],
                                settings[Creation.BASE_URL])
        create_weblab_environment(base_url, settings)

        # Start a local server on that config to check whether it works as expected.
        from weblab.comm.proxy_server import start as start_proxy
        g = globals()
        l = locals()
        execfile(os.path.join(base_url, 'httpd/simple_server_config.py'), g, l)
        print "FILE: " + base_url
        p = g.get("PATHS") or l.get("PATHS")
        start_proxy(8001, p)

        time.sleep(1)

        r = requests.get(
            "http://localhost:8001/testentity/weblab/client/index.html")
        assert r.status_code == 200
        assert "Deusto" in r.text
Пример #3
0
 def test_create_weblab_environment(self):
     settings = prepare_system("*****@*****.**", "admin",
                               "Administrador", "password",
                               "*****@*****.**", self.wcloud_settings)
     self._settings = settings
     base_url = os.path.join(flask_app.config["DIR_BASE"],
                             settings[Creation.BASE_URL])
     create_weblab_environment(base_url, settings)
    def test_create_weblab_environment_thorough(self):

        settings = prepare_system(
            "*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings
        )
        self._settings = settings
        base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL])
        create_weblab_environment(base_url, settings)

        # Start a local server on that config to check whether it works as expected.
        from weblab.comm.proxy_server import start as start_proxy

        g = globals()
        l = locals()
        execfile(os.path.join(base_url, "httpd/simple_server_config.py"), g, l)
        print "FILE: " + base_url
        p = g.get("PATHS") or l.get("PATHS")
        start_proxy(8001, p)

        time.sleep(1)

        r = requests.get("http://localhost:8001/testentity/weblab/client/index.html")
        assert r.status_code == 200
        assert "Deusto" in r.text
    def test_register_and_start_instance(self):
        """
        Test whether the weblab instance can be started successfully.
        PRERREQUISITE: weblabstarter script needs to be running in the background.
        """
        time.sleep(2)
        settings = prepare_system(
            "*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings
        )
        self._settings = settings
        base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL])
        creation_results = create_weblab_environment(base_url, settings)
        configure_web_server(creation_results)
        register_and_start_instance("*****@*****.**", {})

        start_port, end_port = creation_results["start_port"], creation_results["end_port"]
    def test_finish_deployment(self):
        """
        test_finish_deployment: Tests that every step can be done, and the deployment finished.
        PRERREQUISITES: apache-reloader and weblab-starter scripts running.
        """
        settings = prepare_system(
            "*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings
        )
        self._settings = settings
        base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL])
        creation_results = create_weblab_environment(base_url, settings)
        configure_web_server(creation_results)
        register_and_start_instance("*****@*****.**", self.wcloud_settings)

        start_port, end_port = creation_results["start_port"], creation_results["end_port"]
        finish_deployment("*****@*****.**", settings, start_port, end_port, self.wcloud_settings)
        pass
Пример #7
0
    def test_register_and_start_instance(self):
        """
        Test whether the weblab instance can be started successfully.
        PRERREQUISITE: weblabstarter script needs to be running in the background.
        """
        time.sleep(2)
        settings = prepare_system("*****@*****.**", "admin",
                                  "Administrador", "password",
                                  "*****@*****.**", self.wcloud_settings)
        self._settings = settings
        base_url = os.path.join(flask_app.config["DIR_BASE"],
                                settings[Creation.BASE_URL])
        creation_results = create_weblab_environment(base_url, settings)
        configure_web_server(creation_results)
        register_and_start_instance("*****@*****.**", {})

        start_port, end_port = creation_results[
            "start_port"], creation_results["end_port"]
    def test_configure_web_server(self):
        """
        Checks whether the Apache server can be configured correctly.
        PRERREQUISITE: Apache Reloader script must previously be running.
        """
        settings = prepare_system(
            "*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings
        )
        self._settings = settings
        base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL])
        creation_results = create_weblab_environment(base_url, settings)
        configure_web_server(creation_results)

        assert os.path.isfile(os.path.join(base_url, "../", "apache.conf"))
        content = open(os.path.join(base_url, "../", "apache.conf"), "r").read()
        assert "testentity" in content
        lines = content.split("\n")
        line = [line.strip() for line in lines if "testentity" in line][0]
        assert os.path.isfile(line.split('"')[1])
Пример #9
0
    def test_finish_deployment_thorough(self):
        """
        test_finish_deployment_thorough: Tests that every step can be done, and the deployment finished.
        Checks that after being configured, Apache is indeed serving the new instance correctly.
        PRERREQUISITES: apache-reloader and weblab-starter scripts running; apache2 configured correctly to load the instances.
        """
        settings = prepare_system("*****@*****.**", "admin",
                                  "Administrador", "password",
                                  "*****@*****.**", self.wcloud_settings)
        self._settings = settings
        base_url = os.path.join(flask_app.config["DIR_BASE"],
                                settings[Creation.BASE_URL])
        creation_results = create_weblab_environment(base_url, settings)
        configure_web_server(creation_results)
        register_and_start_instance("*****@*****.**",
                                    self.wcloud_settings)

        start_port, end_port = creation_results[
            "start_port"], creation_results["end_port"]
        finish_deployment("*****@*****.**", settings, start_port,
                          end_port, self.wcloud_settings)

        # Check that the new instance is being served correctly.
        bot = requests.Session()
        r = bot.get("http://localhost/testentity/weblab/client/index.html")
        text = r.text
        print text
        assert "weblabclientlab" in text
        assert "input" in text
        assert "hiddenPassword" in text

        # Check that we can login with admin/password.
        r = bot.post(
            "http://localhost/testentity/weblab/login/json/",
            data=
            """{"params":{"username":"******", "password":"******"}, "method":"login"}"""
        )
        str = r.text
        print "The request returned: " + str
        j = json.loads(str)
        assert not j["is_exception"]
        assert "id" in j["result"]
Пример #10
0
    def test_configure_web_server(self):
        """
        Checks whether the Apache server can be configured correctly.
        PRERREQUISITE: Apache Reloader script must previously be running.
        """
        settings = prepare_system("*****@*****.**", "admin",
                                  "Administrador", "password",
                                  "*****@*****.**", self.wcloud_settings)
        self._settings = settings
        base_url = os.path.join(flask_app.config["DIR_BASE"],
                                settings[Creation.BASE_URL])
        creation_results = create_weblab_environment(base_url, settings)
        configure_web_server(creation_results)

        assert os.path.isfile(os.path.join(base_url, "../", "apache.conf"))
        content = open(os.path.join(base_url, "../", "apache.conf"),
                       "r").read()
        assert "testentity" in content
        lines = content.split("\n")
        line = [line.strip() for line in lines if "testentity" in line][0]
        assert os.path.isfile(line.split("\"")[1])
Пример #11
0
    def test_finish_deployment(self):
        """
        test_finish_deployment: Tests that every step can be done, and the deployment finished.
        PRERREQUISITES: apache-reloader and weblab-starter scripts running.
        """
        settings = prepare_system("*****@*****.**", "admin",
                                  "Administrador", "password",
                                  "*****@*****.**", self.wcloud_settings)
        self._settings = settings
        base_url = os.path.join(flask_app.config["DIR_BASE"],
                                settings[Creation.BASE_URL])
        creation_results = create_weblab_environment(base_url, settings)
        configure_web_server(creation_results)
        register_and_start_instance("*****@*****.**",
                                    self.wcloud_settings)

        start_port, end_port = creation_results[
            "start_port"], creation_results["end_port"]
        finish_deployment("*****@*****.**", settings, start_port,
                          end_port, self.wcloud_settings)
        pass
Пример #12
0
    def test_finish_deployment_thorough(self):
        """
        test_finish_deployment_thorough: Tests that every step can be done, and the deployment finished.
        Checks that after being configured, Apache is indeed serving the new instance correctly.
        PRERREQUISITES: apache-reloader and weblab-starter scripts running; apache2 configured correctly to load the instances.
        """
        settings = prepare_system(
            "*****@*****.**", "admin", "Administrador", "password", "*****@*****.**", self.wcloud_settings
        )
        self._settings = settings
        base_url = os.path.join(flask_app.config["DIR_BASE"], settings[Creation.BASE_URL])
        creation_results = create_weblab_environment(base_url, settings)
        configure_web_server(creation_results)
        register_and_start_instance("*****@*****.**", self.wcloud_settings)

        start_port, end_port = creation_results["start_port"], creation_results["end_port"]
        finish_deployment("*****@*****.**", settings, start_port, end_port, self.wcloud_settings)

        # Check that the new instance is being served correctly.
        bot = requests.Session()
        r = bot.get("http://localhost/testentity/weblab/client/index.html")
        text = r.text
        print text
        assert "weblabclientlab" in text
        assert "input" in text
        assert "hiddenPassword" in text

        # Check that we can login with admin/password.
        r = bot.post(
            "http://localhost/testentity/weblab/login/json/",
            data="""{"params":{"username":"******", "password":"******"}, "method":"login"}""",
        )
        str = r.text
        print "The request returned: " + str
        j = json.loads(str)
        assert not j["is_exception"]
        assert "id" in j["result"]