Skip to content

Commit

Permalink
Merge pull request #30 from jungsoft/support-absinthe-15
Browse files Browse the repository at this point in the history
Support absinthe 1.5
  • Loading branch information
gabrielpra1 authored Nov 30, 2020
2 parents f35c76d + 362ada0 commit 390b0de
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 51 deletions.
3 changes: 2 additions & 1 deletion lib/middlewares/field_authorization.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ defmodule Rajska.FieldAuthorization do
}

def call(resolution, [object: %Type.Object{fields: fields} = object, field: field]) do
field_private? = fields[field] |> Type.meta(:private) |> field_private?(resolution.source)
{private_config, _binding} = fields[field] |> Type.meta(:private) |> Code.eval_quoted()
field_private? = field_private?(private_config, resolution.source)
scope? = get_scope!(object)

default_rule = Rajska.apply_auth_mod(resolution.context, :default_rule)
Expand Down
48 changes: 34 additions & 14 deletions lib/schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,46 @@ defmodule Rajska.Schema do
Field.t(),
module()
) :: [Middleware.spec(), ...]
def add_query_authorization(
[{{QueryAuthorization, :call}, config} = query_authorization | middleware] = _middleware,
%Field{name: query_name},
authorization
) do
validate_query_auth_config!(config, authorization, query_name)

[query_authorization | middleware]
end
def add_query_authorization(middlewares, %Field{name: query_name}, authorization) do
middlewares
|> Enum.find(&find_middleware/1)
|> case do
{{QueryAuthorization, :call}, config} ->
validate_query_auth_config!(config, authorization, query_name)

{{Absinthe.Resolution, :call}, _config} ->
raise "No permission specified for query #{query_name}"
end

def add_query_authorization(_middleware, %Field{name: name}, _authorization) do
raise "No permission specified for query #{name}"
middlewares
end

def find_middleware({{QueryAuthorization, :call}, _config}), do: true
def find_middleware({{Absinthe.Resolution, :call}, _config}), do: true
def find_middleware({_middleware, _config}), do: false

@spec add_object_authorization([Middleware.spec(), ...]) :: [Middleware.spec(), ...]
def add_object_authorization([{{QueryAuthorization, :call}, _} = query_authorization | middleware]) do
[query_authorization, ObjectAuthorization] ++ middleware
def add_object_authorization(middlewares) do
middlewares
|> Enum.reduce([], fn
{{QueryAuthorization, :call}, _config} = query_authorization, new_middlewares ->
[ObjectAuthorization, query_authorization] ++ new_middlewares

{{Absinthe.Resolution, :call}, _config} = resolution, new_middlewares ->
add_object_authorization_if_not_yet_present(resolution, new_middlewares)

middleware, new_middlewares ->
[middleware | new_middlewares]
end)
|> Enum.reverse()
end

def add_object_authorization(middleware), do: [ObjectAuthorization | middleware]
defp add_object_authorization_if_not_yet_present(resolution, new_middlewares) do
case Enum.member?(new_middlewares, ObjectAuthorization) do
true -> [resolution | new_middlewares]
false -> [resolution, ObjectAuthorization] ++ new_middlewares
end
end

@spec add_field_authorization(
[Middleware.spec(), ...],
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ defmodule Rajska.MixProject do
defp deps do
[
{:ex_doc, "~> 0.19", only: :dev, runtime: false},
{:credo, "~> 1.1.0", only: [:dev, :test], runtime: false},
{:absinthe, "~> 1.4.0"},
{:credo, "~> 1.5.0", only: [:dev, :test], runtime: false},
{:absinthe, "~> 1.5.4"},
{:excoveralls, "~> 0.11", only: :test},
{:hammer, "~> 6.0", optional: true},
{:mock, "~> 0.3.0", only: :test},
Expand Down
31 changes: 17 additions & 14 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
%{
"absinthe": {:hex, :absinthe, "1.4.16", "0933e4d9f12652b12115d5709c0293a1bf78a22578032e9ad0dad4efee6b9eb1", [:mix], [{:dataloader, "~> 1.0.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "076b8bd9552f4966ba1242f412f6c439b731169a36a0ddaaffcd3893828f5bf6"},
"absinthe": {:hex, :absinthe, "1.5.4", "e84820f770149ada718e2bd58939322965089a5badd9a0bfe632e05b27248dd0", [:mix], [{:dataloader, "~> 1.0.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6df329a071865065edd13a5a1da9981dfe8dc22c5d6729218ca9023999e9a2ff"},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
"certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"},
"credo": {:hex, :credo, "1.1.5", "caec7a3cadd2e58609d7ee25b3931b129e739e070539ad1a0cd7efeeb47014f4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "d0bbd3222607ccaaac5c0340f7f525c627ae4d7aee6c8c8c108922620c5b6446"},
"certifi": {:hex, :certifi, "2.5.2", "b7cfeae9d2ed395695dd8201c57a2d019c0c43ecaf8b8bcb9320b40d6662f340", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "3b3b5f36493004ac3455966991eaf6e768ce9884693d9968055aeeeb1e575040"},
"credo": {:hex, :credo, "1.5.1", "4fe303cc828412b9d21eed4eab60914c401e71f117f40243266aafb66f30d036", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "0b219ca4dcc89e4e7bc6ae7e6539c313e738e192e10b85275fa1e82b5203ecd7"},
"earmark": {:hex, :earmark, "1.4.2", "3aa0bd23bc4c61cf2f1e5d752d1bb470560a6f8539974f767a38923bb20e1d7f", [:mix], [], "hexpm", "5e8806285d8a3a8999bd38e4a73c58d28534c856bc38c44818e5ba85bbda16fb"},
"ex_doc": {:hex, :ex_doc, "0.21.2", "caca5bc28ed7b3bdc0b662f8afe2bee1eedb5c3cf7b322feeeb7c6ebbde089d6", [:mix], [{:earmark, "~> 1.3.3 or ~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f1155337ae17ff7a1255217b4c1ceefcd1860b7ceb1a1874031e7a861b052e39"},
"excoveralls": {:hex, :excoveralls, "0.12.0", "50e17a1b116fdb7facc2fe127a94db246169f38d7627b391376a0bc418413ce1", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1f70c34b462719a519e9d8be0b5f81a49557d8227a2c729d252c3cf4fc84d9cd"},
"hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [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.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "e0100f8ef7d1124222c11ad362c857d3df7cb5f4204054f9f0f4a728666591fc"},
"earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"},
"ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
"excoveralls": {:hex, :excoveralls, "0.13.3", "edc5f69218f84c2bf61b3609a22ddf1cec0fbf7d1ba79e59f4c16d42ea4347ed", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cc26f48d2f68666380b83d8aafda0fffc65dafcc8d8650358e0b61f6a99b1154"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"hackney": {:hex, :hackney, "1.16.0", "5096ac8e823e3a441477b2d187e30dd3fff1a82991a806b2003845ce72ce2d84", [:rebar3], [{:certifi, "2.5.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.1", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.0", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.6", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "3bf0bebbd5d3092a3543b783bf065165fa5d3ad4b899b836810e513064134e18"},
"hammer": {:hex, :hammer, "6.0.0", "72ec6fff10e9d63856968988a22ee04c4d6d5248071ddccfbda50aa6c455c1d7", [:mix], [{:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}], "hexpm", "d8e1ec2e534c4aae508b906759e077c3c1eb3e2b9425235d4b7bbab0b016210a"},
"idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fdf843bca858203ae1de16da2ee206f53416bbda5dc8c9e78f43243de4bc3afe"},
"makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "a10c6eb62cca416019663129699769f0c2ccf39428b3bb3c0cb38c718a0c186d"},
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"},
"idna": {:hex, :idna, "6.0.1", "1d038fb2e7668ce41fbf681d2c45902e52b3cb9e9c77b55334353b222c2ee50c", [:rebar3], [{:unicode_util_compat, "0.5.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a02c8a1c4fd601215bb0b0324c8a6986749f807ce35f25449ec9e69758708122"},
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.0", "98312c9f0d3730fde4049985a1105da5155bfe5c11e47bdc7406d88e01e4219b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "75ffa34ab1056b7e24844c90bfc62aaf6f3a37a15faa76b07bc5eba27e4a8b4a"},
"meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm", "d34f013c156db51ad57cc556891b9720e6a1c1df5fe2e15af999c84d6cebeb1a"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
"mock": {:hex, :mock, "0.3.4", "c5862eb3b8c64237f45f586cf00c9d892ba07bb48305a43319d428ce3c2897dd", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "e6d886252f1a41f4ba06ecf2b4c8d38760b34b1c08a11c28f7397b2e03995964"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm", "00e3ebdc821fb3a36957320d49e8f4bfa310d73ea31c90e5f925dc75e030da8f"},
"mock": {:hex, :mock, "0.3.6", "e810a91fabc7adf63ab5fdbec5d9d3b492413b8cda5131a2a8aa34b4185eb9b4", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "bcf1d0a6826fb5aee01bae3d74474669a3fa8b2df274d094af54a25266a1ebd2"},
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
"parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"},
"poolboy": {:hex, :poolboy, "1.5.2", "392b007a1693a64540cead79830443abf5762f5d30cf50bc95cb2c1aaafa006b", [:rebar3], [], "hexpm", "dad79704ce5440f3d5a3681c8590b9dc25d1a561e8f5a9c995281012860901e3"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm", "13104d7897e38ed7f044c4de953a6c28597d1c952075eb2e328bc6d6f2bfc496"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm", "1d1848c40487cdb0b30e8ed975e34e025860c02e419cb615d255849f3427439d"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
"telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.5.0", "8516502659002cec19e244ebd90d312183064be95025a319a6c7e89f4bccd65b", [:rebar3], [], "hexpm", "d48d002e15f5cc105a696cf2f1bbb3fc72b4b770a184d8420c8db20da2674b38"},
}
1 change: 1 addition & 0 deletions test/middlewares/field_authorization_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ defmodule Rajska.FieldAuthorizationTest do
{:ok, result} = Absinthe.run("{ getNotScoped { phone } }", __MODULE__.Schema, context(:user, 2))

assert %{data: %{"getNotScoped" => data}} = result
assert is_binary(data["phone"])
refute Map.has_key?(result, :errors)
end

Expand Down
6 changes: 3 additions & 3 deletions test/middlewares/object_authorization_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ defmodule Rajska.ObjectAuthorizationTest do
assert {:ok, %{errors: errors}} = Absinthe.run(all_query_with_user_object(), __MODULE__.Schema, context: %{current_user: nil})
assert [
%{
locations: [%{column: 0, line: 2}],
locations: [%{column: 3, line: 2}],
message: "Not authorized to access object company",
path: ["allQuery"]
}
Expand All @@ -146,7 +146,7 @@ defmodule Rajska.ObjectAuthorizationTest do
assert {:ok, %{errors: errors}} = Absinthe.run(user_query_with_admin_object(), __MODULE__.Schema, context: %{current_user: %{role: :user}})
assert [
%{
locations: [%{column: 0, line: 2}],
locations: [%{column: 3, line: 2}],
message: "Not authorized to access object wallet_balance",
path: ["userQuery"]
}
Expand Down Expand Up @@ -185,7 +185,7 @@ defmodule Rajska.ObjectAuthorizationTest do
assert {:ok, %{errors: errors}} = Absinthe.run(fragment_query_admin(), __MODULE__.Schema, context: %{current_user: %{role: :user}})
assert [
%{
locations: [%{column: 0, line: 13}],
locations: [%{column: 3, line: 13}],
message: "Not authorized to access object wallet_balance",
path: ["userQuery"]
}
Expand Down
20 changes: 10 additions & 10 deletions test/middlewares/object_scope_authorization_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ defmodule Rajska.ObjectScopeAuthorizationTest do
assert {:ok, %{errors: errors}} = run_pipeline(all_query(1), context(:user, 2))
assert [
%{
locations: [%{column: 0, line: 2}],
locations: [%{column: 3, line: 2}],
message: "Not authorized to access object user",
}
] == errors
Expand All @@ -220,7 +220,7 @@ defmodule Rajska.ObjectScopeAuthorizationTest do
assert {:ok, %{errors: errors}} = run_pipeline(all_query_with_company(1), context(:user, 2))
assert [
%{
locations: [%{column: 0, line: 2}],
locations: [%{column: 3, line: 2}],
message: "Not authorized to access object user",
}
] == errors
Expand All @@ -239,7 +239,7 @@ defmodule Rajska.ObjectScopeAuthorizationTest do
assert {:ok, %{errors: errors}} = run_pipeline(query, context(:user, 2))
assert [
%{
locations: [%{column: 0, line: 1}],
locations: [%{column: 3, line: 1}],
message: "Not authorized to access object object_scope_user",
}
] == errors
Expand All @@ -249,7 +249,7 @@ defmodule Rajska.ObjectScopeAuthorizationTest do
assert {:ok, %{errors: errors}} = run_pipeline(all_query_company_wallet(2), context(:user, 2))
assert [
%{
locations: [%{column: 0, line: 8}],
locations: [%{column: 7, line: 8}],
message: "Not authorized to access object wallet",
}
] == errors
Expand All @@ -261,7 +261,7 @@ defmodule Rajska.ObjectScopeAuthorizationTest do
assert {:ok, %{errors: errors}} = run_pipeline(all_query_company_wallet(2), context(:user, 1))
assert [
%{
locations: [%{column: 0, line: 2}],
locations: [%{column: 3, line: 2}],
message: "Not authorized to access object user",
}
] == errors
Expand All @@ -279,7 +279,7 @@ defmodule Rajska.ObjectScopeAuthorizationTest do
assert {:ok, %{errors: errors}} = run_pipeline(all_query_no_company(2), context(:user, 1))
assert [
%{
locations: [%{column: 0, line: 2}],
locations: [%{column: 3, line: 2}],
message: "Not authorized to access object user",
}
] == errors
Expand All @@ -299,7 +299,7 @@ defmodule Rajska.ObjectScopeAuthorizationTest do
assert {:ok, %{errors: errors}} = run_pipeline(all_query_companies_list(2), context(:user, 2))
assert [
%{
locations: [%{column: 0, line: 8}],
locations: [%{column: 7, line: 8}],
message: "Not authorized to access object wallet",
}
] == errors
Expand All @@ -311,7 +311,7 @@ defmodule Rajska.ObjectScopeAuthorizationTest do
assert {:ok, %{errors: errors}} = run_pipeline(all_query_companies_list(2), context(:user, 1))
assert [
%{
locations: [%{column: 0, line: 2}],
locations: [%{column: 3, line: 2}],
message: "Not authorized to access object user",
}
] == errors
Expand All @@ -321,7 +321,7 @@ defmodule Rajska.ObjectScopeAuthorizationTest do
assert {:ok, %{errors: errors}} = run_pipeline(users_query(), context(:user, 2))
assert [
%{
locations: [%{column: 0, line: 2}],
locations: [%{column: 3, line: 2}],
message: "Not authorized to access object user",
}
] == errors
Expand All @@ -335,7 +335,7 @@ defmodule Rajska.ObjectScopeAuthorizationTest do
assert {:ok, %{errors: errors}} = run_pipeline(user_query_with_rule(), context(:admin, 1))
assert [
%{
locations: [%{column: 0, line: 2}],
locations: [%{column: 3, line: 2}],
message: "Not authorized to access object user_rule",
}
] == errors
Expand Down
Loading

0 comments on commit 390b0de

Please sign in to comment.