Secure Input Validation Quiz: Unit Testing u0026 Vulnerability Prevention Quiz

  1. Unit Test Goals

    What is the main goal of writing unit tests for user input validation?

    1. To ensure the input behaves as expected and blocks malicious data
    2. To increase the number of commits in the repository
    3. To randomly test some of the code for fun
    4. To make the UI look more attractive
    5. To reduce code performance
  2. SQL Injection Prevention

    Which unit test case best helps prevent SQL injection vulnerabilities?

    1. Testing the input with typical SQL code such as: ' OR '1'='1
    2. Testing input with a valid email address
    3. Testing input with only letters
    4. Testing input with random numbers
    5. Testing input using double quotes only
  3. XSS Defense Scenario

    Suppose you are testing a function that renders user comments. What input is important to include in your unit test to check for Cross-Site Scripting (XSS) vulnerabilities?

    1. u003Cscriptu003Ealert('XSS')u003C/scriptu003E
    2. helloWorld123
    3. u003Cscrptu003Ealert('XSS')u003C/scrptu003E
    4. select * from users;
    5. u003Cdivu003Ecommentu003C/divu003E
  4. Validating Input Length

    Why should you test that a username input does not exceed a specified maximum length?

    1. To prevent buffer overflow and related security issues
    2. To prevent typos in usernames
    3. To ensure better graphics rendering
    4. To increase database size limits
    5. To allow users unlimited creativity
  5. Typos in Test Inputs

    Why is it helpful to include common typos in your input unit tests?

    1. To ensure the validation handles real-world mistakes
    2. To check for better database connections
    3. To speed up frontend performance
    4. To confuse automated test runners
    5. To allow for extra punctuation marks
  6. Parameterized Queries

    Which test scenario best validates the use of parameterized queries?

    1. Sending user input containing SQL keywords and ensuring the query doesn't break
    2. Testing input that is always empty
    3. Testing input with large images
    4. Providing input with extra spaces only
    5. Changing the parameter names in the backend only
  7. Valid and Invalid Email Inputs

    A unit test for an email field should check which of the following scenarios?

    1. Valid email, invalid email, SQL payload, XSS payload, and empty string
    2. Only valid emails
    3. Only invalid emails
    4. Only uppercase email addresses
    5. Only emails ending with .com
  8. Mitigating Script Injection

    You are testing a web application for script injection flaws. Which user input should you unit test for?

    1. Input that includes u003Cscriptu003E tags
    2. Input that includes only blanks
    3. Input that includes special characters like ! and @
    4. Input using emojis
    5. Input written in all caps
  9. Acceptable Username Example

    Which value is most likely to be considered a safe, valid username in a typical unit test?

    1. john_doe99
    2. drop table users;
    3. u003Ch1u003Eadminu003C/h1u003E
    4. admin’ OR ‘1’=‘1
    5. jo hn doe
  10. Testing Required Input

    Why should unit tests specifically check for missing required fields in user input?

    1. To ensure the application doesn't accept incomplete data and handles errors gracefully
    2. To allow valid users to skip required fields
    3. To let invalid data into the database
    4. To crash the testing framework
    5. To hide errors from developers