api.pyfabapi/test.py

26 lines
785 B
Python
Raw Normal View History

2021-12-09 21:54:22 +01:00
import asyncio
2021-09-19 20:35:34 +02:00
import fabapi
2022-04-28 20:57:40 +02:00
import fabapi.user_system
2021-12-09 21:54:22 +01:00
async def main():
2022-03-14 00:04:28 +01:00
session = await fabapi.connect("localhost", 59661, "Testuser", "secret")
2022-03-14 00:05:51 +01:00
info = await session.machineSystem.info().a_wait()
ma = await info.info.getMachineURN("urn:fabaccess:resource:Another").a_wait()
2022-03-14 00:07:32 +01:00
print(ma)
2021-12-09 21:54:22 +01:00
2022-04-28 20:57:40 +02:00
# 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")
2021-12-09 21:54:22 +01:00
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())