buffet: Handle cloud request failures due to device deleted on cloud

When making cloud request and receiving "authorization failed" error,
we are refreshing the access token. If that fails with "invalid_grant",
we are certain that the device's robot account has been deleted, so
we should treat the device as no longer registered with the cloud, and
delete its cached credentials.

This CL adds OnDeviceDeleted() notification which wipes out the device
registration information. This notification is called when refreshing
the access token fails with "invalid_grant".

A follow-up CL will add handling for DEVICE_DELETED XMPP notification.

BUG=brillo:1215
TEST=`FEATURES=test emerge-link buffet`
     `test_that -b link 100.96.49.59 e:buffet_.*`
CQ-DEPEND=CL:281664

Change-Id: I220c286dbd286dd036d7664a4d14e9d761d70f28
Reviewed-on: https://chromium-review.googlesource.com/281393
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Trybot-Ready: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
4 files changed
tree: 69edeee2d172d0438e5f9b51031c5bdad5643621
  1. buffet/