Skip to content

Commit

Permalink
Adjust minimum device_api_version for extensions (#1671)
Browse files Browse the repository at this point in the history
  • Loading branch information
nshoes authored Dec 3, 2024
1 parent b0d86f6 commit ef5ca3f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/nerves_hub_web/channels/device_channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -616,5 +616,5 @@ defmodule NervesHubWeb.DeviceChannel do
end
end

defp is_safe_to_request_extensions?(version), do: Version.match?(version, "> 2.5.2")
defp is_safe_to_request_extensions?(version), do: Version.match?(version, ">= 2.2.0")
end
4 changes: 2 additions & 2 deletions test/nerves_hub_web/channels/device_channel_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defmodule NervesHubWeb.DeviceChannelTest do
alias NervesHubWeb.DeviceSocket
alias NervesHubWeb.ExtensionsChannel

test "extensions are requested from device if version is above 2.5.2" do
test "extensions are requested from device if version is above 2.2.0" do
user = Fixtures.user_fixture()
{device, _firmware, _deployment} = device_fixture(user, %{identifier: "123"})
%{db_cert: certificate, cert: _cert} = Fixtures.device_certificate_fixture(device)
Expand All @@ -19,7 +19,7 @@ defmodule NervesHubWeb.DeviceChannelTest do
connect(DeviceSocket, %{}, connect_info: %{peer_data: %{ssl_cert: certificate.der}})

{:ok, _, socket} =
subscribe_and_join(socket, DeviceChannel, "device", %{"device_api_version" => "2.5.3"})
subscribe_and_join(socket, DeviceChannel, "device", %{"device_api_version" => "2.2.0"})

assert_push("extensions:get", _)

Expand Down
4 changes: 2 additions & 2 deletions test/nerves_hub_web/channels/extensions_channel_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,14 @@ defmodule NervesHubWeb.ExtensionsChannelTest do
end

defp subscribe_and_join_with_default_device_api_version(socket, channel, topic),
do: subscribe_and_join(socket, channel, topic, %{"device_api_version" => "2.5.3"})
do: subscribe_and_join(socket, channel, topic, %{"device_api_version" => "2.2.0"})

defp subscribe_and_join_with_default_device_api_version(socket, channel, topic, payload),
do:
subscribe_and_join(
socket,
channel,
topic,
Map.merge(%{"device_api_version" => "2.5.3"}, payload)
Map.merge(%{"device_api_version" => "2.2.0"}, payload)
)
end

0 comments on commit ef5ca3f

Please sign in to comment.