diff --git a/apps/fg_http/lib/fg_http_web/mock_events.ex b/apps/fg_http/lib/fg_http_web/mock_events.ex
index 986a1eb5d..a7d99c743 100644
--- a/apps/fg_http/lib/fg_http_web/mock_events.ex
+++ b/apps/fg_http/lib/fg_http_web/mock_events.ex
@@ -8,13 +8,7 @@ defmodule FgHttpWeb.MockEvents do
"""
def create_device do
- {:ok,
- %{
- private_key: "privkey",
- public_key: "pubkey",
- server_public_key: "server_pubkey",
- preshared_key: "preshared_key"
- }}
+ {:ok, "privkey", "pubkey", "server_pubkey", "preshared_key"}
end
def delete_device(pubkey) do
diff --git a/apps/fg_http/lib/fg_http_web/router.ex b/apps/fg_http/lib/fg_http_web/router.ex
index 4b3e33d3e..f08d847d2 100644
--- a/apps/fg_http/lib/fg_http_web/router.ex
+++ b/apps/fg_http/lib/fg_http_web/router.ex
@@ -3,7 +3,6 @@ defmodule FgHttpWeb.Router do
Main Application Router
"""
- alias FgHttpWeb.{BlacklistLive, DeviceDetailsLive, WhitelistLive}
use FgHttpWeb, :router
# View emails locally in development
@@ -26,8 +25,7 @@ defmodule FgHttpWeb.Router do
scope "/", FgHttpWeb do
pipe_through :browser
live "/live/device_details", DeviceDetailsLive
- live "/live/whitelist", WhitelistLive
- live "/live/blacklist", BlacklistLive
+ live "/live/rules", RulesLive
resources "/password_resets", PasswordResetController, only: [:update, :new, :create]
get "/password_resets/:reset_token", PasswordResetController, :edit
diff --git a/apps/fg_http/lib/fg_http_web/templates/device/index.html.eex b/apps/fg_http/lib/fg_http_web/templates/device/index.html.eex
index f109b07cb..329f0febb 100644
--- a/apps/fg_http/lib/fg_http_web/templates/device/index.html.eex
+++ b/apps/fg_http/lib/fg_http_web/templates/device/index.html.eex
@@ -1,5 +1,5 @@
-
Devices
+
Devices
diff --git a/apps/fg_http/lib/fg_http_web/templates/device/show.html.eex b/apps/fg_http/lib/fg_http_web/templates/device/show.html.eex
index 935079df2..47a050c7f 100644
--- a/apps/fg_http/lib/fg_http_web/templates/device/show.html.eex
+++ b/apps/fg_http/lib/fg_http_web/templates/device/show.html.eex
@@ -1,5 +1,5 @@
-
<%= @device.name %>
+
<%= @device.name %>
diff --git a/apps/fg_http/lib/fg_http_web/templates/user/edit.html.eex b/apps/fg_http/lib/fg_http_web/templates/user/edit.html.eex
index 344f556c8..36f7e85a7 100644
--- a/apps/fg_http/lib/fg_http_web/templates/user/edit.html.eex
+++ b/apps/fg_http/lib/fg_http_web/templates/user/edit.html.eex
@@ -2,7 +2,7 @@
-
Edit Account
+
Edit Account
<%= form_for @changeset, Routes.user_path(@conn, :update), fn f -> %>
<%= if @changeset.action do %>
diff --git a/apps/fg_http/lib/fg_http_web/templates/user/show.html.eex b/apps/fg_http/lib/fg_http_web/templates/user/show.html.eex
index 96a706ef3..6b0d5a13c 100644
--- a/apps/fg_http/lib/fg_http_web/templates/user/show.html.eex
+++ b/apps/fg_http/lib/fg_http_web/templates/user/show.html.eex
@@ -1,7 +1,7 @@
-
Your Account
+
Your Account
-
diff --git a/apps/fg_http/test/fg_http/devices_test.exs b/apps/fg_http/test/fg_http/devices_test.exs
index 93b156c83..02b01a6e4 100644
--- a/apps/fg_http/test/fg_http/devices_test.exs
+++ b/apps/fg_http/test/fg_http/devices_test.exs
@@ -1,6 +1,5 @@
defmodule FgHttp.DevicesTest do
- use FgHttp.DataCase
- import FgHttp.TestHelpers
+ use FgHttp.DataCase, async: true
alias FgHttp.Devices
describe "list_devices/0" do
diff --git a/apps/fg_http/test/fg_http_web/controllers/device_controller_test.exs b/apps/fg_http/test/fg_http_web/controllers/device_controller_test.exs
index d72416559..a4e6abbb5 100644
--- a/apps/fg_http/test/fg_http_web/controllers/device_controller_test.exs
+++ b/apps/fg_http/test/fg_http_web/controllers/device_controller_test.exs
@@ -1,8 +1,5 @@
defmodule FgHttpWeb.DeviceControllerUnauthedTest do
use FgHttpWeb.ConnCase, async: true
- import FgHttp.TestHelpers
-
- @update_attrs %{name: "some updated name"}
describe "index" do
test "redirects to new session", %{unauthed_conn: conn} do
@@ -11,32 +8,23 @@ defmodule FgHttpWeb.DeviceControllerUnauthedTest do
end
end
- describe "create device" do
+ describe "show" do
+ setup [:create_device]
+
+ test "redirects to new session", %{unauthed_conn: conn, device: device} do
+ test_conn = get(conn, Routes.device_path(conn, :show, device))
+ assert redirected_to(test_conn) == Routes.session_path(test_conn, :new)
+ end
+ end
+
+ describe "create" do
test "redirects to new session", %{unauthed_conn: conn} do
test_conn = post(conn, Routes.device_path(conn, :create))
assert redirected_to(test_conn) == Routes.session_path(test_conn, :new)
end
end
- describe "edit device" do
- setup [:create_device]
-
- test "redirects to new session", %{unauthed_conn: conn, device: device} do
- test_conn = get(conn, Routes.device_path(conn, :edit, device))
- assert redirected_to(test_conn) == Routes.session_path(test_conn, :new)
- end
- end
-
- describe "update device" do
- setup [:create_device]
-
- test "redirects to new session", %{unauthed_conn: conn, device: device} do
- test_conn = put(conn, Routes.device_path(conn, :update, device), device: @update_attrs)
- assert redirected_to(test_conn) == Routes.session_path(test_conn, :new)
- end
- end
-
- describe "delete device" do
+ describe "delete" do
setup [:create_device]
test "redirects to new session", %{unauthed_conn: conn, device: device} do
@@ -48,10 +36,6 @@ end
defmodule FgHttpWeb.DeviceControllerAuthedTest do
use FgHttpWeb.ConnCase, async: true
- import FgHttp.TestHelpers
-
- @update_attrs %{name: "some updated name"}
- @invalid_attrs %{public_key: nil}
describe "show" do
setup [:create_device]
@@ -67,12 +51,12 @@ defmodule FgHttpWeb.DeviceControllerAuthedTest do
test "lists all devices", %{authed_conn: conn, device: device} do
test_conn = get(conn, Routes.device_path(conn, :index))
- assert html_response(test_conn, 200) =~ "Listing Devices"
+ assert html_response(test_conn, 200) =~ "
Devices
"
assert html_response(test_conn, 200) =~ device.name
end
end
- describe "create device" do
+ describe "create" do
test "redirects when data is valid", %{authed_conn: conn} do
test_conn = post(conn, Routes.device_path(conn, :create))
devices = FgHttp.Devices.list_devices()
@@ -81,33 +65,7 @@ defmodule FgHttpWeb.DeviceControllerAuthedTest do
end
end
- describe "edit device" do
- setup [:create_device]
-
- test "renders form for editing chosen device", %{authed_conn: conn, device: device} do
- test_conn = get(conn, Routes.device_path(conn, :edit, device))
- assert html_response(test_conn, 200) =~ "Edit Device"
- end
- end
-
- describe "update device" do
- setup [:create_device]
-
- test "redirects when data is valid", %{authed_conn: conn, device: device} do
- test_conn = put(conn, Routes.device_path(conn, :update, device), device: @update_attrs)
- assert redirected_to(test_conn) == Routes.device_path(conn, :show, device)
-
- test_conn = get(conn, Routes.device_path(conn, :show, device))
- assert html_response(test_conn, 200) =~ "some updated name"
- end
-
- test "renders errors when data is invalid", %{authed_conn: conn, device: device} do
- conn = put(conn, Routes.device_path(conn, :update, device), device: @invalid_attrs)
- assert html_response(conn, 200) =~ "Edit Device"
- end
- end
-
- describe "delete device" do
+ describe "delete" do
setup [:create_device]
test "deletes chosen device", %{authed_conn: conn, device: device} do
diff --git a/apps/fg_http/test/fg_http_web/live/device_details_live_test.exs b/apps/fg_http/test/fg_http_web/live/device_details_live_test.exs
new file mode 100644
index 000000000..fc8d36de6
--- /dev/null
+++ b/apps/fg_http/test/fg_http_web/live/device_details_live_test.exs
@@ -0,0 +1,11 @@
+defmodule FgHttpWeb.DeviceDetailsLiveTest do
+ use FgHttpWeb.ConnCase, async: true
+
+ setup :create_device
+
+ test "connected mount", %{authed_conn: conn, device: device} do
+ path = Routes.device_path(conn, :show, device)
+ {:ok, view, html} = live(conn, path)
+ assert html =~ "#{device.name}
"
+ end
+end
diff --git a/apps/fg_http/test/fg_http_web/live/rules_live_test.exs b/apps/fg_http/test/fg_http_web/live/rules_live_test.exs
new file mode 100644
index 000000000..bec7f6581
--- /dev/null
+++ b/apps/fg_http/test/fg_http_web/live/rules_live_test.exs
@@ -0,0 +1,3 @@
+defmodule FgHttpWeb.RulesLiveTest do
+ use FgHttpWeb.ConnCase, async: true
+end
diff --git a/apps/fg_http/test/support/channel_case.ex b/apps/fg_http/test/support/channel_case.ex
index 84dd0f8f3..5c552b3a3 100644
--- a/apps/fg_http/test/support/channel_case.ex
+++ b/apps/fg_http/test/support/channel_case.ex
@@ -23,6 +23,7 @@ defmodule FgHttpWeb.ChannelCase do
quote do
# Import conveniences for testing with channels
use Phoenix.ChannelTest
+ import FgHttp.TestHelpers
# The default endpoint for testing
@endpoint FgHttpWeb.Endpoint
diff --git a/apps/fg_http/test/support/conn_case.ex b/apps/fg_http/test/support/conn_case.ex
index f8bbc84c2..b0d47d7bc 100644
--- a/apps/fg_http/test/support/conn_case.ex
+++ b/apps/fg_http/test/support/conn_case.ex
@@ -26,6 +26,8 @@ defmodule FgHttpWeb.ConnCase do
# Import conveniences for testing with connections
import Plug.Conn
import Phoenix.ConnTest
+ import Phoenix.LiveViewTest
+ import FgHttp.TestHelpers
alias FgHttpWeb.Router.Helpers, as: Routes
# The default endpoint for testing
diff --git a/apps/fg_http/test/support/data_case.ex b/apps/fg_http/test/support/data_case.ex
index dc043f428..ec32f4e75 100644
--- a/apps/fg_http/test/support/data_case.ex
+++ b/apps/fg_http/test/support/data_case.ex
@@ -26,6 +26,7 @@ defmodule FgHttp.DataCase do
import Ecto.Changeset
import Ecto.Query
import FgHttp.DataCase
+ import FgHttp.TestHelpers
end
end