4 meta = with pkgs.lib.maintainers; {
5 maintainers = [ martinetd ];
9 services.rmfakecloud = {
11 storageUrl = "https://local.appspot.com";
16 machine.wait_for_unit("rmfakecloud.service")
17 machine.wait_for_open_port(3000)
19 # first login creates user
20 login_token = machine.succeed("""
21 curl -sSf -b cookie -c cookie -H "Content-Type: application/json" \
22 -d'{"email":"test","password":"test"}' -X POST \
23 http://localhost:3000/ui/api/login
26 # subsequent different pass or mail should fail, but same login works
28 curl -sSf -H "Content-Type: application/json" \
29 -d'{"email":"test","password":"test2"}' -X POST \
30 http://localhost:3000/ui/api/login
33 curl -sSf -H "Content-Type: application/json" \
34 -d'{"email":"test2","password":"test"}' -X POST
35 http://localhost:3000/ui/api/login
38 curl -sSf -H "Content-Type: application/json" \
39 -d'{"email":"test","password":"test"}' -X POST \
40 http://localhost:3000/ui/api/login
43 # can get code from cookie or bearer
45 curl -sSf -b cookie -c cookie http://localhost:3000/ui/api/newcode
47 newcode = machine.succeed(f"""
48 curl -sSf -H "Authorization: Bearer {login_token}" \
49 http://localhost:3000/ui/api/newcode
54 curl -sSf -H "Authorization: Bearer abc{login_token}" \
55 http://localhost:3000/ui/api/newcode
58 # can connect "device" with said code
60 curl -sSf -d '{{"code":"{newcode}", "deviceDesc": "desc", "deviceID":"rm100-123"}}' \
61 http://localhost:3000/token/json/2/device/new
64 # for future improvements
65 machine.log(machine.execute("systemd-analyze security rmfakecloud.service")[1])