@Path("/{destination}")
  @PUT
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public void sendProvisioningMessage(@ReadOnly @Auth AuthenticatedDevice auth,
      @PathParam("destination") String destinationName,
      @NotNull @Valid ProvisioningMessage message,
      @HeaderParam(HttpHeaders.USER_AGENT) String userAgent)
      throws RateLimitExceededException {

    if (message.body().length() > MAX_MESSAGE_SIZE) {
      Metrics.counter(REJECT_OVERSIZE_MESSAGE_COUNTER, Tags.of(UserAgentTagUtil.getPlatformTag(userAgent)))
          .increment();
      throw new WebApplicationException(Response.Status.BAD_REQUEST);
    }

    rateLimiters.getMessagesLimiter().validate(auth.getAccount().getUuid());

    if (!provisioningManager.sendProvisioningMessage(ProvisioningAddress.create(destinationName),
        Base64.getMimeDecoder().decode(message.body()))) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
  }
@Test
  void sendProvisioningMessageRateLimited() throws RateLimitExceededException {
    final String destination = UUID.randomUUID().toString();
    final byte[] messageBody = "test".getBytes(StandardCharsets.UTF_8);

    doThrow(new RateLimitExceededException(Duration.ZERO))
        .when(messagesRateLimiter).validate(AuthHelper.VALID_UUID);

    try (final Response response = RESOURCE_EXTENSION.getJerseyTest()
        .target("/v1/provisioning/" + destination)
        .request()
        .header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
        .put(Entity.entity(new ProvisioningMessage(Base64.getMimeEncoder().encodeToString(messageBody)),
            MediaType.APPLICATION_JSON))) {

      assertEquals(429, response.getStatus());

      verify(provisioningManager, never()).sendProvisioningMessage(any(), any());
    }
  }