def do_test_ok_preauth_and_remove(self): """ Test the removal of a preauthorized auth set, verify it's gone from all API results. """ # preauthorize preauth_iddata = "{\"mac\":\"preauth-mac\"}" preauth_key = "preauth-key" r = adm.preauth(preauth_iddata, preauth_key) assert r.status_code == 201 devs = adm.get_devices(2) dev_preauth = [d for d in devs if d['device_identity'] == preauth_iddata] assert len(dev_preauth) == 1 dev_preauth = dev_preauth[0] # remove from admission r = adm.delete_auth_set(dev_preauth['id']) assert r.status_code == 204 # verify removed from admission devs = adm.get_devices(1) dev_removed = [d for d in devs if d['device_identity'] == preauth_iddata] assert len(dev_removed) == 0 # verify removed from deviceauth r = deviceauth.get_device(dev_preauth['id']) assert r.status_code == 404 # verify removed from inventory r = inv.get_device(dev_preauth['id']) assert r.status_code == 404
def do_test_ok_preauth_and_remove(self): """ Test the removal of a preauthorized auth set, verify it's gone from all API results. """ # preauthorize preauth_iddata = json.loads("{\"mac\":\"preauth-mac\"}") preauth_key = '''-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzogVU7RGDilbsoUt/DdH VJvcepl0A5+xzGQ50cq1VE/Dyyy8Zp0jzRXCnnu9nu395mAFSZGotZVr+sWEpO3c yC3VmXdBZmXmQdZqbdD/GuixJOYfqta2ytbIUPRXFN7/I7sgzxnXWBYXYmObYvdP okP0mQanY+WKxp7Q16pt1RoqoAd0kmV39g13rFl35muSHbSBoAW3GBF3gO+mF5Ty 1ddp/XcgLOsmvNNjY+2HOD5F/RX0fs07mWnbD7x+xz7KEKjF+H7ZpkqCwmwCXaf0 iyYyh1852rti3Afw4mDxuVSD7sd9ggvYMc0QHIpQNkD4YWOhNiE1AB0zH57VbUYG UwIDAQAB -----END PUBLIC KEY----- ''' r = auth_v2.preauth(preauth_iddata, preauth_key) assert r.status_code == 201 devs = auth_v2.get_devices(2) dev_preauth = [d for d in devs if d['identity_data'] == preauth_iddata] assert len(dev_preauth) == 1 dev_preauth = dev_preauth[0] # remove from deviceauth r = auth_v2.delete_auth_set(dev_preauth['id'], dev_preauth["auth_sets"][0]["id"]) assert r.status_code == 204 # verify removed from deviceauth devs = auth_v2.get_devices(1) dev_removed = [d for d in devs if d['identity_data'] == preauth_iddata] assert len(dev_removed) == 0 # verify removed from deviceauth r = auth_v2.get_device(dev_preauth['id']) assert r.status_code == 404 # verify removed from inventory r = inv.get_device(dev_preauth['id']) assert r.status_code == 404
def check_gone_from_inventory(self, device_id): r = inv.get_device(device_id) assert r.status_code == 404, "device [%s] not removed from inventory" % ( device_id, )