handle #55
Better handling if a bot is missing a DID, which could be a corrupt or outdated database.
This commit is contained in:
parent
da9d2bbea7
commit
e690436a37
3 changed files with 28 additions and 3 deletions
|
|
@ -489,7 +489,10 @@ class ConfServer:
|
|||
bumper.user_add_device(tmpuser["userid"], user_devid)
|
||||
|
||||
for bot in bots: # Add all bots to the user
|
||||
bumper.user_add_bot(tmpuser["userid"], bot["did"])
|
||||
if "did" in bot:
|
||||
bumper.user_add_bot(tmpuser["userid"], bot["did"])
|
||||
else:
|
||||
confserverlog.error("No DID for bot: {}".format(bot))
|
||||
|
||||
if "checkLogin" in request.path: # If request was to check a token do so
|
||||
checkToken = self.check_token(
|
||||
|
|
|
|||
|
|
@ -309,7 +309,10 @@ def bot_toEcoVacsHome_JSON(bot): # EcoVacs Home
|
|||
def bot_full_upsert(vacbot):
|
||||
bots = db_get().table("bots")
|
||||
Bot = Query()
|
||||
bots.upsert(vacbot, Bot.did == vacbot["did"])
|
||||
if "did" in vacbot:
|
||||
bots.upsert(vacbot, Bot.did == vacbot["did"])
|
||||
else:
|
||||
bumperlog.error("No DID in vacbot: {}".format(vacbot))
|
||||
|
||||
|
||||
def bot_set_nick(did, nick):
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ async def test_login(aiohttp_client):
|
|||
assert "username" in jsonresp["data"]
|
||||
|
||||
remove_existing_db()
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
|
||||
# Test global_e without user
|
||||
resp = await client.get("/v1/private/us/en/dev_1234/global_e/1/0/0/user/login")
|
||||
|
|
@ -118,6 +118,25 @@ async def test_login(aiohttp_client):
|
|||
assert "uid" in jsonresp["data"]
|
||||
assert "username" in jsonresp["data"]
|
||||
|
||||
# Add a bot to db that doesn't have a did
|
||||
newbot = {
|
||||
"class": "dev_1234",
|
||||
"company": "com_123",
|
||||
#"did": self.did,
|
||||
"name": "sn_1234",
|
||||
"resource": "res_1234",
|
||||
}
|
||||
bumper.bot_full_upsert(newbot)
|
||||
|
||||
resp = await client.get("/v1/private/us/en/dev_1234/ios/1/0/0/user/login")
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
assert "accessToken" in jsonresp["data"]
|
||||
assert "uid" in jsonresp["data"]
|
||||
assert "username" in jsonresp["data"]
|
||||
|
||||
|
||||
async def test_logout(aiohttp_client):
|
||||
remove_existing_db()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue