Gray Box Testing

A cat inside a gray box

In gray box testing we have some knowledge about the internal structure of the application, but, as in black box testing, we mostly rely on the specification.

For example, we might have access to the database schema and spot bugs already at the documentation review stage. We will cover databases later here.

Analyzing Database-Level Constraints

Access to the database schema allows the tester to check in advance whether the requirements match the actual table structure.

Below are examples of bugs that can be found simply by comparing the requirements with the schema.

Data type
Requirements Database
The field may contain any characters The field has a numeric type INTEGER
The field must store text up to 200 characters long The field is limited to 100 characters VARCHAR(100)
Bug: A smaller size constraint in the database may lead to errors when writing or updating data.
Integrity constraint
Requirements Database
The field may be empty The field has a constraint NOT NULL
Bug: NOT NULL constraint may cause an error when inserting a record with an empty value.
Value uniqueness
Requirements Database
Values in the field are not unique The field has a constraint UNIQUE
Bug: UNIQUE constraint may cause an error when inserting a record with a duplicate value.
Task

Review the API requirements and the database schema. Perform gray box testing. When the server receives a request, it updates the name column of the table cat.

HTTP request form

Requirements for the API:

  • Endpoint /hello-gray-box-server
  • HTTP method that corresponds to updating data on the server
  • Header with a content type application/json
    (indicates that data will be sent in JSON format)
  • Request body must contain the key name with any string value in JSON format
Key Type Required Constraints
name string + 1 to 30 characters

Cat table schema:

Field Type Description
id integer Record identifier
name varchar(16) Name
age integer Age

Field constraints:

  • varchar(16) - string up to 16 characters
  • integer - number

We did something similar in the task from the API. This time, our goal is to find a bug using both the requirements and additional knowledge of the database schema.

Task available to premium users!
Sidebar arrow