From 90332d01f2c13c1b8aa612e09e25596b3eeb96d9 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Wed, 4 Sep 2024 22:40:19 -0400 Subject: [PATCH] fix: use consistent naming for configurations closes #1436 --- config/config.exs | 2 +- lib/ash/policy/authorizer/authorizer.ex | 2 +- lib/ash/policy/filter_check.ex | 2 +- test/policy/complex_test.exs | 10 ++++++++-- test/policy/simple_test.exs | 10 ++++++++-- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/config/config.exs b/config/config.exs index 7a55cc52..dbdfcc7b 100644 --- a/config/config.exs +++ b/config/config.exs @@ -29,7 +29,7 @@ if Mix.env() == :test do Ash.Test.Support.PolicySimple.Domain ] - config :ash, :policy, no_filter_static_forbidden_reads?: false + config :ash, :policies, no_filter_static_forbidden_reads?: false config :ash, :custom_expressions, [Ash.Test.Expressions.JaroDistance] diff --git a/lib/ash/policy/authorizer/authorizer.ex b/lib/ash/policy/authorizer/authorizer.ex index 7fda6404..93310d17 100644 --- a/lib/ash/policy/authorizer/authorizer.ex +++ b/lib/ash/policy/authorizer/authorizer.ex @@ -1559,7 +1559,7 @@ defmodule Ash.Policy.Authorizer do defp forbidden_due_to_strict_policy?(authorizer) do no_filter_static_forbidden_reads? = Keyword.get( - Application.get_env(:ash, :policy, []), + Application.get_env(:ash, :policies, []), :no_filter_static_forbidden_reads?, true ) diff --git a/lib/ash/policy/filter_check.ex b/lib/ash/policy/filter_check.ex index f5c8709e..fa7de22d 100644 --- a/lib/ash/policy/filter_check.ex +++ b/lib/ash/policy/filter_check.ex @@ -85,7 +85,7 @@ defmodule Ash.Policy.FilterCheck do |> then(fn expr -> no_filter_static_forbidden_reads? = Keyword.get( - Application.get_env(:ash, :policy, []), + Application.get_env(:ash, :policies, []), :no_filter_static_forbidden_reads?, true ) diff --git a/test/policy/complex_test.exs b/test/policy/complex_test.exs index 7879c6a3..6dbb2061 100644 --- a/test/policy/complex_test.exs +++ b/test/policy/complex_test.exs @@ -6,10 +6,16 @@ defmodule Ash.Test.Policy.ComplexTest do alias Ash.Test.Support.PolicyComplex.{Bio, Comment, Post, User} setup do - Application.put_env(:ash, :policies, show_policy_breakdowns?: true) + old_env = Application.get_env(:ash, :policies, []) + + Application.put_env( + :ash, + :policies, + Keyword.merge(old_env, show_policy_breakdowns?: true) + ) on_exit(fn -> - Application.delete_env(:ash, :policies) + Application.put_env(:ash, :policies, old_env) end) me = User.create!("me", %{email: "me@app.com", bio_text: "this is my bio"}, authorize?: false) diff --git a/test/policy/simple_test.exs b/test/policy/simple_test.exs index 94e1e587..8508d9ad 100644 --- a/test/policy/simple_test.exs +++ b/test/policy/simple_test.exs @@ -75,10 +75,16 @@ defmodule Ash.Test.Policy.SimpleTest do end setup do - Application.put_env(:ash, :policies, show_policy_breakdowns?: true) + old_env = Application.get_env(:ash, :policies, []) + + Application.put_env( + :ash, + :policies, + Keyword.merge(old_env, show_policy_breakdowns?: true) + ) on_exit(fn -> - Application.delete_env(:ash, :policies) + Application.put_env(:ash, :policies, old_env) end) [