api.pyfabapi/test.py
Nadja Reitzenstein c8ed03caec User system things
2022-04-28 20:57:40 +02:00

26 lines
785 B
Python

import asyncio
import fabapi
import fabapi.user_system
async def main():
session = await fabapi.connect("localhost", 59661, "Testuser", "secret")
info = await session.machineSystem.info().a_wait()
ma = await info.info.getMachineURN("urn:fabaccess:resource:Another").a_wait()
print(ma)
# Add an user with the given roles
roles = [
"somerole", "testrole"
]
user = await fabapi.user_system.add_user(session.userSystem, "ANewUser", "ANewSecret", roles=roles)
# As you can see, Roles were attached
await user.info.listRoles().a_wait()
# Delete the same user again
await fabapi.user_system.del_user(session.userSystem, "ANewUser")
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())