예제 #1
0
 def test_generate_config(self):
     config_file = os.path.join(self.test_dir,self.conf_file)
     self.assertEqual(os.path.exists(config_file),
                      False)
     
     generate_config(config_file=config_file)
     self.assertEqual(os.path.exists(config_file),
                      True)
     
     cfg = Config(file=config_file)
     self.assertEqual(cfg["config"].get_val('version'),VERSION)   
예제 #2
0
 def test_usage(self):
     generate_config(config_file=TMP_CHEROKEE_CONF)
     admin = Admin(config_file=TMP_CHEROKEE_CONF)
     admin.create_vserver(nick="my-vserver", document_root="/dev/null")
     admin.create_source(nick="my-source", type="host", host="/tmp/host_socket.sock")
     rule_dict = {
         "disabled" : "0",
         "document_root" : "/var/www/example.com/foo",
         "handler" : "file",
         "handler!iocache" : "1",
         "match" : "directory",
         "match!directory" : "/foo",
         "match!final" : "1",
         "no_log" : "0",
         "only_secure" : "0",
     }
     admin.create_rule(vserver_path="vserver!10", **rule_dict)
    def cherokee(self):
        generate_config(config_file="wsgi-cherokee-gene.conf")
        admin = Admin(config_file="wsgi-cherokee-gene.conf")
        vserver_dict = {"match": "target_ip", "match!to!1": "127.0.0.1"}
        admin.create_vserver(nick="my_vserver", document_root="/dev/null", **vserver_dict)
        my_vserver = admin.get_vserver_by_nick("my_vserver")
        source_host = "127.0.0.1:1234"
        uwsgi_module = "uwsgi_settings"
        current_dir = os.getcwd()
        python_home = sys.prefix
        uwsgi_bin = os.path.join(python_home, "bin", "uwsgi")
        source_dict = {
            "interpreter": "%s -s %s -H %s -w %s --pythonpath %s"
            % (uwsgi_bin, source_host, python_home, uwsgi_module, current_dir)
        }
        admin.create_source(nick="my_uwsgi_source", type="interpreter", host=source_host, **source_dict)

        my_uwsgi_source = admin.get_source_by_nick("my_uwsgi_source")

        rule_dict = {
            "disabled": "0",
            "encoder!deflate": "allow",
            "encoder!gzip": "allow",
            "handler": "uwsgi",
            "handler!balancer": "round_robin",
            "handler!balancer!source!1": my_uwsgi_source.split("!").pop(),
            "handler!change_user": "******",
            "handler!check_file": "0",
            "handler!error_handler": "1",
            "handler!pass_req_headers": "1",
            "handler!x_real_ip_access_all": "0",
            "handler!x_real_ip_enabled": "0",
            "handler!xsendfile": "0",
            "match": "directory",
            "match!directory": "/wsgi_app",
            "match!final": "1",
            "no_log": "0",
            "only_secure": "0",
        }
        admin.create_rule(vserver_path=my_vserver, **rule_dict)
        admin.config["server!bind!1!port"] = "82"
        admin.config.save()