Readme

Here are some tests for val Authorization_from_SQLite

Test Cases

Positive Test Cases

  1. 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
  2. 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

Negative Test Cases

  1. 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
  2. No Authorization header

    • TableName: "Authorization_from_SQLite_Test"
    • Database content: UserId "david", PasswordHash "{PBKDF2}10000$saltABC$hashedPasswordABC"
    • Authorization header: undefined
    • Expected result: false
  3. Non-existent user

    • TableName: "Authorization_from_SQLite_Test"
    • Database content: (empty)
    • Authorization header: "Basic " + btoa("eve:anyPassword")
    • Expected result: false

Error Cases

  1. Invalid table name
    • TableName: "1INVALID"
    • Authorization header: "Basic " + btoa("frank:password")
    • Expected result: Error thrown

Edge Cases

  1. 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)
  2. 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
  3. Malformed PasswordHash in database

    • TableName: "Authorization_from_SQLite_Test"
    • Database content: UserId "isaac", PasswordHash "malformedHash"
    • Authorization header: "Basic " + btoa("isaac:password")
    • Expected result: false
  4. 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)
  5. 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)
  6. Empty UserId

    • TableName: "Authorization_from_SQLite_Test"
    • Authorization header: "Basic " + btoa(":password")
    • Expected result: false
Code
HTTP
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!