mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
Rename CfPhx -> CfHttp success
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
# CfPhx
|
||||
# CfHttp
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
defmodule CfPhx do
|
||||
defmodule CfHttp do
|
||||
@moduledoc """
|
||||
CfPhx keeps the contexts that define your domain
|
||||
CfHttp keeps the contexts that define your domain
|
||||
and business logic.
|
||||
|
||||
Contexts are also responsible for managing your data, regardless
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhx.Application do
|
||||
defmodule CfHttp.Application do
|
||||
# See https://hexdocs.pm/elixir/Application.html
|
||||
# for more information on OTP Applications
|
||||
@moduledoc false
|
||||
@@ -9,25 +9,25 @@ defmodule CfPhx.Application do
|
||||
# List all child processes to be supervised
|
||||
children = [
|
||||
# Start the Ecto repository
|
||||
CfPhx.Repo,
|
||||
CfHttp.Repo,
|
||||
# Start the PubSub system
|
||||
{Phoenix.PubSub, name: CfPhx.PubSub},
|
||||
{Phoenix.PubSub, name: CfHttp.PubSub},
|
||||
# Start the endpoint when the application starts
|
||||
CfPhxWeb.Endpoint
|
||||
# Starts a worker by calling: CfPhx.Worker.start_link(arg)
|
||||
# {CfPhx.Worker, arg},
|
||||
CfHttpWeb.Endpoint
|
||||
# Starts a worker by calling: CfHttp.Worker.start_link(arg)
|
||||
# {CfHttp.Worker, arg},
|
||||
]
|
||||
|
||||
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||
# for other strategies and supported options
|
||||
opts = [strategy: :one_for_one, name: CfPhx.Supervisor]
|
||||
opts = [strategy: :one_for_one, name: CfHttp.Supervisor]
|
||||
Supervisor.start_link(children, opts)
|
||||
end
|
||||
|
||||
# Tell Phoenix to update the endpoint configuration
|
||||
# whenever the application is updated.
|
||||
def config_change(changed, _new, removed) do
|
||||
CfPhxWeb.Endpoint.config_change(changed, removed)
|
||||
CfHttpWeb.Endpoint.config_change(changed, removed)
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
defmodule CfPhx.Devices do
|
||||
defmodule CfHttp.Devices do
|
||||
@moduledoc """
|
||||
The Devices context.
|
||||
"""
|
||||
|
||||
import Ecto.Query, warn: false
|
||||
alias CfPhx.Repo
|
||||
alias CfHttp.Repo
|
||||
|
||||
alias CfPhx.Devices.Device
|
||||
alias CfHttp.Devices.Device
|
||||
|
||||
@doc """
|
||||
Returns the list of devices.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhx.Devices.Device do
|
||||
defmodule CfHttp.Devices.Device do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
@@ -8,7 +8,7 @@ defmodule CfPhx.Devices.Device do
|
||||
field :verified_at, :utc_datetime
|
||||
field :user_id, :id
|
||||
|
||||
has_many :firewall_rules, CfPhx.FirewallRules.FirewallRule
|
||||
has_many :firewall_rules, CfHttp.FirewallRules.FirewallRule
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
defmodule CfPhx.FirewallRules do
|
||||
defmodule CfHttp.FirewallRules do
|
||||
@moduledoc """
|
||||
The FirewallRules context.
|
||||
"""
|
||||
|
||||
import Ecto.Query, warn: false
|
||||
alias CfPhx.Repo
|
||||
alias CfHttp.Repo
|
||||
|
||||
alias CfPhx.FirewallRules.FirewallRule
|
||||
alias CfHttp.FirewallRules.FirewallRule
|
||||
|
||||
@doc """
|
||||
Returns the list of firewall_rules.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhx.FirewallRules.FirewallRule do
|
||||
defmodule CfHttp.FirewallRules.FirewallRule do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
@@ -8,7 +8,7 @@ defmodule CfPhx.FirewallRules.FirewallRule do
|
||||
field :port, :string
|
||||
field :protocol, :string
|
||||
|
||||
belongs_to :device, CfPhx.Devices.Device
|
||||
belongs_to :device, CfHttp.Devices.Device
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhx.Release do
|
||||
defmodule CfHttp.Release do
|
||||
@app :cf_http
|
||||
|
||||
def migrate do
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhx.Repo do
|
||||
defmodule CfHttp.Repo do
|
||||
use Ecto.Repo,
|
||||
otp_app: :cf_http,
|
||||
adapter: Ecto.Adapters.Postgres
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhx.User do
|
||||
defmodule CfHttp.User do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
defmodule CfPhxWeb do
|
||||
defmodule CfHttpWeb do
|
||||
@moduledoc """
|
||||
The entrypoint for defining your web interface, such
|
||||
as controllers, views, channels and so on.
|
||||
|
||||
This can be used in your application as:
|
||||
|
||||
use CfPhxWeb, :controller
|
||||
use CfPhxWeb, :view
|
||||
use CfHttpWeb, :controller
|
||||
use CfHttpWeb, :view
|
||||
|
||||
The definitions below will be executed for every view,
|
||||
controller, etc, so keep them short and clean, focused
|
||||
@@ -19,11 +19,11 @@ defmodule CfPhxWeb do
|
||||
|
||||
def controller do
|
||||
quote do
|
||||
use Phoenix.Controller, namespace: CfPhxWeb
|
||||
use Phoenix.Controller, namespace: CfHttpWeb
|
||||
|
||||
import Plug.Conn
|
||||
import CfPhxWeb.Gettext
|
||||
alias CfPhxWeb.Router.Helpers, as: Routes
|
||||
import CfHttpWeb.Gettext
|
||||
alias CfHttpWeb.Router.Helpers, as: Routes
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,7 +31,7 @@ defmodule CfPhxWeb do
|
||||
quote do
|
||||
use Phoenix.View,
|
||||
root: "lib/cf_http_web/templates",
|
||||
namespace: CfPhxWeb
|
||||
namespace: CfHttpWeb
|
||||
|
||||
# Import convenience functions from controllers
|
||||
import Phoenix.Controller, only: [get_flash: 1, get_flash: 2, view_module: 1]
|
||||
@@ -39,9 +39,9 @@ defmodule CfPhxWeb do
|
||||
# Use all HTML functionality (forms, tags, etc)
|
||||
use Phoenix.HTML
|
||||
|
||||
import CfPhxWeb.ErrorHelpers
|
||||
import CfPhxWeb.Gettext
|
||||
alias CfPhxWeb.Router.Helpers, as: Routes
|
||||
import CfHttpWeb.ErrorHelpers
|
||||
import CfHttpWeb.Gettext
|
||||
alias CfHttpWeb.Router.Helpers, as: Routes
|
||||
end
|
||||
end
|
||||
|
||||
@@ -56,7 +56,7 @@ defmodule CfPhxWeb do
|
||||
def channel do
|
||||
quote do
|
||||
use Phoenix.Channel
|
||||
import CfPhxWeb.Gettext
|
||||
import CfHttpWeb.Gettext
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
defmodule CfPhxWeb.UserSocket do
|
||||
defmodule CfHttpWeb.UserSocket do
|
||||
use Phoenix.Socket
|
||||
|
||||
## Channels
|
||||
# channel "room:*", CfPhxWeb.RoomChannel
|
||||
# channel "room:*", CfHttpWeb.RoomChannel
|
||||
|
||||
# Socket params are passed from the client and can
|
||||
# be used to verify and authenticate a user. After
|
||||
@@ -26,7 +26,7 @@ defmodule CfPhxWeb.UserSocket do
|
||||
# Would allow you to broadcast a "disconnect" event and terminate
|
||||
# all active sockets and channels for a given user:
|
||||
#
|
||||
# CfPhxWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
|
||||
# CfHttpWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
|
||||
#
|
||||
# Returning `nil` makes this socket anonymous.
|
||||
def id(_socket), do: nil
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
defmodule CfPhxWeb.DeviceController do
|
||||
use CfPhxWeb, :controller
|
||||
defmodule CfHttpWeb.DeviceController do
|
||||
use CfHttpWeb, :controller
|
||||
|
||||
alias CfPhx.Devices
|
||||
alias CfPhx.Devices.Device
|
||||
alias CfHttp.Devices
|
||||
alias CfHttp.Devices.Device
|
||||
|
||||
plug CfPhxWeb.Plugs.Authenticator
|
||||
plug CfHttpWeb.Plugs.Authenticator
|
||||
|
||||
def index(conn, _params) do
|
||||
devices = Devices.list_devices()
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
defmodule CfPhxWeb.FirewallRuleController do
|
||||
use CfPhxWeb, :controller
|
||||
defmodule CfHttpWeb.FirewallRuleController do
|
||||
use CfHttpWeb, :controller
|
||||
|
||||
alias CfPhx.FirewallRules
|
||||
alias CfPhx.FirewallRules.FirewallRule
|
||||
alias CfPhx.Devices
|
||||
alias CfHttp.FirewallRules
|
||||
alias CfHttp.FirewallRules.FirewallRule
|
||||
alias CfHttp.Devices
|
||||
|
||||
plug CfPhxWeb.Plugs.Authenticator
|
||||
plug CfHttpWeb.Plugs.Authenticator
|
||||
|
||||
def index(conn, %{"device_id" => device_id}) do
|
||||
device = Devices.get_device!(device_id)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
defmodule CfPhxWeb.PageController do
|
||||
use CfPhxWeb, :controller
|
||||
defmodule CfHttpWeb.PageController do
|
||||
use CfHttpWeb, :controller
|
||||
|
||||
def index(conn, _params) do
|
||||
render(conn, "index.html")
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
defmodule CfPhxWeb.UserController do
|
||||
defmodule CfHttpWeb.UserController do
|
||||
@moduledoc """
|
||||
Implements the CRUD for a User
|
||||
"""
|
||||
|
||||
use CfPhxWeb, :controller
|
||||
alias CfPhx.{Repo, User}
|
||||
use CfHttpWeb, :controller
|
||||
alias CfHttp.{Repo, User}
|
||||
|
||||
plug CfPhxWeb.Plugs.Authenticator when action in [:show, :edit, :update, :delete]
|
||||
plug CfHttpWeb.Plugs.Authenticator when action in [:show, :edit, :update, :delete]
|
||||
|
||||
# GET /users/new
|
||||
def new(conn, _params) do
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhxWeb.Endpoint do
|
||||
defmodule CfHttpWeb.Endpoint do
|
||||
use Phoenix.Endpoint, otp_app: :cf_http
|
||||
|
||||
# The session will be stored in the cookie and signed,
|
||||
@@ -10,7 +10,7 @@ defmodule CfPhxWeb.Endpoint do
|
||||
signing_salt: "Z9eq8iof"
|
||||
]
|
||||
|
||||
socket "/socket", CfPhxWeb.UserSocket,
|
||||
socket "/socket", CfHttpWeb.UserSocket,
|
||||
websocket: true,
|
||||
longpoll: false
|
||||
|
||||
@@ -43,5 +43,5 @@ defmodule CfPhxWeb.Endpoint do
|
||||
plug Plug.MethodOverride
|
||||
plug Plug.Head
|
||||
plug Plug.Session, @session_options
|
||||
plug CfPhxWeb.Router
|
||||
plug CfHttpWeb.Router
|
||||
end
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
defmodule CfPhxWeb.Gettext do
|
||||
defmodule CfHttpWeb.Gettext do
|
||||
@moduledoc """
|
||||
A module providing Internationalization with a gettext-based API.
|
||||
|
||||
By using [Gettext](https://hexdocs.pm/gettext),
|
||||
your module gains a set of macros for translations, for example:
|
||||
|
||||
import CfPhxWeb.Gettext
|
||||
import CfHttpWeb.Gettext
|
||||
|
||||
# Simple translation
|
||||
gettext("Here is the string to translate")
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
defmodule CfPhxWeb.Plugs.Authenticator do
|
||||
defmodule CfHttpWeb.Plugs.Authenticator do
|
||||
@moduledoc """
|
||||
Loads the user's session from cookie
|
||||
"""
|
||||
|
||||
import Plug.Conn
|
||||
alias CfPhx.User
|
||||
alias CfHttp.User
|
||||
|
||||
def init(default), do: default
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
defmodule CfPhxWeb.Router do
|
||||
use CfPhxWeb, :router
|
||||
defmodule CfHttpWeb.Router do
|
||||
use CfHttpWeb, :router
|
||||
|
||||
pipeline :browser do
|
||||
plug :accepts, ["html"]
|
||||
@@ -13,7 +13,7 @@ defmodule CfPhxWeb.Router do
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
scope "/", CfPhxWeb do
|
||||
scope "/", CfHttpWeb do
|
||||
pipe_through :browser
|
||||
|
||||
get "/", PageController, :index
|
||||
@@ -27,7 +27,7 @@ defmodule CfPhxWeb.Router do
|
||||
end
|
||||
|
||||
# Other scopes may use custom stacks.
|
||||
# scope "/api", CfPhxWeb do
|
||||
# scope "/api", CfHttpWeb do
|
||||
# pipe_through :api
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<li><a href="<%= Routes.device_path(@conn, :index) %>">Devices</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<a href="<%= CfPhxWeb.Endpoint.url() %>" class="cf-logo">
|
||||
<a href="<%= CfHttpWeb.Endpoint.url() %>" class="cf-logo">
|
||||
<img src="<%= Routes.static_path(@conn, "/images/logo.svg") %>" alt="Cloudfire Logo"/>
|
||||
</a>
|
||||
</section>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
defmodule CfPhxWeb.DeviceView do
|
||||
use CfPhxWeb, :view
|
||||
defmodule CfHttpWeb.DeviceView do
|
||||
use CfHttpWeb, :view
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhxWeb.ErrorHelpers do
|
||||
defmodule CfHttpWeb.ErrorHelpers do
|
||||
@moduledoc """
|
||||
Conveniences for translating and building error messages.
|
||||
"""
|
||||
@@ -36,9 +36,9 @@ defmodule CfPhxWeb.ErrorHelpers do
|
||||
# should be written to the errors.po file. The :count option is
|
||||
# set by Ecto and indicates we should also apply plural rules.
|
||||
if count = opts[:count] do
|
||||
Gettext.dngettext(CfPhxWeb.Gettext, "errors", msg, msg, count, opts)
|
||||
Gettext.dngettext(CfHttpWeb.Gettext, "errors", msg, msg, count, opts)
|
||||
else
|
||||
Gettext.dgettext(CfPhxWeb.Gettext, "errors", msg, opts)
|
||||
Gettext.dgettext(CfHttpWeb.Gettext, "errors", msg, opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
defmodule CfPhxWeb.ErrorView do
|
||||
use CfPhxWeb, :view
|
||||
defmodule CfHttpWeb.ErrorView do
|
||||
use CfHttpWeb, :view
|
||||
|
||||
# If you want to customize a particular status code
|
||||
# for a certain format, you may uncomment below.
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
defmodule CfPhxWeb.FirewallRuleView do
|
||||
use CfPhxWeb, :view
|
||||
defmodule CfHttpWeb.FirewallRuleView do
|
||||
use CfHttpWeb, :view
|
||||
end
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
defmodule CfPhxWeb.LayoutView do
|
||||
use CfPhxWeb, :view
|
||||
defmodule CfHttpWeb.LayoutView do
|
||||
use CfHttpWeb, :view
|
||||
end
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
defmodule CfPhxWeb.PageView do
|
||||
use CfPhxWeb, :view
|
||||
defmodule CfHttpWeb.PageView do
|
||||
use CfHttpWeb, :view
|
||||
end
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
defmodule CfPhxWeb.UserView do
|
||||
use CfPhxWeb, :view
|
||||
defmodule CfHttpWeb.UserView do
|
||||
use CfHttpWeb, :view
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhx.MixProject do
|
||||
defmodule CfHttp.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
@@ -23,7 +23,7 @@ defmodule CfPhx.MixProject do
|
||||
# Type `mix help compile.app` for more information.
|
||||
def application do
|
||||
[
|
||||
mod: {CfPhx.Application, []},
|
||||
mod: {CfHttp.Application, []},
|
||||
extra_applications: [:logger, :runtime_tools]
|
||||
]
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhx.Repo.Migrations.CreateUsers do
|
||||
defmodule CfHttp.Repo.Migrations.CreateUsers do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhx.Repo.Migrations.CreateDevices do
|
||||
defmodule CfHttp.Repo.Migrations.CreateDevices do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhx.Repo.Migrations.CreateFirewallRules do
|
||||
defmodule CfHttp.Repo.Migrations.CreateFirewallRules do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# Inside the script, you can read and write to any of your
|
||||
# repositories directly:
|
||||
#
|
||||
# CfPhx.Repo.insert!(%CfPhx.SomeSchema{})
|
||||
# CfHttp.Repo.insert!(%CfHttp.SomeSchema{})
|
||||
#
|
||||
# We recommend using the bang functions (`insert!`, `update!`
|
||||
# and so on) as they will fail if something goes wrong.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
defmodule CfPhx.DevicesTest do
|
||||
use CfPhx.DataCase
|
||||
defmodule CfHttp.DevicesTest do
|
||||
use CfHttp.DataCase
|
||||
|
||||
describe "devices" do
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
defmodule CfPhx.FirewallRulesTest do
|
||||
use CfPhx.DataCase
|
||||
defmodule CfHttp.FirewallRulesTest do
|
||||
use CfHttp.DataCase
|
||||
|
||||
describe "firewall_rules" do
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule CfPhxWeb.DeviceControllerTest do
|
||||
use CfPhxWeb.ConnCase
|
||||
defmodule CfHttpWeb.DeviceControllerTest do
|
||||
use CfHttpWeb.ConnCase
|
||||
|
||||
alias CfPhx.Devices
|
||||
alias CfHttp.Devices
|
||||
|
||||
@create_attrs %{name: "some name"}
|
||||
@update_attrs %{name: "some updated name"}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
defmodule CfPhxWeb.FirewallRuleControllerTest do
|
||||
use CfPhxWeb.ConnCase
|
||||
defmodule CfHttpWeb.FirewallRuleControllerTest do
|
||||
use CfHttpWeb.ConnCase
|
||||
|
||||
describe "index" do
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
defmodule CfPhxWeb.PageControllerTest do
|
||||
use CfPhxWeb.ConnCase
|
||||
defmodule CfHttpWeb.PageControllerTest do
|
||||
use CfHttpWeb.ConnCase
|
||||
|
||||
test "GET /", %{conn: conn} do
|
||||
conn = get(conn, "/")
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
defmodule CfPhxWeb.ErrorViewTest do
|
||||
use CfPhxWeb.ConnCase, async: true
|
||||
defmodule CfHttpWeb.ErrorViewTest do
|
||||
use CfHttpWeb.ConnCase, async: true
|
||||
|
||||
# Bring render/3 and render_to_string/3 for testing custom views
|
||||
import Phoenix.View
|
||||
|
||||
test "renders 404.html" do
|
||||
assert render_to_string(CfPhxWeb.ErrorView, "404.html", []) == "Not Found"
|
||||
assert render_to_string(CfHttpWeb.ErrorView, "404.html", []) == "Not Found"
|
||||
end
|
||||
|
||||
test "renders 500.html" do
|
||||
assert render_to_string(CfPhxWeb.ErrorView, "500.html", []) == "Internal Server Error"
|
||||
assert render_to_string(CfHttpWeb.ErrorView, "500.html", []) == "Internal Server Error"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
defmodule CfPhxWeb.LayoutViewTest do
|
||||
use CfPhxWeb.ConnCase, async: true
|
||||
defmodule CfHttpWeb.LayoutViewTest do
|
||||
use CfHttpWeb.ConnCase, async: true
|
||||
|
||||
# When testing helpers, you may want to import Phoenix.HTML and
|
||||
# use functions such as safe_to_string() to convert the helper
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
defmodule CfPhxWeb.PageViewTest do
|
||||
use CfPhxWeb.ConnCase, async: true
|
||||
defmodule CfHttpWeb.PageViewTest do
|
||||
use CfHttpWeb.ConnCase, async: true
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhxWeb.ChannelCase do
|
||||
defmodule CfHttpWeb.ChannelCase do
|
||||
@moduledoc """
|
||||
This module defines the test case to be used by
|
||||
channel tests.
|
||||
@@ -11,7 +11,7 @@ defmodule CfPhxWeb.ChannelCase do
|
||||
we enable the SQL sandbox, so changes done to the database
|
||||
are reverted at the end of every test. If you are using
|
||||
PostgreSQL, you can even run database tests asynchronously
|
||||
by setting `use CfPhxWeb.ChannelCase, async: true`, although
|
||||
by setting `use CfHttpWeb.ChannelCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
@@ -23,15 +23,15 @@ defmodule CfPhxWeb.ChannelCase do
|
||||
use Phoenix.ChannelTest
|
||||
|
||||
# The default endpoint for testing
|
||||
@endpoint CfPhxWeb.Endpoint
|
||||
@endpoint CfHttpWeb.Endpoint
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(CfPhx.Repo)
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(CfHttp.Repo)
|
||||
|
||||
unless tags[:async] do
|
||||
Ecto.Adapters.SQL.Sandbox.mode(CfPhx.Repo, {:shared, self()})
|
||||
Ecto.Adapters.SQL.Sandbox.mode(CfHttp.Repo, {:shared, self()})
|
||||
end
|
||||
|
||||
:ok
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhxWeb.ConnCase do
|
||||
defmodule CfHttpWeb.ConnCase do
|
||||
@moduledoc """
|
||||
This module defines the test case to be used by
|
||||
tests that require setting up a connection.
|
||||
@@ -11,7 +11,7 @@ defmodule CfPhxWeb.ConnCase do
|
||||
we enable the SQL sandbox, so changes done to the database
|
||||
are reverted at the end of every test. If you are using
|
||||
PostgreSQL, you can even run database tests asynchronously
|
||||
by setting `use CfPhxWeb.ConnCase, async: true`, although
|
||||
by setting `use CfHttpWeb.ConnCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
@@ -22,18 +22,18 @@ defmodule CfPhxWeb.ConnCase do
|
||||
# Import conveniences for testing with connections
|
||||
import Plug.Conn
|
||||
import Phoenix.ConnTest
|
||||
alias CfPhxWeb.Router.Helpers, as: Routes
|
||||
alias CfHttpWeb.Router.Helpers, as: Routes
|
||||
|
||||
# The default endpoint for testing
|
||||
@endpoint CfPhxWeb.Endpoint
|
||||
@endpoint CfHttpWeb.Endpoint
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(CfPhx.Repo)
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(CfHttp.Repo)
|
||||
|
||||
unless tags[:async] do
|
||||
Ecto.Adapters.SQL.Sandbox.mode(CfPhx.Repo, {:shared, self()})
|
||||
Ecto.Adapters.SQL.Sandbox.mode(CfHttp.Repo, {:shared, self()})
|
||||
end
|
||||
|
||||
{:ok, conn: Phoenix.ConnTest.build_conn()}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule CfPhx.DataCase do
|
||||
defmodule CfHttp.DataCase do
|
||||
@moduledoc """
|
||||
This module defines the setup for tests requiring
|
||||
access to the application's data layer.
|
||||
@@ -10,7 +10,7 @@ defmodule CfPhx.DataCase do
|
||||
we enable the SQL sandbox, so changes done to the database
|
||||
are reverted at the end of every test. If you are using
|
||||
PostgreSQL, you can even run database tests asynchronously
|
||||
by setting `use CfPhx.DataCase, async: true`, although
|
||||
by setting `use CfHttp.DataCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
@@ -18,20 +18,20 @@ defmodule CfPhx.DataCase do
|
||||
|
||||
using do
|
||||
quote do
|
||||
alias CfPhx.Repo
|
||||
alias CfHttp.Repo
|
||||
|
||||
import Ecto
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
import CfPhx.DataCase
|
||||
import CfHttp.DataCase
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(CfPhx.Repo)
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(CfHttp.Repo)
|
||||
|
||||
unless tags[:async] do
|
||||
Ecto.Adapters.SQL.Sandbox.mode(CfPhx.Repo, {:shared, self()})
|
||||
Ecto.Adapters.SQL.Sandbox.mode(CfHttp.Repo, {:shared, self()})
|
||||
end
|
||||
|
||||
:ok
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
ExUnit.start()
|
||||
Ecto.Adapters.SQL.Sandbox.mode(CfPhx.Repo, :manual)
|
||||
Ecto.Adapters.SQL.Sandbox.mode(CfHttp.Repo, :manual)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# migrate DB
|
||||
cf_phx/bin/cf_phx eval "CfPhx.Release.migrate"
|
||||
cf_http/bin/cf_http eval "CfHttp.Release.migrate"
|
||||
|
||||
# start app
|
||||
cf_phx/bin/cf_phx start
|
||||
cf_http/bin/cf_http start
|
||||
|
||||
@@ -19,15 +19,15 @@ import Config
|
||||
# Use Jason for JSON parsing in Phoenix
|
||||
config :phoenix, :json_library, Jason
|
||||
|
||||
config :cf_phx,
|
||||
ecto_repos: [CfPhx.Repo]
|
||||
config :cf_http,
|
||||
ecto_repos: [CfHttp.Repo]
|
||||
|
||||
# Configures the endpoint
|
||||
config :cf_phx, CfPhxWeb.Endpoint,
|
||||
config :cf_http, CfHttpWeb.Endpoint,
|
||||
url: [host: "localhost"],
|
||||
secret_key_base: "5OVYJ83AcoQcPmdKNksuBhJFBhjHD1uUa9mDOHV/6EIdBQ6pXksIhkVeWIzFk5SD",
|
||||
render_errors: [view: CfPhxWeb.ErrorView, accepts: ~w(html json)],
|
||||
pubsub_server: [name: CfPhx.PubSub]
|
||||
render_errors: [view: CfHttpWeb.ErrorView, accepts: ~w(html json)],
|
||||
pubsub_server: [name: CfHttp.PubSub]
|
||||
|
||||
# Configures Elixir's Logger
|
||||
config :logger, :console,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Config
|
||||
|
||||
# Configure your database
|
||||
config :cf_phx, CfPhx.Repo,
|
||||
config :cf_http, CfHttp.Repo,
|
||||
username: "cloudfire",
|
||||
password: "postgres",
|
||||
database: "cloudfire_dev",
|
||||
@@ -15,7 +15,7 @@ config :cf_phx, CfPhx.Repo,
|
||||
# The watchers configuration can be used to run external
|
||||
# watchers to your application. For example, we use it
|
||||
# with webpack to recompile .js and .css sources.
|
||||
config :cf_phx, CfPhxWeb.Endpoint,
|
||||
config :cf_http, CfHttpWeb.Endpoint,
|
||||
http: [port: 4000],
|
||||
debug_errors: true,
|
||||
code_reloader: true,
|
||||
@@ -55,13 +55,13 @@ config :cf_phx, CfPhxWeb.Endpoint,
|
||||
# different ports.
|
||||
|
||||
# Watch static and templates for browser reloading.
|
||||
config :cf_phx, CfPhxWeb.Endpoint,
|
||||
config :cf_http, CfHttpWeb.Endpoint,
|
||||
live_reload: [
|
||||
patterns: [
|
||||
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
|
||||
~r"priv/gettext/.*(po)$",
|
||||
~r"lib/cf_phx_web/(live|views)/.*(ex)$",
|
||||
~r"lib/cf_phx_web/templates/.*(eex)$"
|
||||
~r"lib/cf_http_web/(live|views)/.*(ex)$",
|
||||
~r"lib/cf_http_web/templates/.*(eex)$"
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import Config
|
||||
# manifest is generated by the `mix phx.digest` task,
|
||||
# which you should run after static files are built and
|
||||
# before starting your production server.
|
||||
config :cf_phx, CfPhxWeb.Endpoint,
|
||||
config :cf_http, CfHttpWeb.Endpoint,
|
||||
url: [host: "example.com", port: 80],
|
||||
cache_static_manifest: "priv/static/cache_manifest.json"
|
||||
|
||||
@@ -21,7 +21,7 @@ config :logger, level: :info
|
||||
# To get SSL working, you will need to add the `https` key
|
||||
# to the previous section and set your `:url` port to 443:
|
||||
#
|
||||
# config :cf_phx, CfPhxWeb.Endpoint,
|
||||
# config :cf_http, CfHttpWeb.Endpoint,
|
||||
# ...
|
||||
# url: [host: "example.com", port: 443],
|
||||
# https: [
|
||||
@@ -45,7 +45,7 @@ config :logger, level: :info
|
||||
# We also recommend setting `force_ssl` in your endpoint, ensuring
|
||||
# no data is ever sent via http, always redirecting to https:
|
||||
#
|
||||
# config :cf_phx, CfPhxWeb.Endpoint,
|
||||
# config :cf_http, CfHttpWeb.Endpoint,
|
||||
# force_ssl: [hsts: true]
|
||||
#
|
||||
# Check `Plug.SSL` for all available options in `force_ssl`.
|
||||
|
||||
@@ -18,12 +18,12 @@ secret_key_base =
|
||||
You can generate one by calling: mix phx.gen.secret
|
||||
"""
|
||||
|
||||
config :cf_phx, CfPhx.Repo,
|
||||
config :cf_http, CfHttp.Repo,
|
||||
# ssl: true,
|
||||
url: database_url,
|
||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
|
||||
|
||||
config :cf_phx, CfPhxWeb.Endpoint,
|
||||
config :cf_http, CfHttpWeb.Endpoint,
|
||||
http: [
|
||||
port: String.to_integer(System.get_env("PORT") || "4000"),
|
||||
transport_options: [socket_opts: [:inet6]]
|
||||
@@ -35,7 +35,7 @@ config :cf_phx, CfPhxWeb.Endpoint,
|
||||
# If you are doing OTP releases, you need to instruct Phoenix
|
||||
# to start each relevant endpoint:
|
||||
#
|
||||
config :cf_phx, CfPhxWeb.Endpoint, server: true
|
||||
config :cf_http, CfHttpWeb.Endpoint, server: true
|
||||
#
|
||||
# Then you can assemble a release by calling `mix release`.
|
||||
# See `mix help release` for more information.
|
||||
|
||||
@@ -20,11 +20,11 @@ end
|
||||
|
||||
# Configure your database
|
||||
db_url = System.get_env("DATABASE_URL")
|
||||
config :cf_phx, CfPhx.Repo, DBConfig.config(db_url)
|
||||
config :cf_http, CfHttp.Repo, DBConfig.config(db_url)
|
||||
|
||||
# We don't run a server during test. If one is required,
|
||||
# you can enable the server option below.
|
||||
config :cf_phx, CfPhxWeb.Endpoint,
|
||||
config :cf_http, CfHttpWeb.Endpoint,
|
||||
http: [port: 4002],
|
||||
server: false
|
||||
|
||||
|
||||
4
mix.exs
4
mix.exs
@@ -8,8 +8,8 @@ defmodule CloudfireUmbrella.MixProject do
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
releases: [
|
||||
cf_phx: [
|
||||
applications: [cf_phx: :permanent],
|
||||
cf_http: [
|
||||
applications: [cf_http: :permanent],
|
||||
include_executables_for: [:unix],
|
||||
cookie: System.get_env("ERL_COOKIE")
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user