Senior
How do you test an API endpoint for updating user data with two mandatory fields (email, phone) and two optional ones (name, surname)?
sobes.tech AI
Answer from AI
To test the user data update API endpoint with two required fields (email, phone) and two optional fields (first name, last name), the following scenarios should be covered:
-
Positive tests:
- Updating with required fields (email and phone) — verify that data is successfully updated.
- Updating with required and optional fields (first name, last name) — verify correct update.
-
Negative tests:
- Missing required fields (email or phone) — API should return a validation error.
- Invalid email or phone format — verify validation.
- Empty strings in required fields — verify that they are not accepted.
-
Boundary cases:
- Maximum length of fields.
- Special characters in optional fields.
-
Security tests:
- Authorization and authentication checks.
- SQL injection or XSS in fields.
-
Performance tests:
- Updating a large number of users.
Example update request (JSON):
{
"email": "user@example.com",
"phone": "+1234567890",
"firstName": "Ivan",
"lastName": "Ivanov"
}
For automation, tools like Postman, REST-assured, or writing tests in Python with requests and pytest can be used to cover all listed scenarios.