AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/jeepney/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /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,)
    ))

Anon7 - 2022
AnonSec Team