rename environment variable
This commit is contained in:
parent
926ff822ec
commit
30548eae80
@ -2,11 +2,11 @@ defmodule BasicSignupWhitelist do
|
||||
import FunCore.BasicSignupWhitelist
|
||||
|
||||
@moduledoc """
|
||||
Checks if an email address is allowed based on the SIGNUP_ALLOWED_EMAILS env variable.
|
||||
Checks if an email address is allowed based on the SIGNUP_ALLOWLIST_EMAILS env variable.
|
||||
"""
|
||||
|
||||
@doc """
|
||||
Checks if an email address is allowed based on the SIGNUP_ALLOWED_EMAILS env variable.
|
||||
Checks if an email address is allowed based on the SIGNUP_ALLOWLIST_EMAILS env variable.
|
||||
|
||||
Rules:
|
||||
- Returns true if ALLOWED_EMAILS == "*" (all emails allowed)
|
||||
@ -18,16 +18,16 @@ defmodule BasicSignupWhitelist do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> System.delete_env("SIGNUP_ALLOWED_EMAILS")
|
||||
iex> System.delete_env("SIGNUP_ALLOWLIST_EMAILS")
|
||||
iex> BasicSignupWhitelist.mail_whitelisted("joe@example.com")
|
||||
false
|
||||
iex> System.put_env("SIGNUP_ALLOWED_EMAILS","*")
|
||||
iex> System.put_env("SIGNUP_ALLOWLIST_EMAILS","*")
|
||||
iex> BasicSignupWhitelist.mail_whitelisted("joe@example.com")
|
||||
true
|
||||
|
||||
"""
|
||||
def mail_whitelisted(email) do
|
||||
env_value = System.get_env("SIGNUP_ALLOWED_EMAILS")
|
||||
env_value = System.get_env("SIGNUP_ALLOWLIST_EMAILS")
|
||||
mail_whitelisted_fun(env_value, email)
|
||||
end
|
||||
end
|
||||
|
||||
@ -3,21 +3,21 @@ defmodule BasicSignupWhitelistTest do
|
||||
doctest BasicSignupWhitelist
|
||||
|
||||
defp allow_signups_for(whitelist) do
|
||||
System.put_env("SIGNUP_ALLOWED_EMAILS", whitelist)
|
||||
System.put_env("SIGNUP_ALLOWLIST_EMAILS", whitelist)
|
||||
end
|
||||
|
||||
describe "setup in describe block" do
|
||||
setup do
|
||||
on_exit(fn ->
|
||||
# resetting values did not work, so 'just' set it to the effect without this module configured.
|
||||
System.put_env("SIGNUP_ALLOWED_EMAILS", "*")
|
||||
System.put_env("SIGNUP_ALLOWLIST_EMAILS", "*")
|
||||
end)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
test "When not set, not whitelisted" do
|
||||
System.delete_env("SIGNUP_ALLOWED_EMAILS")
|
||||
System.delete_env("SIGNUP_ALLOWLIST_EMAILS")
|
||||
refute BasicSignupWhitelist.mail_whitelisted("joe@example.com")
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user