Closed qudong521 closed 1 year ago
Sorry, I'm a newcomer. I asked some childish questions for my first contact,
Sorry, I'm a newcomer. I asked some childish questions for my first contact,
There is no problem to being a newcomer. You're welcome !
I'll take a look at this later, sorry for the delay.
Add some information:
__________________________________________________________________________________________________________________________________ test_run ___________________________________________________________________________________________________________________________________
psql = <conftest.PSQL object at 0x7f7eb4615ba8>
def test_run(psql):
# type: (PSQL) -> None
from sh import ldap2pg
c = 'tests/func/ldap2pg.full.yml'
# Ensure database is not sync.
ldap2pg('-C', c=c, _ok_code=1)
# Synchronize all
ldap2pg('-N', c=c)
ldap2pg('-C', c=c)
roles = list(psql.roles())
print(roles)
assert 'Alan' in roles
assert 'oscar' not in roles
assert 'ALICE' in psql.superusers()
writers = list(psql.members('writers'))
print(writers)
> assert 'daniel' in writers
E AssertionError: assert 'daniel' in ['owners']
c = 'tests/func/ldap2pg.full.yml'
ldap2pg = <Command '/usr/local/bin/ldap2pg'>
psql = <conftest.PSQL object at 0x7f7eb4615ba8>
roles = ['pg_database_owner',
'pg_read_all_data',
'pg_write_all_data',
'pg_monitor',
'pg_read_all_settings',
'pg_read_all_stats',
'pg_stat_scan_tables',
'pg_read_server_files',
'pg_write_server_files',
'pg_execute_server_program',
'pg_signal_backend',
'pg_checkpoint',
'nonsuper',
'ldap_roles',
'app',
'daniel',
'david',
'denis',
'ALICE',
'keepme',
'kevin',
'owners',
'writers',
'readers',
'postgres',
'DBA',
'Alan']
writers = ['owners']
tests/func/test_full.py:33: AssertionError
============================================================================================================================== warnings summary ===============================================================================================================================
../../../usr/local/lib/python3.6/site-packages/_pytest/cacheprovider.py:433
/usr/local/lib/python3.6/site-packages/_pytest/cacheprovider.py:433: PytestCacheWarning: cache could not write path /home/package/ldap2pg-master/tests/func/.pytest_cache/v/cache/nodeids
config.cache.set("cache/nodeids", sorted(self.cached_nodeids))
../../../usr/local/lib/python3.6/site-packages/_pytest/cacheprovider.py:387
/usr/local/lib/python3.6/site-packages/_pytest/cacheprovider.py:387: PytestCacheWarning: cache could not write path /home/package/ldap2pg-master/tests/func/.pytest_cache/v/cache/lastfailed
config.cache.set("cache/lastfailed", self.lastfailed)
../../../usr/local/lib/python3.6/site-packages/_pytest/stepwise.py:52
/usr/local/lib/python3.6/site-packages/_pytest/stepwise.py:52: PytestCacheWarning: cache could not write path /home/package/ldap2pg-master/tests/func/.pytest_cache/v/cache/stepwise
session.config.cache.set(STEPWISE_CACHE_DIR, [])
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================================================================================================================== short test summary info ===========================================================================================================================
FAILED tests/func/test_full.py::test_run - AssertionError: assert 'daniel' in ['owners']
FAILED tests/func/test_sample.py::test_real_mode - AssertionError: assert 'daniel' in ['owners']
================================================================================================================== 2 failed, 7 passed, 3 warnings in 19.74s ===================================================================================================================
[postgres@MiWiFi-R3G-srv ldap2pg-master]$
What is the output of \du+
in psql ?
Use pytest --pdb
to stop test on failure before cleanup.
Now this is the result:
[postgres@MiWiFi-R3G-srv ldap2pg-master]$ psql
psql (15.2)
Type "help" for help.
postgres=# \du
List of roles
Role name | Attributes | Member of
------------+------------------------------------------------------------+-----------
ALICE | Superuser, Cannot login | {app}
Alan | Cannot login | {}
DBA | Cannot login | {}
app | Cannot login | {}
daniel | | {}
david | | {}
denis | | {}
keepme | Cannot login | {}
kevin | Cannot login | {}
ldap_roles | Cannot login | {}
nonsuper | Create role, Create DB | {}
owners | Cannot login | {writers}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
readers | Cannot login | {}
writers | Cannot login | {readers}
postgres=# \q
But when I modified the configuration file, I added:
-Name: daniel
Parent: writers
After this, the testing changed:
___________________________________________________________ test_run ___________________________________________________________
psql = <conftest.PSQL object at 0x7f90c25c6d68>
def test_run(psql):
# type: (PSQL) -> None
from sh import ldap2pg
c = 'tests/func/ldap2pg.full.yml'
# Ensure database is not sync.
ldap2pg('-C', c=c, _ok_code=1)
# Synchronize all
ldap2pg('-N', c=c)
> ldap2pg('-C', c=c)
c = 'tests/func/ldap2pg.full.yml'
ldap2pg = <Command '/usr/local/bin/ldap2pg'>
psql = <conftest.PSQL object at 0x7f90c25c6d68>
tests/func/test_full.py:18:
[postgres@MiWiFi-R3G-srv ldap2pg-master]$ psql
psql (15.2)
Type "help" for help.
postgres=# \du
List of roles
Role name | Attributes | Member of
------------+------------------------------------------------------------+-----------
ALICE | Superuser, Cannot login | {app}
Alan | Cannot login | {}
DBA | Cannot login | {}
app | Cannot login | {}
daniel | Cannot login | {writers}
david | | {}
denis | | {}
keepme | Cannot login | {}
kevin | Cannot login | {}
ldap_roles | Cannot login | {}
nonsuper | Create role, Create DB | {}
owners | Cannot login | {writers}
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
readers | Cannot login | {}
writers | Cannot login | {readers}
postgres=#
Haha. I have resolved the issue, but there is a missing entry in my ldap service configuration. Thank you very much. Now close the issue.
Hello!
I encountered the following error while running pytest. I tried to modify the yml file, but the problem has not been resolved. Can you help me?
My configuration file is as follows:
I have manually made many modifications, but the issue has not been resolved. The file above is the version I currently maintain with the least number of issues. I hope you can give me some guidance, and I would be very grateful.