403Webshell
Server IP : 172.67.216.182  /  Your IP : 162.158.108.94
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/jeepney/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/jeepney/tests/test_bus_messages.py
from jeepney import DBusAddress, new_signal, new_method_call
from jeepney.bus_messages import MatchRule, message_bus

portal = DBusAddress(
    object_path='/org/freedesktop/portal/desktop',
    bus_name='org.freedesktop.portal.Desktop',
)
portal_req_iface = portal.with_interface('org.freedesktop.portal.Request')


def test_match_rule_simple():
    rule = MatchRule(
        type='signal', interface='org.freedesktop.portal.Request',
    )
    assert rule.matches(new_signal(portal_req_iface, 'Response'))

    # Wrong message type
    assert not rule.matches(new_method_call(portal_req_iface, 'Boo'))

    # Wrong interface
    assert not rule.matches(new_signal(
        portal.with_interface('org.freedesktop.portal.FileChooser'), 'Response'
    ))


def test_match_rule_path_namespace():
    assert MatchRule(path_namespace='/org/freedesktop/portal').matches(
        new_signal(portal_req_iface, 'Response')
    )

    # Prefix but not a parent in the path hierarchy
    assert not MatchRule(path_namespace='/org/freedesktop/por').matches(
        new_signal(portal_req_iface, 'Response')
    )


def test_match_rule_arg():
    rule = MatchRule(type='method_call')
    rule.add_arg_condition(0, 'foo')

    assert rule.matches(new_method_call(
        portal_req_iface, 'Boo', signature='s', body=('foo',)
    ))

    assert not rule.matches(new_method_call(
        portal_req_iface, 'Boo', signature='s', body=('foobar',)
    ))

    # No such argument
    assert not rule.matches(new_method_call(portal_req_iface, 'Boo'))


def test_match_rule_arg_path():
    rule = MatchRule(type='method_call')
    rule.add_arg_condition(0, '/aa/bb/', kind='path')

    # Exact match
    assert rule.matches(new_method_call(
        portal_req_iface, 'Boo', signature='s', body=('/aa/bb/',)
    ))

    # Match a prefix
    assert rule.matches(new_method_call(
        portal_req_iface, 'Boo', signature='s', body=('/aa/bb/cc',)
    ))

    # Argument is a prefix, ending with /
    assert rule.matches(new_method_call(
        portal_req_iface, 'Boo', signature='s', body=('/aa/',)
    ))

    # Argument is a prefix, but NOT ending with /
    assert not rule.matches(new_method_call(
        portal_req_iface, 'Boo', signature='s', body=('/aa',)
    ))

    assert not rule.matches(new_method_call(
        portal_req_iface, 'Boo', signature='s', body=('/aa/bb',)
    ))

    # Not a string
    assert not rule.matches(new_method_call(
        portal_req_iface, 'Boo', signature='u', body=(12,)
    ))


def test_match_rule_arg_namespace():
    rule = MatchRule(member='NameOwnerChanged')
    rule.add_arg_condition(0, 'com.example.backend1', kind='namespace')

    # Exact match
    assert rule.matches(new_signal(
        message_bus, 'NameOwnerChanged', 's', ('com.example.backend1',)
    ))

    # Parent of the name
    assert rule.matches(new_signal(
        message_bus, 'NameOwnerChanged', 's', ('com.example.backend1.foo.bar',)
    ))

    # Prefix but not a parent in the namespace
    assert not rule.matches(new_signal(
        message_bus, 'NameOwnerChanged', 's', ('com.example.backend12',)
    ))

    # Not a string
    assert not rule.matches(new_signal(
        message_bus, 'NameOwnerChanged', 'u', (1,)
    ))

Youez - 2016 - github.com/yon3zu
LinuXploit