Integrate whitelist in imperative shell
This commit is contained in:
parent
1c23e93d43
commit
5a7f651547
@ -1,4 +1,6 @@
|
|||||||
defmodule BasicSignupWhitelist do
|
defmodule BasicSignupWhitelist do
|
||||||
|
import FunCore.BasicSignupWhitelist
|
||||||
|
|
||||||
@moduledoc """
|
@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_ALLOWED_EMAILS env variable.
|
||||||
"""
|
"""
|
||||||
@ -20,7 +22,8 @@ defmodule BasicSignupWhitelist do
|
|||||||
false
|
false
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def mail_whitelisted(_email) do
|
def mail_whitelisted(email) do
|
||||||
false
|
env_value = System.get_env("SIGNUP_ALLOWED_EMAILS")
|
||||||
|
mail_whitelisted_fun(env_value, email)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -6,7 +6,23 @@ defmodule BasicSignupWhitelistTest do
|
|||||||
System.put_env("SIGNUP_ALLOWED_EMAILS", whitelist)
|
System.put_env("SIGNUP_ALLOWED_EMAILS", whitelist)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
setup do
|
||||||
|
# Save original env var
|
||||||
|
original_env = System.get_env("SIGNUP_ALLOWED_EMAILS")
|
||||||
|
|
||||||
|
on_exit(fn ->
|
||||||
|
# Restore original env var after each test
|
||||||
|
case original_env do
|
||||||
|
nil -> System.delete_env("SIGNUP_ALLOWED_EMAILS")
|
||||||
|
value -> System.put_env("SIGNUP_ALLOWED_EMAILS", value)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
|
||||||
test "When not set, not whitelisted" do
|
test "When not set, not whitelisted" do
|
||||||
|
System.delete_env("SIGNUP_ALLOWED_EMAILS")
|
||||||
refute BasicSignupWhitelist.mail_whitelisted("joe@example.com")
|
refute BasicSignupWhitelist.mail_whitelisted("joe@example.com")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user