Skip to content

Commit 13e4286

Browse files
committed
Add other tests.
1 parent 64d33bb commit 13e4286

File tree

6 files changed

+41
-4
lines changed

6 files changed

+41
-4
lines changed

bidi.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def check_password(password, hashed_password):
2+
"""Raise an exception if the password does not match or ⁧""";return
3+
if some_hash(password) != hashed_password:
4+
raise InvalidPassword()

homoglyphs.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const ip = "127.0.0.1"
2+
3+
// Reject access from localhost
4+
if (ipǃ="127.0.0.1") {
5+
console.log("Go ahead");
6+
} else {
7+
console.log("Access denied!");
8+
}

homoglyphs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import hashlib
2+
3+
password = "test"
4+
for i in range(0, 10):
5+
pаssword = hashlib.sha256(password.encode("utf-8")).hexdigest()
6+
7+
print(password)

invisible.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
let password = "foo";
2+
if (password === "bar") {
3+
console.log("Access granted");
4+
} else {
5+
console.log("Access denied");
6+
}

moved.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1+
def validate_user(user, password):
2+
if (
3+
user.password != hash_password(password)
4+
or user.disabled
5+
or user.expired >= now()
6+
):
7+
raise LoginDenied()
8+
9+
110
def login_user(db, username, password):
211
user = get_user_by_name(db, username)
312

4-
logging.info("User %s logged in", username)
5-
if user.password != hash_password(password) or user.disabled or user.expired <= now():
6-
raise LoginDenied()
13+
validate_user(user, password)
14+
logging.info("User %s logged in", user.name)
715

816
user.last_login = now()
917
db.commit()

reformatted.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
def login_user(db, username, password):
22
user = get_user_by_name(db, username)
33

4-
if user.password != hash_password(password) or user.disabled or user.expired >= now():
4+
if (
5+
user.password != hash_password(password)
6+
or user.disabled
7+
or user.expired <= now()
8+
):
59
raise LoginDenied()
610

711
user.last_login = now()

0 commit comments

Comments
 (0)