Skip to content

Commit

Permalink
Fix "password too short" tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gcpreston committed Jun 11, 2024
1 parent 4b20ed6 commit 0f379bd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions test/lax/users_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ defmodule Lax.UsersTest do
end

test "validates email and password when given" do
{:error, changeset} = Users.register_user(%{email: "not valid", password: "not valid"})
{:error, changeset} = Users.register_user(%{email: "not valid", password: "short"})

assert %{
email: ["must have the @ sign and no spaces"],
password: ["should be at least 12 character(s)"]
password: ["should be at least 8 character(s)"]
} = errors_on(changeset)
end

Expand Down Expand Up @@ -97,7 +97,7 @@ defmodule Lax.UsersTest do
describe "change_user_registration/2" do
test "returns a changeset" do
assert %Ecto.Changeset{} = changeset = Users.change_user_registration(%User{})
assert changeset.required == [:password, :email]
assert changeset.required == [:time_zone, :password, :username, :email]
end

test "allows fields to be set" do
Expand Down Expand Up @@ -262,12 +262,12 @@ defmodule Lax.UsersTest do
test "validates password", %{user: user} do
{:error, changeset} =
Users.update_user_password(user, valid_user_password(), %{
password: "not valid",
password: "short",
password_confirmation: "another"
})

assert %{
password: ["should be at least 12 character(s)"],
password: ["should be at least 8 character(s)"],
password_confirmation: ["does not match password"]
} = errors_on(changeset)
end
Expand Down Expand Up @@ -471,12 +471,12 @@ defmodule Lax.UsersTest do
test "validates password", %{user: user} do
{:error, changeset} =
Users.reset_user_password(user, %{
password: "not valid",
password: "short",
password_confirmation: "another"
})

assert %{
password: ["should be at least 12 character(s)"],
password: ["should be at least 8 character(s)"],
password_confirmation: ["does not match password"]
} = errors_on(changeset)
end
Expand Down
4 changes: 2 additions & 2 deletions test/lax_web/live/user_registration_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ defmodule LaxWeb.UserRegistrationLiveTest do
result =
lv
|> element("#registration_form")
|> render_change(user: %{"email" => "with spaces", "password" => "too short"})
|> render_change(user: %{"email" => "with spaces", "password" => "short"})

assert result =~ "Register"
assert result =~ "must have the @ sign and no spaces"
assert result =~ "should be at least 12 character"
assert result =~ "should be at least 8 character"
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/lax_web/live/user_reset_password_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ defmodule LaxWeb.UserResetPasswordLiveTest do
lv
|> element("#reset_password_form")
|> render_change(
user: %{"password" => "secret12", "password_confirmation" => "secret123456"}
user: %{"password" => "secret1", "password_confirmation" => "secret123456"}
)

assert result =~ "should be at least 12 character"
assert result =~ "should be at least 8 character"
assert result =~ "does not match password"
end
end
Expand Down Expand Up @@ -75,14 +75,14 @@ defmodule LaxWeb.UserResetPasswordLiveTest do
lv
|> form("#reset_password_form",
user: %{
"password" => "too short",
"password" => "short",
"password_confirmation" => "does not match"
}
)
|> render_submit()

assert result =~ "Reset Password"
assert result =~ "should be at least 12 character(s)"
assert result =~ "should be at least 8 character(s)"
assert result =~ "does not match password"
end
end
Expand Down
8 changes: 4 additions & 4 deletions test/lax_web/live/user_settings_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ defmodule LaxWeb.UserSettingsLiveTest do
|> render_change(%{
"current_password" => "invalid",
"user" => %{
"password" => "too short",
"password" => "short",
"password_confirmation" => "does not match"
}
})

assert result =~ "Change Password"
assert result =~ "should be at least 12 character(s)"
assert result =~ "should be at least 8 character(s)"
assert result =~ "does not match password"
end

Expand All @@ -145,14 +145,14 @@ defmodule LaxWeb.UserSettingsLiveTest do
|> form("#password_form", %{
"current_password" => "invalid",
"user" => %{
"password" => "too short",
"password" => "short",
"password_confirmation" => "does not match"
}
})
|> render_submit()

assert result =~ "Change Password"
assert result =~ "should be at least 12 character(s)"
assert result =~ "should be at least 8 character(s)"
assert result =~ "does not match password"
assert result =~ "is not valid"
end
Expand Down

0 comments on commit 0f379bd

Please sign in to comment.