Commit 5e7dfe66 authored by Alex Castaño's avatar Alex Castaño

Registration works and first HTML work

parent 9f3b1fa6
erlang 21.1
elixir 1.7.3-otp-21
nodejs 10.13.0
......@@ -4063,12 +4063,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
......@@ -4083,17 +4085,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
......@@ -4210,7 +4215,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
......@@ -4222,6 +4228,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
......@@ -4236,6 +4243,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
......@@ -4243,12 +4251,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.2.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
......@@ -4267,6 +4277,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
......@@ -4347,7 +4358,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
......@@ -4359,6 +4371,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
......@@ -4480,6 +4493,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
......
......@@ -55,10 +55,10 @@ config :moodle_net, MoodleNetWeb.Endpoint,
patterns: [
~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
~r{priv/gettext/.*(po)$},
~r{lib/moodle_net_web/views/.*(ex)$},
~r{lib/moodle_net_web/templates/.*(eex)$},
~r{lib/activity_pub_web/views/.*(ex)$},
~r{lib/activity_pub_web/templates/.*(eex)$}
~r{lib/moodle_net_web/.*_view.*(ex)$},
~r{lib/moodle_net_web/.*/templates/.*(eex)$},
~r{lib/activity_pub_web/.*_view.*(ex)$},
~r{lib/activity_pub_web/.*/templates/.*(eex)$}
]
]
......
......@@ -25,11 +25,5 @@ config :pbkdf2_elixir, rounds: 1
config :moodle_net, :httpoison, HTTPoisonMock
try do
import_config "test.secret.exs"
rescue
_ ->
IO.puts(
"You may want to create test.secret.exs to declare custom database connection parameters."
)
end
config :phoenix_integration,
endpoint: MoodleNetWeb.Endpoint
......@@ -31,7 +31,9 @@ defmodule MoodleNetWeb do
def view do
quote do
use Phoenix.View,
root: "lib/moodle_net_web/templates",
root: "lib/moodle_net_web/",
path: Phoenix.Template.module_to_template_root(__MODULE__, MoodleNetWeb, "View") <> "/templates/",
pattern: "*",
namespace: MoodleNetWeb
# Import convenience functions from controllers
......
<div class="row justify-content-md-center">
<div class="col col-md-6">
<h2>Register</h2>
<%= form_for @conn, user_path(@conn, :create), [as: :user], fn f -> %>
<div class="form-group">
<label for="user_email">Email address</label>
<%= text_input f, :email, class: "form-control" %>
</div>
<div class="form-group">
<label for="user_preferred_username">Username</label>
<%= text_input f, :preferred_username, class: "form-control" %>
</div>
<div class="form-group">
<label for="user_password">Password</label>
<%= password_input f, :password, class: "form-control" %>
<small class="form-text text-muted">Minimum 6 characters</small>
</div>
<%= submit "Register", class: "btn btn-primary"%>
<% end %>
</div>
</div>
......@@ -3,14 +3,28 @@ defmodule MoodleNetWeb.Accounts.UserController do
alias MoodleNet.{Accounts, OAuth}
plug(:accepts, ["html"] when action in [:new])
def new(conn, params) do
render(conn, "new.html")
end
plug(ScrubParams, "user" when action == :create)
def create(conn, params) do
with {:ok, %{actor: actor, user: user}} <- Accounts.register_user(params["user"]),
{:ok, token} <- OAuth.create_token(user.id) do
conn
|> put_status(:created)
|> render(:registration, token: token, actor: actor, user: user)
case get_format(conn) do
"json" ->
conn
|> put_status(:created)
|> render(:registration, token: token, actor: actor, user: user)
"html" ->
conn
|> put_status(:created)
|> text("OK")
end
end
end
end
......@@ -11,7 +11,8 @@ defmodule MoodleNetWeb.Accounts.UserView do
def render("user.json", %{user: user}) do
%{
id: user.id
id: user.id,
email: user.email
}
end
end
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="/">MoodleNet</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
......@@ -9,6 +9,7 @@
<link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/>
</head>
<body>
<%= render "topbar.html", assigns %>
<div class="container">
<%= render @view_module, @view_template, assigns %>
</div>
......
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
......@@ -9,8 +9,8 @@ defmodule MoodleNetWeb.Router do
plug :put_secure_browser_headers
end
pipeline :api do
plug(:accepts, ["json"])
pipeline :api_html do
plug(:accepts, ["json", "html"])
plug(:fetch_session)
plug(MoodleNet.Plugs.OAuthPlug)
end
......@@ -24,13 +24,13 @@ defmodule MoodleNetWeb.Router do
end
scope "/api/v1" do
pipe_through(:api)
resources("/users", MoodleNetWeb.Accounts.UserController, only: [:create])
pipe_through(:api_html)
resources("/users", MoodleNetWeb.Accounts.UserController, only: [:new, :create])
resources("/sessions", MoodleNetWeb.Accounts.SessionController, only: [:create])
end
scope "/api/v1" do
pipe_through([:api, :ensure_authenticated])
pipe_through([:api_html, :ensure_authenticated])
resources("/sessions", MoodleNetWeb.Accounts.SessionController,
only: [:delete],
......@@ -39,7 +39,7 @@ defmodule MoodleNetWeb.Router do
end
scope "/oauth", MoodleNetWeb.OAuth do
pipe_through(:api)
pipe_through(:api_html)
get("/authorize", OAuthController, :authorize)
post("/authorize", OAuthController, :create_authorization)
post("/token", OAuthController, :token_exchange)
......
......@@ -30,7 +30,7 @@ defmodule MoodleNet.Mixfile do
# Type `mix help deps` for examples and options.
defp deps do
[
{:phoenix, "~> 1.4.0-rc"},
{:phoenix, "~> 1.4.0"},
{:phoenix_pubsub, "~> 1.1"},
{:phoenix_html, "~> 2.11"},
{:phoenix_ecto, "~> 4.0"},
......@@ -56,6 +56,7 @@ defmodule MoodleNet.Mixfile do
{:faker, "~> 0.11", only: [:dev, :test]},
# {:ex_machina, "~> 2.2", only: :test},
{:ex_machina, git: "https://github.com/thoughtbot/ex_machina", ref: "master", only: :test},
{:phoenix_integration, git: "https://github.com/alexcastano/phoenix_integration", only: :test},
{:credo, "~> 0.9.3", only: [:dev, :test]},
{:mock, "~> 0.3.1", only: :test},
{:ex_doc, "~> 0.19", only: :dev, runtime: false},
......
......@@ -12,7 +12,7 @@
"db_connection": {:hex, :db_connection, "2.0.1", "09454c6c6e8e4295f400b72580b19f0ac68fda2602e209533285206cb99bee6b", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"},
"decimal": {:hex, :decimal, "1.5.0", "b0433a36d0e2430e3d50291b1c65f53c37d56f83665b43d79963684865beab68", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.2.6", "b6da42b3831458d3ecc57314dff3051b080b9b2be88c2e5aa41cd642a5b044ed", [:mix], [], "hexpm"},
"ecto": {:hex, :ecto, "3.0.0", "059250d96f17f9c10f524fcb09d058f566691343e90318a161cf62a48f3912a9", [:mix], [{:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"},
"ecto": {:hex, :ecto, "3.0.1", "a26605ee7b243a754e6609d1c23da27bcb22823659b07bf03f9020da92a8e4f4", [:mix], [{:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"},
"ecto_sql": {:hex, :ecto_sql, "3.0.0", "8d1883376bee02a0e76b5ef797e39d04333c34b9935d0b4785dbf3cbdb571e2a", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.0.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.9.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.14.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.2.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"},
"eternal": {:hex, :eternal, "1.2.1", "d5b6b2499ba876c57be2581b5b999ee9bdf861c647401066d3eeed111d096bc4", [:mix], [], "hexpm"},
"ex_aws": {:hex, :ex_aws, "2.1.0", "b92651527d6c09c479f9013caa9c7331f19cba38a650590d82ebf2c6c16a1d8a", [:mix], [{:configparser_ex, "~> 2.0", [hex: :configparser_ex, repo: "hexpm", optional: true]}, {:hackney, "1.6.3 or 1.6.5 or 1.7.1 or 1.8.6 or ~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:jsx, "~> 2.8", [hex: :jsx, repo: "hexpm", optional: true]}, {:poison, ">= 1.2.0", [hex: :poison, repo: "hexpm", optional: true]}, {:sweet_xml, "~> 0.6", [hex: :sweet_xml, repo: "hexpm", optional: true]}, {:xml_builder, "~> 0.1.0", [hex: :xml_builder, repo: "hexpm", optional: true]}], "hexpm"},
......@@ -21,8 +21,10 @@
"ex_machina": {:git, "https://github.com/thoughtbot/ex_machina", "4714e7b96e1458262c8f043c0376c1f71f70a4fe", [ref: "master"]},
"faker": {:hex, :faker, "0.11.1", "0dcf151bef21cb27e289ae7418fd15c6a278dad676d5996b75d1d309b155c205", [:mix], [], "hexpm"},
"file_system": {:hex, :file_system, "0.2.6", "fd4dc3af89b9ab1dc8ccbcc214a0e60c41f34be251d9307920748a14bf41f1d3", [:mix], [], "hexpm"},
"floki": {:hex, :floki, "0.20.4", "be42ac911fece24b4c72f3b5846774b6e61b83fe685c2fc9d62093277fb3bc86", [:mix], [{:html_entities, "~> 0.4.0", [hex: :html_entities, repo: "hexpm", optional: false]}, {:mochiweb, "~> 2.15", [hex: :mochiweb, repo: "hexpm", optional: false]}], "hexpm"},
"gettext": {:hex, :gettext, "0.16.0", "4a7e90408cef5f1bf57c5a39e2db8c372a906031cc9b1466e963101cb927dafc", [:mix], [], "hexpm"},
"hackney": {:hex, :hackney, "1.14.3", "b5f6f5dcc4f1fba340762738759209e21914516df6be440d85772542d4a5e412", [:rebar3], [{:certifi, "2.4.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"html_entities": {:hex, :html_entities, "0.4.0", "f2fee876858cf6aaa9db608820a3209e45a087c5177332799592142b50e89a6b", [:mix], [], "hexpm"},
"html_sanitize_ex": {:hex, :html_sanitize_ex, "1.3.0", "f005ad692b717691203f940c686208aa3d8ffd9dd4bb3699240096a51fa9564e", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, repo: "hexpm", optional: false]}], "hexpm"},
"httpoison": {:hex, :httpoison, "1.2.0", "2702ed3da5fd7a8130fc34b11965c8cfa21ade2f232c00b42d96d4967c39a3a3", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
......@@ -39,10 +41,11 @@
"nimble_parsec": {:hex, :nimble_parsec, "0.4.0", "ee261bb53214943679422be70f1658fff573c5d0b0a1ecd0f18738944f818efe", [:mix], [], "hexpm"},
"parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"},
"pbkdf2_elixir": {:hex, :pbkdf2_elixir, "0.12.3", "6706a148809a29c306062862c803406e88f048277f6e85b68faf73291e820b84", [:mix], [], "hexpm"},
"phoenix": {:hex, :phoenix, "1.4.0-rc.3", "fa3e0759ee0602247a5e2d63e3acad7d479be7846bb5d06e03d8da8941d02967", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm"},
"phoenix": {:hex, :phoenix, "1.4.0", "56fe9a809e0e735f3e3b9b31c1b749d4b436e466d8da627b8d82f90eaae714d2", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm"},
"phoenix_ecto": {:hex, :phoenix_ecto, "4.0.0", "c43117a136e7399ea04ecaac73f8f23ee0ffe3e07acfcb8062fe5f4c9f0f6531", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
"phoenix_html": {:hex, :phoenix_html, "2.12.0", "1fb3c2e48b4b66d75564d8d63df6d53655469216d6b553e7e14ced2b46f97622", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.2.0-rc.0", "e4876fe249fdfbcca372a2c8d512a7c67d893d7a4f1bb66597050aa4d5001a69", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4-rc", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm"},
"phoenix_integration": {:git, "https://github.com/alexcastano/phoenix_integration", "9a5222b2ac1489ebfd987f9e3d9d4201049a792c", []},
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.2.0", "3bb31a9fbd40ffe8652e60c8660dffd72dd231efcdf49b744fb75b9ef7db5dd2", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [:mix], [], "hexpm"},
"plug": {:hex, :plug, "1.7.1", "8516d565fb84a6a8b2ca722e74e2cd25ca0fc9d64f364ec9dbec09d33eb78ccd", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}], "hexpm"},
"plug_cowboy": {:hex, :plug_cowboy, "2.0.0", "ab0c92728f2ba43c544cce85f0f220d8d30fc0c90eaa1e6203683ab039655062", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
......
defmodule MoodleNetWeb.Accounts.UserControllerTest do
use MoodleNetWeb.ConnCase
alias MoodleNet.NewFactory, as: Factory
@tag format: :json
describe "new" do
test "does not accept json format", %{conn: conn} do
assert_raise Phoenix.NotAcceptableError, fn ->
get(conn, "api/v1/users/new")
end
end
end
describe "create" do
test "works" do
@tag format: :json
test "works", %{conn: conn} do
params = Factory.attributes(:user)
conn
|> post("/api/v1/users", %{"user" => params})
|> json_response(201)
assert ret =
conn
|> post("/api/v1/users", %{"user" => params})
|> json_response(201)
assert %{
"user" => user,
"token" => token
# "actor" => actor
} = ret
# assert actor["preferred_username"] == params["username"]
assert user["email"] == params["email"]
assert %{"token_type" => "Bearer", "access_token" => _} = token
end
@tag format: :json
test "returns errors", %{conn: conn} do
params = Factory.attributes(:user, password: "short")
assert ret =
conn
|> post("/api/v1/users", %{"user" => params})
|> json_response(422)
assert %{
"error_code" => "validation_errors",
"error_message" => "Validation errors",
"errors" => %{"password" => ["should be at least 6 character(s)"]}
} = ret
end
end
end
defmodule MoodleNetWeb.Accoutns.UserControllerIntegrationTest do
use MoodleNetWeb.IntegrationCase, async: true
@tag format: :html
test "works", %{conn: conn} do
conn
|> get("api/v1/users/new")
|> follow_form(%{
user: %{
email: "alex@moodle.net",
password: "password",
preferred_username: "alex"
}
})
|> assert_response(status: 201)
end
end
......@@ -21,6 +21,8 @@ defmodule MoodleNetWeb.ConnCase do
use Phoenix.ConnTest
import MoodleNetWeb.Router.Helpers
alias MoodleNet.NewFactory, as: Factory
# The default endpoint for testing
@endpoint MoodleNetWeb.Endpoint
end
......@@ -34,6 +36,19 @@ defmodule MoodleNetWeb.ConnCase do
Ecto.Adapters.SQL.Sandbox.mode(MoodleNet.Repo, {:shared, self()})
end
{:ok, conn: Phoenix.ConnTest.build_conn()}
conn = Phoenix.ConnTest.build_conn()
accept_header = case tags[:format] do
:json ->
"application/json"
:json_ld ->
"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""
_ ->
"text/html"
end
conn = Plug.Conn.put_req_header(conn, "accept", accept_header)
{:ok, conn: conn}
end
end
......@@ -147,9 +147,9 @@ defmodule MoodleNet.Factory do
end
def oauth_app_factory do
%MoodleNetWeb.OAuth.App{
%MoodleNet.OAuth.App{
client_name: "Some client",
redirect_uris: "https://example.com/callback",
redirect_uri: "https://example.com/callback",
scopes: "read",
website: "https://example.com",
client_id: "aaabbb==",
......
defmodule MoodleNetWeb.IntegrationCase do
use ExUnit.CaseTemplate
using do
quote do
use MoodleNetWeb.ConnCase
use PhoenixIntegration
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment