diff --git a/.tool-versions b/.tool-versions index 79f415675..fb3f44dc7 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ -elixir 1.10.2-otp-22 -erlang 22.3.2 -nodejs 10.20.0 +elixir 1.10.3-otp-22 +erlang 22.3.3 +nodejs 10.20.1 diff --git a/apps/cf_http/.tool-versions b/apps/cf_http/.tool-versions deleted file mode 100644 index e61bf801c..000000000 --- a/apps/cf_http/.tool-versions +++ /dev/null @@ -1 +0,0 @@ -elixir 1.9.1-otp-21 diff --git a/apps/cf_http/lib/cf_http/devices/device.ex b/apps/cf_http/lib/cf_http/devices/device.ex index 0857e7af7..8a188fdf3 100644 --- a/apps/cf_http/lib/cf_http/devices/device.ex +++ b/apps/cf_http/lib/cf_http/devices/device.ex @@ -1,4 +1,8 @@ defmodule CfHttp.Devices.Device do + @moduledoc """ + Handles Device stuff when it comes to the DB + """ + use Ecto.Schema import Ecto.Changeset diff --git a/apps/cf_http/lib/cf_http/firewall_rules/firewall_rule.ex b/apps/cf_http/lib/cf_http/firewall_rules/firewall_rule.ex index c1cf3cf97..b134879ba 100644 --- a/apps/cf_http/lib/cf_http/firewall_rules/firewall_rule.ex +++ b/apps/cf_http/lib/cf_http/firewall_rules/firewall_rule.ex @@ -1,4 +1,8 @@ defmodule CfHttp.FirewallRules.FirewallRule do + @moduledoc """ + Not really sure what to write here. I'll update this later. + """ + use Ecto.Schema import Ecto.Changeset diff --git a/apps/cf_http/lib/cf_http/release.ex b/apps/cf_http/lib/cf_http/release.ex index 4b3e1eaac..d2ce12e3c 100644 --- a/apps/cf_http/lib/cf_http/release.ex +++ b/apps/cf_http/lib/cf_http/release.ex @@ -1,4 +1,8 @@ defmodule CfHttp.Release do + @moduledoc """ + Configures the Mix Release or something + """ + @app :cf_http def migrate do diff --git a/apps/cf_http/lib/cf_http/user.ex b/apps/cf_http/lib/cf_http/user.ex index 87d9f87b1..16fdb6011 100644 --- a/apps/cf_http/lib/cf_http/user.ex +++ b/apps/cf_http/lib/cf_http/user.ex @@ -1,4 +1,8 @@ defmodule CfHttp.User do + @moduledoc """ + Represents a User I guess + """ + use Ecto.Schema import Ecto.Changeset diff --git a/apps/cf_http/lib/cf_http_web/controllers/firewall_rule_controller.ex b/apps/cf_http/lib/cf_http_web/controllers/firewall_rule_controller.ex index 6b8ed1206..17884adae 100644 --- a/apps/cf_http/lib/cf_http_web/controllers/firewall_rule_controller.ex +++ b/apps/cf_http/lib/cf_http_web/controllers/firewall_rule_controller.ex @@ -1,9 +1,13 @@ defmodule CfHttpWeb.FirewallRuleController do + @moduledoc """ + Controller logic for FirewallRules + """ + use CfHttpWeb, :controller + alias CfHttp.Devices alias CfHttp.FirewallRules alias CfHttp.FirewallRules.FirewallRule - alias CfHttp.Devices plug CfHttpWeb.Plugs.Authenticator @@ -30,7 +34,7 @@ defmodule CfHttpWeb.FirewallRuleController do {:error, %Ecto.Changeset{} = changeset} -> render(conn, "new.html", changeset: changeset) end - end + end def show(conn, %{"id" => id}) do firewall_rule = FirewallRules.get_firewall_rule!(id) diff --git a/apps/cf_http/lib/cf_http_web/controllers/user_controller.ex b/apps/cf_http/lib/cf_http_web/controllers/user_controller.ex index 0283715e9..2ee715eb5 100644 --- a/apps/cf_http/lib/cf_http_web/controllers/user_controller.ex +++ b/apps/cf_http/lib/cf_http_web/controllers/user_controller.ex @@ -11,6 +11,7 @@ defmodule CfHttpWeb.UserController do # GET /users/new def new(conn, _params) do changeset = User.changeset(%User{}) + conn |> render("new.html", changeset: changeset) end @@ -25,6 +26,7 @@ defmodule CfHttpWeb.UserController do |> assign(:current_user, user) |> put_flash(:info, "User created successfully") |> redirect(to: Routes.device_path(conn, :index)) + {:error, changeset} -> conn |> put_flash(:error, "Error creating user.") @@ -35,6 +37,7 @@ defmodule CfHttpWeb.UserController do # GET /user/edit def edit(conn, _params) do changeset = User.changeset(conn.current_user) + conn |> render("edit.html", changeset: changeset) end @@ -55,6 +58,7 @@ defmodule CfHttpWeb.UserController do |> assign(:current_user, user) |> put_flash(:info, "User updated successfully.") |> redirect(to: Routes.user_path(conn, :show, conn.current_user)) + {:error, changeset} -> conn |> put_flash(:error, "Error updating user.") @@ -70,6 +74,7 @@ defmodule CfHttpWeb.UserController do |> assign(:current_user, nil) |> put_flash(:info, "User deleted successfully.") |> redirect(to: Routes.page_path(conn, :index)) + {:error, _changeset} -> conn |> put_flash(:error, "Error deleting User.") diff --git a/apps/cf_http/lib/cf_http_web/router.ex b/apps/cf_http/lib/cf_http_web/router.ex index fb903eb8b..84a8d6f22 100644 --- a/apps/cf_http/lib/cf_http_web/router.ex +++ b/apps/cf_http/lib/cf_http_web/router.ex @@ -20,9 +20,11 @@ defmodule CfHttpWeb.Router do resources "/user", UserController, singleton: true, only: [:show, :edit, :update, :delete] resources "/users", UserController, only: [:new, :create] + resources "/devices", DeviceController, except: [:create] do resources "/firewall_rules", FirewallRuleController, only: [:new, :index, :create] end + resources "/firewall_rules", FirewallRuleController, only: [:show, :update, :delete, :edit] end diff --git a/apps/cf_http/mix.exs b/apps/cf_http/mix.exs index 4c588fd62..f83576add 100644 --- a/apps/cf_http/mix.exs +++ b/apps/cf_http/mix.exs @@ -41,7 +41,8 @@ defmodule CfHttp.MixProject do {:phoenix_pubsub, "~> 2.0"}, {:phoenix_ecto, "~> 4.0"}, {:ecto_sql, "~> 3.1"}, - {:ecto_network, "~> 1.3.0"}, # Exposes Postgres inet, cidr, macaddr types + # Exposes Postgres inet, cidr, macaddr types + {:ecto_network, "~> 1.3.0"}, {:postgrex, ">= 0.0.0"}, {:phoenix_html, "~> 2.11"}, {:phoenix_live_reload, "~> 1.2", only: :dev}, diff --git a/apps/cf_http/priv/repo/migrations/20200228154815_create_firewall_rules.exs b/apps/cf_http/priv/repo/migrations/20200228154815_create_firewall_rules.exs index db1a7f9b5..336a27fdb 100644 --- a/apps/cf_http/priv/repo/migrations/20200228154815_create_firewall_rules.exs +++ b/apps/cf_http/priv/repo/migrations/20200228154815_create_firewall_rules.exs @@ -10,6 +10,5 @@ defmodule CfHttp.Repo.Migrations.CreateFirewallRules do timestamps() end - end end diff --git a/apps/cf_http/test/cf_http_web/controllers/device_controller_test.exs b/apps/cf_http/test/cf_http_web/controllers/device_controller_test.exs index e129a505a..51fdc0f9e 100644 --- a/apps/cf_http/test/cf_http_web/controllers/device_controller_test.exs +++ b/apps/cf_http/test/cf_http_web/controllers/device_controller_test.exs @@ -58,6 +58,7 @@ defmodule CfHttpWeb.DeviceControllerTest do test "deletes chosen device", %{conn: conn, device: device} do conn = delete(conn, Routes.device_path(conn, :delete, device)) assert redirected_to(conn) == Routes.device_path(conn, :index) + assert_error_sent 404, fn -> get(conn, Routes.device_path(conn, :show, device)) end diff --git a/apps/cf_http/test/support/channel_case.ex b/apps/cf_http/test/support/channel_case.ex index ebe2cbcf1..f16f87f6f 100644 --- a/apps/cf_http/test/support/channel_case.ex +++ b/apps/cf_http/test/support/channel_case.ex @@ -17,6 +17,8 @@ defmodule CfHttpWeb.ChannelCase do use ExUnit.CaseTemplate + alias Ecto.Adapters.SQL.Sandbox + using do quote do # Import conveniences for testing with channels @@ -28,10 +30,10 @@ defmodule CfHttpWeb.ChannelCase do end setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(CfHttp.Repo) + :ok = Sandbox.checkout(CfHttp.Repo) unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(CfHttp.Repo, {:shared, self()}) + Sandbox.mode(CfHttp.Repo, {:shared, self()}) end :ok diff --git a/apps/cf_http/test/support/conn_case.ex b/apps/cf_http/test/support/conn_case.ex index 0ec47b376..a14c510d6 100644 --- a/apps/cf_http/test/support/conn_case.ex +++ b/apps/cf_http/test/support/conn_case.ex @@ -17,6 +17,8 @@ defmodule CfHttpWeb.ConnCase do use ExUnit.CaseTemplate + alias Ecto.Adapters.SQL.Sandbox + using do quote do # Import conveniences for testing with connections @@ -30,10 +32,10 @@ defmodule CfHttpWeb.ConnCase do end setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(CfHttp.Repo) + :ok = Sandbox.checkout(CfHttp.Repo) unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(CfHttp.Repo, {:shared, self()}) + Sandbox.mode(CfHttp.Repo, {:shared, self()}) end {:ok, conn: Phoenix.ConnTest.build_conn()} diff --git a/apps/cf_http/test/support/data_case.ex b/apps/cf_http/test/support/data_case.ex index 24a7163f2..e11c4c13b 100644 --- a/apps/cf_http/test/support/data_case.ex +++ b/apps/cf_http/test/support/data_case.ex @@ -16,6 +16,8 @@ defmodule CfHttp.DataCase do use ExUnit.CaseTemplate + alias Ecto.Adapters.SQL.Sandbox + using do quote do alias CfHttp.Repo @@ -28,10 +30,10 @@ defmodule CfHttp.DataCase do end setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(CfHttp.Repo) + :ok = Sandbox.checkout(CfHttp.Repo) unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(CfHttp.Repo, {:shared, self()}) + Sandbox.mode(CfHttp.Repo, {:shared, self()}) end :ok diff --git a/mix.exs b/mix.exs index e8da2545f..29faca367 100644 --- a/mix.exs +++ b/mix.exs @@ -28,6 +28,8 @@ defmodule CloudfireUmbrella.MixProject do # # Run "mix help deps" for examples and options. defp deps do - [] + [ + {:credo, "~> 1.4", only: [:dev, :test], runtime: false} + ] end end diff --git a/mix.lock b/mix.lock index aa8838d42..73733f638 100644 --- a/mix.lock +++ b/mix.lock @@ -1,7 +1,9 @@ %{ + "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm", "4a0850c9be22a43af9920a71ab17c051f5f7d45c209e40269a1938832510e4d9"}, "cowboy": {:hex, :cowboy, "2.7.0", "91ed100138a764355f43316b1d23d7ff6bdb0de4ea618cb5d8677c93a7a2f115", [:rebar3], [{:cowlib, "~> 2.8.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "04fd8c6a39edc6aaa9c26123009200fc61f92a3a94f3178c527b70b767c6e605"}, "cowlib": {:hex, :cowlib, "2.8.0", "fd0ff1787db84ac415b8211573e9a30a3ebe71b5cbff7f720089972b2319c8a4", [:rebar3], [], "hexpm", "79f954a7021b302186a950a32869dbc185523d99d3e44ce430cd1f3289f41ed4"}, + "credo": {:hex, :credo, "1.4.0", "92339d4cbadd1e88b5ee43d427b639b68a11071b6f73854e33638e30a0ea11f5", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1fd3b70dce216574ce3c18bdf510b57e7c4c85c2ec9cad4bff854abaf7e58658"}, "db_connection": {:hex, :db_connection, "2.2.1", "caee17725495f5129cb7faebde001dc4406796f12a62b8949f4ac69315080566", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "2b02ece62d9f983fcd40954e443b7d9e6589664380e5546b2b9b523cd0fb59e1"}, "decimal": {:hex, :decimal, "1.8.1", "a4ef3f5f3428bdbc0d35374029ffcf4ede8533536fa79896dd450168d9acdf3c", [:mix], [], "hexpm", "3cb154b00225ac687f6cbd4acc4b7960027c757a5152b369923ead9ddbca7aec"}, "ecto": {:hex, :ecto, "3.4.1", "ca5b5f6314eebd7fa2e52c6d78abb1ef955005dd60cc7a047b963ee23ee14a6c", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "748a317a2eacac0b7b6540cb7d2198b79457ede9cec2b4d1582117f90ac309d5"},