Ejemplo n.º 1
0
def change_authset_status(dauthm, did, aid, status, utoken):
    r = dauthm.with_auth(utoken).call(
        "PUT",
        deviceauth.URL_AUTHSET_STATUS,
        deviceauth.req_status(status),
        path_params={"did": did, "aid": aid},
    )
    assert r.status_code == 204
Ejemplo n.º 2
0
        def set_device_status_in_mender(desired_status: str):
            """Set device status in Mender."""
            if self.azure_iot_hub_mock:
                httpserver.expect_oneshot_request(
                    re.compile("^/devices"),
                    method="GET",
                    query_string="api-version=2021-04-12",
                ).respond_with_json(
                    self._prepare_iot_hub_upsert_device_response())
                httpserver.expect_oneshot_request(
                    re.compile("^/devices"),
                    method="PUT",
                    query_string="api-version=2021-04-12",
                ).respond_with_json(
                    self._prepare_iot_hub_upsert_device_response(
                        status="disabled"))

            authset_id = dev.authsets[0].id
            if status == "noauth":
                rsp = self.api_devauth_mgmt.with_auth(azure_user.token).call(
                    "DELETE",
                    deviceauth.URL_AUTHSET,
                    path_params={
                        "did": dev.id,
                        "aid": authset_id
                    },
                )
            else:
                rsp = self.api_devauth_mgmt.with_auth(azure_user.token).call(
                    "PUT",
                    deviceauth.URL_AUTHSET_STATUS,
                    deviceauth.req_status(desired_status),
                    path_params={
                        "did": dev.id,
                        "aid": authset_id
                    },
                )
            assert rsp.status_code == 204