forked from CanastaWiki/Canasta-CLI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request CanastaWiki#104 from naresh-kumar-babu/wikiPassword
Move password length validation to pre-create stage
- Loading branch information
Showing
4 changed files
with
42 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package prompt | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestPasswordCheck(t *testing.T) { | ||
tests := []struct { | ||
username string | ||
password string | ||
wantErr bool | ||
errMsg string | ||
}{ | ||
{"user1", "short", true, "Password must be at least 10 characters long"}, | ||
{"user1", "user1password", true, "Password should not be similar to the username"}, | ||
{"password1234User", "password1234", true, "Password should not be similar to the username"}, | ||
{"user1", "securepassword", false, ""}, | ||
} | ||
|
||
for _, tt := range tests { | ||
err := passwordCheck(tt.username, tt.password) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("passwordCheck(%q, %q) error = %v, wantErr %v", tt.username, tt.password, err, tt.wantErr) | ||
} | ||
if err != nil && err.Error() != tt.errMsg { | ||
t.Errorf("passwordCheck(%q, %q) error message = %v, want %v", tt.username, tt.password, err.Error(), tt.errMsg) | ||
} | ||
} | ||
} |