예제 #1
0
def test_gather_options_noinit(mocker):
    from ldap2pg.ldap import gather_options

    options = gather_options(
        password='******',
        environ=dict(LDAPNOINIT=b'', LDAPBASEDN=b'dc=base'),
    )
    assert 'BASE' not in options
예제 #2
0
def test_gather_options(mocker):
    rf = mocker.patch('ldap2pg.ldap.read_files', autospec=True)

    from ldap2pg.ldap import gather_options, RCEntry

    rf.side_effect = [
        [RCEntry(filename='a', lineno=1, option='URI', value='ldap:///')],
        [RCEntry(filename='b', lineno=1, option='BINDDN', value='cn=binddn')],
    ]

    options = gather_options(
        password=None,
        environ=dict(LDAPBASE=b'dc=local', LDAPPASSWORD=b'envpass'),
    )

    assert 'envpass' == options['PASSWORD']
    assert 'ldap:///' == options['URI']
    assert 'cn=binddn' == options['BINDDN']