Readme
Here are some tests for val Authorization_from_SQLite
-
Valid credentials with existing user
- TableName: "Authorization_from_SQLite_Test"
- Database content: UserId "alice", PasswordHash "{PBKDF2}10000$salt123$hashedPassword123"
- Authorization header: "Basic " + btoa("alice:correctPassword")
- Expected result: true
-
Valid credentials with case-insensitive UserId
- TableName: "Authorization_from_SQLite_Test"
- Database content: UserId "Bob", PasswordHash "{PBKDF2}10000$salt456$hashedPassword456"
- Authorization header: "Basic " + btoa("bob:correctPassword")
- Expected result: true
-
Invalid password
- TableName: "Authorization_from_SQLite_Test"
- Database content: UserId "charlie", PasswordHash "{PBKDF2}10000$salt789$hashedPassword789"
- Authorization header: "Basic " + btoa("charlie:wrongPassword")
- Expected result: false
-
No Authorization header
- TableName: "Authorization_from_SQLite_Test"
- Database content: UserId "david", PasswordHash "{PBKDF2}10000$saltABC$hashedPasswordABC"
- Authorization header: undefined
- Expected result: false
-
Non-existent user
- TableName: "Authorization_from_SQLite_Test"
- Database content: (empty)
- Authorization header: "Basic " + btoa("eve:anyPassword")
- Expected result: false
- Invalid table name
- TableName: "1INVALID"
- Authorization header: "Basic " + btoa("frank:password")
- Expected result: Error thrown
-
Empty string as password
- TableName: "Authorization_from_SQLite_Test"
- Database content: UserId "grace", PasswordHash "{PBKDF2}10000$saltDEF$hashedEmptyPassword"
- Authorization header: "Basic " + btoa("grace:")
- Expected result: true (if the empty password hashes correctly)
-
Non-Basic authorization type
- TableName: "Authorization_from_SQLite_Test"
- Database content: UserId "henry", PasswordHash "{PBKDF2}10000$saltGHI$hashedPasswordGHI"
- Authorization header: "Bearer " + btoa("henry:password")
- Expected result: false
-
Malformed PasswordHash in database
- TableName: "Authorization_from_SQLite_Test"
- Database content: UserId "isaac", PasswordHash "malformedHash"
- Authorization header: "Basic " + btoa("isaac:password")
- Expected result: false
-
Very long UserId (at 256 character limit)
- TableName: "Authorization_from_SQLite_Test"
- Database content: UserId (256 'a' characters), PasswordHash "{PBKDF2}10000$saltJKL$hashedPasswordJKL"
- Authorization header: "Basic " + btoa("a".repeat(256) + ":password")
- Expected result: true (if password is correct)
-
UserId exceeding 256 characters
- TableName: "Authorization_from_SQLite_Test"
- Authorization header: "Basic " + btoa("a".repeat(257) + ":password")
- Expected result: false (as it shouldn't exist in the database)
-
Empty UserId
- TableName: "Authorization_from_SQLite_Test"
- Authorization header: "Basic " + btoa(":password")
- Expected result: false
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
rozek-authorization_from_sqlite_test.web.val.run
Updated: January 30, 2025