Exemplo n.º 1
0
def test_rest():
    reset_all_users()
    username = pwd.getpwuid(os.getuid()).pw_name
    client = make_logged_in_client(username=username, is_superuser=True)

    d = {'eventlet.input': None}
    response = client.get('/shell/', follow=True, **d)

    shell_types_available = []
    for item in shell.conf.SHELL_TYPES.keys():
        nice_name = shell.conf.SHELL_TYPES[item].nice_name.get().strip()
        assert nice_name in response.content
        command = shell.conf.SHELL_TYPES[item].command.get().strip().split()
        if utils.executable_exists(command):
            shell_types_available.append(item)

    if not shell_types_available:
        return

    response = client.get('/shell/create?keyName=%s' % (time.strftime("%s"), ),
                          follow=True,
                          **d)
    assert "There is no shell with that name." in response.content

    nonexistent_username = "******" % (time.strftime("%s"), )
    client2 = make_logged_in_client(username=nonexistent_username,
                                    is_superuser=True)

    response = client2.get("/shell/create?keyName=%s" %
                           (shell_types_available[0], ),
                           follow=True,
                           **d)
    assert "There is no Unix user account for you." in response.content

    response = client.get("/shell/create?keyName=%s" %
                          (shell_types_available[0], ),
                          follow=True,
                          **d)
    fragment = '<span id="shell_id" class="hide">'
    assert fragment in response.content

    shell_id_start = response.content.index(fragment) + len(fragment)
    shell_id_end = response.content.index('</span>', shell_id_start)
    shell_id = response.content[shell_id_start:shell_id_end]
    assert re.match(r"^\s*\d+\s*$", shell_id)

    response = client.post("/shell/kill_shell",
                           follow=True,
                           data={constants.SHELL_ID: shell_id},
                           **d)
    assert 'Shell successfully marked for cleanup' in response.content
Exemplo n.º 2
0
Arquivo: tests.py Projeto: rvs/hue
def test_unix_user_account_check():
    reset_all_users()
    nonexistent_username = "******" % (time.strftime("%s"),)
    client = make_logged_in_client(username=nonexistent_username, is_superuser=True)

    d = {"eventlet.input": None}
    response = client.get("/shell/", follow=True, **d)
    assert "The Shell app requires a Unix user account for every user of Hue" in response.content
Exemplo n.º 3
0
def test_unix_user_account_check():
    reset_all_users()
    nonexistent_username = "******" % (time.strftime("%s"), )
    client = make_logged_in_client(username=nonexistent_username,
                                   is_superuser=True)

    d = {'eventlet.input': None}
    response = client.get('/shell/', follow=True, **d)
    assert "The Shell application requires a Unix user account for every user of Hue" in response.content
Exemplo n.º 4
0
 def log_msg(self, msg, **kwargs):
     if kwargs and kwargs.get("cat"):
         print time.strftime("[%H:%M:%S] ") + "[" + kwargs.get("cat") + "] " + str(msg)
     elif self.get_options() == None:
         print time.strftime("[%H:%M:%S] ") + str(msg)
         sys.stdout.flush()
     elif self.get_options().debug == True:
         print time.strftime("[%H:%M:%S] ") + str(msg)
         sys.stdout.flush()
     else: 
         print time.strftime("[%H:%M:%S] ") + str(msg)
         sys.stdout.flush()
Exemplo n.º 5
0
def test_rest():
    reset_all_users()
    username = pwd.getpwuid(os.getuid()).pw_name
    client = make_logged_in_client(username=username, is_superuser=True)

    d = {"eventlet.input": None}
    response = client.get("/shell/", follow=True, **d)

    shell_types_available = []
    for item in shell.conf.SHELL_TYPES.keys():
        nice_name = shell.conf.SHELL_TYPES[item].nice_name.get().strip()
        assert nice_name in response.content
        command = shell.conf.SHELL_TYPES[item].command.get().strip().split()
        if utils.executable_exists(command):
            shell_types_available.append(item)

    if not shell_types_available:
        return

    response = client.get("/shell/create?keyName=%s" % (time.strftime("%s"),), follow=True, **d)
    assert "There is no shell with that name." in response.content

    nonexistent_username = "******" % (time.strftime("%s"),)
    client2 = make_logged_in_client(username=nonexistent_username, is_superuser=True)

    response = client2.get("/shell/create?keyName=%s" % (shell_types_available[0],), follow=True, **d)
    assert "There is no Unix user account for you." in response.content

    response = client.get("/shell/create?keyName=%s" % (shell_types_available[0],), follow=True, **d)
    fragment = '<span id="shell_id" class="hide">'
    assert fragment in response.content

    shell_id_start = response.content.index(fragment) + len(fragment)
    shell_id_end = response.content.index("</span>", shell_id_start)
    shell_id = response.content[shell_id_start:shell_id_end]
    assert re.match(r"^\s*\d+\s*$", shell_id)

    response = client.post("/shell/kill_shell", follow=True, data={constants.SHELL_ID: shell_id}, **d)
    assert "Shell successfully marked for cleanup" in response.content
Exemplo n.º 6
0
    def on_block(self, LP, block, work, server):
        """
        Recieves the current block and server and dumps it to file
        """
        fd = None
        try:
            # determine if application is a script file or frozen exe
            if hasattr(sys, 'frozen'):
                application_path = os.path.dirname(sys.executable)
            elif __file__:
                application_path = os.path.dirname(__file__)
            fd = open(os.path.join(application_path, self.file_name), 'brwa+')
        except:
            fd = open(self.file_name, 'brwa+')

        fd.write(time.strftime('%H%M%S') + ":" + block + ":" + server + "\n" )
        fd.close()
Exemplo n.º 7
0
    def on_block(self, LP, block, work, server):
        """
        Recieves the current block and server and dumps it to file
        """
        fd = None
        try:
            # determine if application is a script file or frozen exe
            if hasattr(sys, 'frozen'):
                application_path = os.path.dirname(sys.executable)
            elif __file__:
                application_path = os.path.dirname(__file__)
            fd = open(os.path.join(application_path, self.file_name), 'brwa+')
        except:
            fd = open(self.file_name, 'brwa+')

        fd.write(time.strftime('%H%M%S') + ":" + block + ":" + server + "\n")
        fd.close()