more white to allow renaming
This commit is contained in:
parent
6eab34c61a
commit
12ce7d1d5d
@ -1,19 +0,0 @@
|
|||||||
defmodule FunCore.BasicSignupAllowlist do
|
|
||||||
def normalize(email) do
|
|
||||||
email |> String.trim() |> String.downcase()
|
|
||||||
end
|
|
||||||
|
|
||||||
def addresses_as_list(addresses_str) do
|
|
||||||
addresses_str
|
|
||||||
|> String.split(",")
|
|
||||||
|> Enum.map(&normalize/1)
|
|
||||||
end
|
|
||||||
|
|
||||||
def mail_allowlisted_fun(signups_allowed, email_received) do
|
|
||||||
case signups_allowed do
|
|
||||||
nil -> false
|
|
||||||
"*" -> true
|
|
||||||
list_str -> normalize(email_received) in addresses_as_list(list_str)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
110
plan.md
110
plan.md
@ -1,17 +1,17 @@
|
|||||||
# whitelist sketch
|
# allowlist sketch
|
||||||
|
|
||||||
Here's a complete Mix project structure with the email whitelist functionality and tests:
|
Here's a complete Mix project structure with the email allowlist functionality and tests:
|
||||||
|
|
||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
email_whitelist_test/
|
email_allowlist_test/
|
||||||
├── config
|
├── config
|
||||||
│ └── config.exs
|
│ └── config.exs
|
||||||
├── lib
|
├── lib
|
||||||
│ └── email_whitelist.ex
|
│ └── email_allowlist.ex
|
||||||
├── test
|
├── test
|
||||||
│ ├── email_whitelist_test.exs
|
│ ├── email_allowlist_test.exs
|
||||||
│ └── test_helper.exs
|
│ └── test_helper.exs
|
||||||
├── mix.exs
|
├── mix.exs
|
||||||
└── README.md
|
└── README.md
|
||||||
@ -25,7 +25,7 @@ defmodule EmailWhitelistTest.MixProject do
|
|||||||
|
|
||||||
def project do
|
def project do
|
||||||
[
|
[
|
||||||
app: :email_whitelist_test,
|
app: :email_allowlist_test,
|
||||||
version: "0.1.0",
|
version: "0.1.0",
|
||||||
elixir: "~> 1.14",
|
elixir: "~> 1.14",
|
||||||
start_permanent: Mix.env() == :prod,
|
start_permanent: Mix.env() == :prod,
|
||||||
@ -47,11 +47,11 @@ end
|
|||||||
import Config
|
import Config
|
||||||
|
|
||||||
# Configure your application
|
# Configure your application
|
||||||
config :email_whitelist_test, :allowed_emails,
|
config :email_allowlist_test, :allowed_emails,
|
||||||
["user@domain.com", "admin@example.org"]
|
["user@domain.com", "admin@example.org"]
|
||||||
```
|
```
|
||||||
|
|
||||||
## 3. `lib/email_whitelist.ex` - Main Implementation
|
## 3. `lib/email_allowlist.ex` - Main Implementation
|
||||||
|
|
||||||
```elixir
|
```elixir
|
||||||
defmodule EmailWhitelist do
|
defmodule EmailWhitelist do
|
||||||
@ -64,10 +64,10 @@ defmodule EmailWhitelist do
|
|||||||
- Returns false if:
|
- Returns false if:
|
||||||
* Environment variable doesn't exist
|
* Environment variable doesn't exist
|
||||||
* Environment variable is empty string
|
* Environment variable is empty string
|
||||||
* Email not found in whitelist
|
* Email not found in allowlist
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def mail_whitelisted(email) do
|
def mail_allowlisted(email) do
|
||||||
normalized_email = String.downcase(email)
|
normalized_email = String.downcase(email)
|
||||||
env_var = System.get_env("ALLOWED_EMAILS")
|
env_var = System.get_env("ALLOWED_EMAILS")
|
||||||
|
|
||||||
@ -94,13 +94,13 @@ end
|
|||||||
ExUnit.start()
|
ExUnit.start()
|
||||||
```
|
```
|
||||||
|
|
||||||
## 5. `test/email_whitelist_test.exs` - Test Cases
|
## 5. `test/email_allowlist_test.exs` - Test Cases
|
||||||
|
|
||||||
```elixir
|
```elixir
|
||||||
defmodule EmailWhitelistTest do
|
defmodule EmailWhitelistTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case, async: true
|
||||||
|
|
||||||
describe "mail_whitelisted/1" do
|
describe "mail_allowlisted/1" do
|
||||||
setup do
|
setup do
|
||||||
# Save original env var
|
# Save original env var
|
||||||
original_env = System.get_env("ALLOWED_EMAILS")
|
original_env = System.get_env("ALLOWED_EMAILS")
|
||||||
@ -119,59 +119,59 @@ defmodule EmailWhitelistTest do
|
|||||||
test "allows all emails when ALLOWED_EMAILS is '*'" do
|
test "allows all emails when ALLOWED_EMAILS is '*'" do
|
||||||
System.put_env("ALLOWED_EMAILS", "*")
|
System.put_env("ALLOWED_EMAILS", "*")
|
||||||
|
|
||||||
assert EmailWhitelist.mail_whitelisted("any@example.com") == true
|
assert EmailWhitelist.mail_allowlisted("any@example.com") == true
|
||||||
assert EmailWhitelist.mail_whitelisted("user@domain.com") == true
|
assert EmailWhitelist.mail_allowlisted("user@domain.com") == true
|
||||||
assert EmailWhitelist.mail_whitelisted("test@test.co.uk") == true
|
assert EmailWhitelist.mail_allowlisted("test@test.co.uk") == true
|
||||||
end
|
end
|
||||||
|
|
||||||
test "allows whitelisted emails" do
|
test "allows allowlisted emails" do
|
||||||
System.put_env("ALLOWED_EMAILS", "user@domain.com,admin@example.org")
|
System.put_env("ALLOWED_EMAILS", "user@domain.com,admin@example.org")
|
||||||
|
|
||||||
assert EmailWhitelist.mail_whitelisted("user@domain.com") == true
|
assert EmailWhitelist.mail_allowlisted("user@domain.com") == true
|
||||||
assert EmailWhitelist.mail_whitelisted("ADMIN@EXAMPLE.ORG") == true
|
assert EmailWhitelist.mail_allowlisted("ADMIN@EXAMPLE.ORG") == true
|
||||||
assert EmailWhitelist.mail_whitelisted("User@Domain.Com") == true
|
assert EmailWhitelist.mail_allowlisted("User@Domain.Com") == true
|
||||||
end
|
end
|
||||||
|
|
||||||
test "rejects non-whitelisted emails" do
|
test "rejects non-allowlisted emails" do
|
||||||
System.put_env("ALLOWED_EMAILS", "user@domain.com,admin@example.org")
|
System.put_env("ALLOWED_EMAILS", "user@domain.com,admin@example.org")
|
||||||
|
|
||||||
assert EmailWhitelist.mail_whitelisted("invalid@example.com") == false
|
assert EmailWhitelist.mail_allowlisted("invalid@example.com") == false
|
||||||
assert EmailWhitelist.mail_whitelisted("test@test.co.uk") == false
|
assert EmailWhitelist.mail_allowlisted("test@test.co.uk") == false
|
||||||
end
|
end
|
||||||
|
|
||||||
test "rejects when ALLOWED_EMAILS is nil" do
|
test "rejects when ALLOWED_EMAILS is nil" do
|
||||||
System.delete_env("ALLOWED_EMAILS")
|
System.delete_env("ALLOWED_EMAILS")
|
||||||
|
|
||||||
assert EmailWhitelist.mail_whitelisted("any@example.com") == false
|
assert EmailWhitelist.mail_allowlisted("any@example.com") == false
|
||||||
end
|
end
|
||||||
|
|
||||||
test "rejects when ALLOWED_EMAILS is empty string" do
|
test "rejects when ALLOWED_EMAILS is empty string" do
|
||||||
System.put_env("ALLOWED_EMAILS", "")
|
System.put_env("ALLOWED_EMAILS", "")
|
||||||
|
|
||||||
assert EmailWhitelist.mail_whitelisted("any@example.com") == false
|
assert EmailWhitelist.mail_allowlisted("any@example.com") == false
|
||||||
end
|
end
|
||||||
|
|
||||||
test "handles whitespace in email list" do
|
test "handles allowspace in email list" do
|
||||||
System.put_env("ALLOWED_EMAILS", " user@domain.com , admin@example.org , test@test.co.uk ")
|
System.put_env("ALLOWED_EMAILS", " user@domain.com , admin@example.org , test@test.co.uk ")
|
||||||
|
|
||||||
assert EmailWhitelist.mail_whitelisted("user@domain.com") == true
|
assert EmailWhitelist.mail_allowlisted("user@domain.com") == true
|
||||||
assert EmailWhitelist.mail_whitelisted("ADMIN@EXAMPLE.ORG") == true
|
assert EmailWhitelist.mail_allowlisted("ADMIN@EXAMPLE.ORG") == true
|
||||||
assert EmailWhitelist.mail_whitelisted("test@test.co.uk") == true
|
assert EmailWhitelist.mail_allowlisted("test@test.co.uk") == true
|
||||||
assert EmailWhitelist.mail_whitelisted("invalid@example.com") == false
|
assert EmailWhitelist.mail_allowlisted("invalid@example.com") == false
|
||||||
end
|
end
|
||||||
|
|
||||||
test "case insensitive matching works" do
|
test "case insensitive matching works" do
|
||||||
System.put_env("ALLOWED_EMAILS", "User@Domain.Com,ADMIN@EXAMPLE.ORG")
|
System.put_env("ALLOWED_EMAILS", "User@Domain.Com,ADMIN@EXAMPLE.ORG")
|
||||||
|
|
||||||
assert EmailWhitelist.mail_whitelisted("user@domain.com") == true
|
assert EmailWhitelist.mail_allowlisted("user@domain.com") == true
|
||||||
assert EmailWhitelist.mail_whitelisted("USER@DOMAIN.COM") == true
|
assert EmailWhitelist.mail_allowlisted("USER@DOMAIN.COM") == true
|
||||||
assert EmailWhitelist.mail_whitelisted("admin@example.org") == true
|
assert EmailWhitelist.mail_allowlisted("admin@example.org") == true
|
||||||
end
|
end
|
||||||
|
|
||||||
test "empty email returns false" do
|
test "empty email returns false" do
|
||||||
System.put_env("ALLOWED_EMAILS", "user@domain.com")
|
System.put_env("ALLOWED_EMAILS", "user@domain.com")
|
||||||
|
|
||||||
assert EmailWhitelist.mail_whitelisted("") == false
|
assert EmailWhitelist.mail_allowlisted("") == false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -182,24 +182,24 @@ end
|
|||||||
```markdown
|
```markdown
|
||||||
# EmailWhitelistTest
|
# EmailWhitelistTest
|
||||||
|
|
||||||
A simple Mix project demonstrating email whitelist functionality.
|
A simple Mix project demonstrating email allowlist functionality.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
|
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
|
||||||
by adding `email_whitelist_test` to your list of dependencies in `mix.exs`:
|
by adding `email_allowlist_test` to your list of dependencies in `mix.exs`:
|
||||||
|
|
||||||
```elixir
|
```elixir
|
||||||
def deps do
|
def deps do
|
||||||
[
|
[
|
||||||
{:email_whitelist_test, "~> 0.1.0"}
|
{:email_allowlist_test, "~> 0.1.0"}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
The main function is `EmailWhitelist.mail_whitelisted/1` which checks if an email address is allowed.
|
The main function is `EmailWhitelist.mail_allowlisted/1` which checks if an email address is allowed.
|
||||||
|
|
||||||
Environment variable configuration:
|
Environment variable configuration:
|
||||||
- `ALLOWED_EMAILS="*"` - Allow all emails
|
- `ALLOWED_EMAILS="*"` - Allow all emails
|
||||||
@ -221,8 +221,8 @@ MIT
|
|||||||
|
|
||||||
1. **Create the project structure:**
|
1. **Create the project structure:**
|
||||||
```bash
|
```bash
|
||||||
mkdir email_whitelist_test
|
mkdir email_allowlist_test
|
||||||
cd email_whitelist_test
|
cd email_allowlist_test
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Create all files with the content above**
|
2. **Create all files with the content above**
|
||||||
@ -251,7 +251,7 @@ Finished in 0.05 seconds (0.04s async, 0.01s sync)
|
|||||||
The tests cover all your specified requirements:
|
The tests cover all your specified requirements:
|
||||||
- ✅ All emails allowed when `ALLOWED_EMAILS="*"`
|
- ✅ All emails allowed when `ALLOWED_EMAILS="*"`
|
||||||
- ✅ Specific emails allowed when in list
|
- ✅ Specific emails allowed when in list
|
||||||
- ✅ Non-whitelisted emails rejected
|
- ✅ Non-allowlisted emails rejected
|
||||||
- ✅ Missing environment variable handled properly
|
- ✅ Missing environment variable handled properly
|
||||||
- ✅ Empty environment variable handled properly
|
- ✅ Empty environment variable handled properly
|
||||||
- ✅ Whitespace trimming in email lists
|
- ✅ Whitespace trimming in email lists
|
||||||
@ -272,7 +272,7 @@ You can easily switch from a local path dependency to a git dependency by simply
|
|||||||
```elixir
|
```elixir
|
||||||
def deps do
|
def deps do
|
||||||
[
|
[
|
||||||
{:email_whitelist_test, path: "../email_whitelist_test"}
|
{:email_allowlist_test, path: "../email_allowlist_test"}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
@ -281,7 +281,7 @@ end
|
|||||||
```elixir
|
```elixir
|
||||||
def deps do
|
def deps do
|
||||||
[
|
[
|
||||||
{:email_whitelist_test, git: "https://github.com/yourusername/email_whitelist_test.git"}
|
{:email_allowlist_test, git: "https://github.com/yourusername/email_allowlist_test.git"}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
@ -292,7 +292,7 @@ After changing the dependency specification:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Remove the old dependency
|
# Remove the old dependency
|
||||||
mix deps.clean email_whitelist_test
|
mix deps.clean email_allowlist_test
|
||||||
|
|
||||||
# Fetch the new git dependency
|
# Fetch the new git dependency
|
||||||
mix deps.get
|
mix deps.get
|
||||||
@ -302,21 +302,21 @@ mix deps.get
|
|||||||
|
|
||||||
### Specify a Branch or Tag:
|
### Specify a Branch or Tag:
|
||||||
```elixir
|
```elixir
|
||||||
{:email_whitelist_test,
|
{:email_allowlist_test,
|
||||||
git: "https://github.com/yourusername/email_whitelist_test.git",
|
git: "https://github.com/yourusername/email_allowlist_test.git",
|
||||||
branch: "main"}
|
branch: "main"}
|
||||||
|
|
||||||
# Or for a specific tag
|
# Or for a specific tag
|
||||||
{:email_whitelist_test,
|
{:email_allowlist_test,
|
||||||
git: "https://github.com/yourusername/email_whitelist_test.git",
|
git: "https://github.com/yourusername/email_allowlist_test.git",
|
||||||
tag: "v1.0.0"}
|
tag: "v1.0.0"}
|
||||||
```
|
```
|
||||||
|
|
||||||
### For Private Repositories:
|
### For Private Repositories:
|
||||||
```elixir
|
```elixir
|
||||||
{:email_whitelist_test,
|
{:email_allowlist_test,
|
||||||
git: "https://github.com/yourusername/email_whitelist_test.git",
|
git: "https://github.com/yourusername/email_allowlist_test.git",
|
||||||
github: "yourusername/email_whitelist_test",
|
github: "yourusername/email_allowlist_test",
|
||||||
branch: "main"}
|
branch: "main"}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ mix deps.get
|
|||||||
```elixir
|
```elixir
|
||||||
def deps do
|
def deps do
|
||||||
[
|
[
|
||||||
{:email_whitelist_test, path: "../email_whitelist_test"}
|
{:email_allowlist_test, path: "../email_allowlist_test"}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
@ -335,8 +335,8 @@ end
|
|||||||
```elixir
|
```elixir
|
||||||
def deps do
|
def deps do
|
||||||
[
|
[
|
||||||
{:email_whitelist_test,
|
{:email_allowlist_test,
|
||||||
git: "https://github.com/yourusername/email_whitelist_test.git",
|
git: "https://github.com/yourusername/email_allowlist_test.git",
|
||||||
branch: "main"}
|
branch: "main"}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
@ -352,7 +352,7 @@ end
|
|||||||
## Important Notes:
|
## Important Notes:
|
||||||
|
|
||||||
- **No code changes needed** - your existing imports and usage remain identical
|
- **No code changes needed** - your existing imports and usage remain identical
|
||||||
- **Same module names** - `EmailWhitelist.mail_whitelisted/1` works the same
|
- **Same module names** - `EmailWhitelist.mail_allowlisted/1` works the same
|
||||||
- **Same function signatures** - no API changes required
|
- **Same function signatures** - no API changes required
|
||||||
- **Cache cleared** - you'll need to run `mix deps.get` to fetch the new version
|
- **Cache cleared** - you'll need to run `mix deps.get` to fetch the new version
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ end
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Edit your mix.exs file, then:
|
# Edit your mix.exs file, then:
|
||||||
mix deps.clean email_whitelist_test
|
mix deps.clean email_allowlist_test
|
||||||
mix deps.get
|
mix deps.get
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
120
rename_module.sh
120
rename_module.sh
@ -2,45 +2,101 @@
|
|||||||
|
|
||||||
# Script to rename BasicSignupWhitelist module to BasicSignupAllowlist
|
# Script to rename BasicSignupWhitelist module to BasicSignupAllowlist
|
||||||
# This includes renaming files, module names, function names, and all references
|
# This includes renaming files, module names, function names, and all references
|
||||||
|
# Works recursively through all subdirectories
|
||||||
|
|
||||||
echo "Starting module rename from Whitelist to Allowlist..."
|
echo "Starting module rename from Whitelist to Allowlist..."
|
||||||
|
echo ""
|
||||||
|
|
||||||
# 1. Rename the files
|
# Counter for renamed files
|
||||||
echo "Renaming files..."
|
renamed_count=0
|
||||||
if [ -f "lib/basic_signup_whitelist.ex" ]; then
|
|
||||||
mv lib/basic_signup_whitelist.ex lib/basic_signup_allowlist.ex
|
|
||||||
echo " ✓ Renamed lib/basic_signup_whitelist.ex to lib/basic_signup_allowlist.ex"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "test/basic_signup_whitelist_test.exs" ]; then
|
# 1. Find and rename ALL files containing "whitelist" recursively
|
||||||
mv test/basic_signup_whitelist_test.exs test/basic_signup_allowlist_test.exs
|
echo "Finding and renaming files recursively..."
|
||||||
echo " ✓ Renamed test/basic_signup_whitelist_test.exs to test/basic_signup_allowlist_test.exs"
|
echo "----------------------------------------"
|
||||||
fi
|
|
||||||
|
|
||||||
# 2. Replace all occurrences of BasicSignupWhitelist with BasicSignupAllowlist
|
# Use find to locate all files with whitelist in the name
|
||||||
echo "Updating module names..."
|
# Process deepest files first to avoid path issues
|
||||||
find . -type f \( -name "*.ex" -o -name "*.exs" \) -exec sed -i 's/BasicSignupWhitelist/BasicSignupAllowlist/g' {} +
|
while IFS= read -r -d '' file; do
|
||||||
echo " ✓ Updated module names from BasicSignupWhitelist to BasicSignupAllowlist"
|
dir=$(dirname "$file")
|
||||||
|
filename=$(basename "$file")
|
||||||
|
newname="${filename//whitelist/allowlist}"
|
||||||
|
newname="${newname//Whitelist/Allowlist}"
|
||||||
|
|
||||||
# 3. Replace function names (mail_whitelisted -> mail_allowlisted)
|
if [ "$filename" != "$newname" ]; then
|
||||||
echo "Updating function names..."
|
mv "$file" "$dir/$newname"
|
||||||
find . -type f \( -name "*.ex" -o -name "*.exs" \) -exec sed -i 's/mail_whitelisted/mail_allowlisted/g' {} +
|
echo " ✓ Renamed: $file → $dir/$newname"
|
||||||
echo " ✓ Updated function names from mail_whitelisted to mail_allowlisted"
|
((renamed_count++))
|
||||||
|
fi
|
||||||
|
done < <(find . -type f \( -name "*whitelist*" -o -name "*Whitelist*" \) \( -name "*.ex" -o -name "*.exs" \) -print0 | sort -zr)
|
||||||
|
|
||||||
# 4. Replace any remaining "whitelist" references in comments/docs with "allowlist"
|
if [ $renamed_count -eq 0 ]; then
|
||||||
echo "Updating remaining whitelist references..."
|
echo " No files needed renaming"
|
||||||
find . -type f \( -name "*.ex" -o -name "*.exs" \) -exec sed -i 's/whitelist/allowlist/g' {} +
|
|
||||||
echo " ✓ Updated all remaining references from whitelist to allowlist"
|
|
||||||
|
|
||||||
# 5. Update any references to the old filenames in mix.exs or other config files
|
|
||||||
echo "Checking for filename references in config files..."
|
|
||||||
if [ -f "mix.exs" ]; then
|
|
||||||
sed -i 's/basic_signup_whitelist/basic_signup_allowlist/g' mix.exs
|
|
||||||
echo " ✓ Updated references in mix.exs"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Module rename complete! You may want to:"
|
|
||||||
echo " 1. Run 'mix test' to ensure all tests still pass"
|
# 2. Replace all occurrences of BasicSignupWhitelist with BasicSignupAllowlist
|
||||||
echo " 2. Run 'mix compile --force' to recompile with the new module names"
|
echo "Updating module names in all .ex and .exs files..."
|
||||||
echo " 3. Check any documentation or README files for references to update"
|
echo "---------------------------------------------------"
|
||||||
|
find . -type f \( -name "*.ex" -o -name "*.exs" \) ! -path "./_build/*" ! -path "./deps/*" -exec sed -i 's/BasicSignupWhitelist/BasicSignupAllowlist/g' {} +
|
||||||
|
echo " ✓ Updated module names from BasicSignupWhitelist to BasicSignupAllowlist"
|
||||||
|
|
||||||
|
# 3. Replace function names (mail_whitelisted -> mail_allowlisted)
|
||||||
|
echo ""
|
||||||
|
echo "Updating function names..."
|
||||||
|
echo "--------------------------"
|
||||||
|
find . -type f \( -name "*.ex" -o -name "*.exs" \) ! -path "./_build/*" ! -path "./deps/*" -exec sed -i 's/mail_whitelisted/mail_allowlisted/g' {} +
|
||||||
|
echo " ✓ Updated function names from mail_whitelisted to mail_allowlisted"
|
||||||
|
|
||||||
|
# 4. Replace case-sensitive variations of whitelist/allowlist
|
||||||
|
echo ""
|
||||||
|
echo "Updating all whitelist references (case-sensitive)..."
|
||||||
|
echo "-----------------------------------------------------"
|
||||||
|
find . -type f \( -name "*.ex" -o -name "*.exs" \) ! -path "./_build/*" ! -path "./deps/*" -exec sed -i 's/whitelist/allowlist/g' {} +
|
||||||
|
find . -type f \( -name "*.ex" -o -name "*.exs" \) ! -path "./_build/*" ! -path "./deps/*" -exec sed -i 's/Whitelist/Allowlist/g' {} +
|
||||||
|
find . -type f \( -name "*.ex" -o -name "*.exs" \) ! -path "./_build/*" ! -path "./deps/*" -exec sed -i 's/WHITELIST/ALLOWLIST/g' {} +
|
||||||
|
echo " ✓ Updated all case variations of whitelist to allowlist"
|
||||||
|
|
||||||
|
# 5. Update references in config files (mix.exs, README.md, etc.)
|
||||||
|
echo ""
|
||||||
|
echo "Updating references in configuration and documentation files..."
|
||||||
|
echo "--------------------------------------------------------------"
|
||||||
|
for file in mix.exs README.md CLAUDE.md .formatter.exs; do
|
||||||
|
if [ -f "$file" ]; then
|
||||||
|
sed -i 's/whitelist/allowlist/g' "$file"
|
||||||
|
sed -i 's/Whitelist/Allowlist/g' "$file"
|
||||||
|
sed -i 's/WHITELIST/ALLOWLIST/g' "$file"
|
||||||
|
echo " ✓ Updated references in $file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# 6. Clean up old build artifacts
|
||||||
|
echo ""
|
||||||
|
echo "Cleaning up old build artifacts..."
|
||||||
|
echo "----------------------------------"
|
||||||
|
if [ -d "_build" ]; then
|
||||||
|
# Find and remove directories with whitelist in the name
|
||||||
|
find _build -type d -name "*whitelist*" -exec rm -rf {} + 2>/dev/null
|
||||||
|
echo " ✓ Removed old build directories containing 'whitelist'"
|
||||||
|
echo " Note: Run 'mix clean' and 'mix compile' to rebuild completely"
|
||||||
|
else
|
||||||
|
echo " No _build directory found"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 7. Show summary of changes
|
||||||
|
echo ""
|
||||||
|
echo "============================================"
|
||||||
|
echo "Module rename complete!"
|
||||||
|
echo "============================================"
|
||||||
|
echo ""
|
||||||
|
echo "Summary:"
|
||||||
|
echo " - Renamed $renamed_count file(s)"
|
||||||
|
echo " - Updated all module and function references"
|
||||||
|
echo " - Cleaned build artifacts"
|
||||||
|
echo ""
|
||||||
|
echo "Recommended next steps:"
|
||||||
|
echo " 1. Run 'mix clean' to clean all build artifacts"
|
||||||
|
echo " 2. Run 'mix deps.get' if you have dependencies"
|
||||||
|
echo " 3. Run 'mix compile --force' to recompile with new module names"
|
||||||
|
echo " 4. Run 'mix test' to ensure all tests still pass"
|
||||||
|
echo " 5. Commit these changes to version control"
|
||||||
@ -1,40 +0,0 @@
|
|||||||
defmodule FunCore.BasicSignupAllowlistTest do
|
|
||||||
use ExUnit.Case
|
|
||||||
import FunCore.BasicSignupAllowlist
|
|
||||||
|
|
||||||
test "addresses_as_list" do
|
|
||||||
assert addresses_as_list("joe@example.com, jane@example.com") == [
|
|
||||||
"joe@example.com",
|
|
||||||
"jane@example.com"
|
|
||||||
]
|
|
||||||
end
|
|
||||||
|
|
||||||
test "jane in list" do
|
|
||||||
lst = addresses_as_list("joe@example.com, jane@example.com")
|
|
||||||
assert "jane@example.com" in lst
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "Not allowlisted when allowed list is" do
|
|
||||||
test "not set" do
|
|
||||||
refute(mail_allowlisted_fun(nil, "joe@example.com"))
|
|
||||||
end
|
|
||||||
|
|
||||||
test "empty" do
|
|
||||||
refute(mail_allowlisted_fun("j", "joe@example.com"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "Whitelisted when" do
|
|
||||||
test "*" do
|
|
||||||
assert(mail_allowlisted_fun("*", "jane@example.com"))
|
|
||||||
end
|
|
||||||
|
|
||||||
test "Multiple set and one match" do
|
|
||||||
assert(mail_allowlisted_fun("joe@example.com, jane@example.com", "jane@example.com"))
|
|
||||||
end
|
|
||||||
|
|
||||||
test "Matches with different casings" do
|
|
||||||
assert(mail_allowlisted_fun("joe@Example.com, jane@example.com", "Joe@example.com"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Loading…
x
Reference in New Issue
Block a user