Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances the Firebase Auth integration tests by updating the GenerateEmailAddress utility to incorporate platform-specific labels and test names, which improves the traceability of generated test accounts. It also refactors several test cases for better robustness, including more explicit error checking for provider linking and additional debug logging. The review feedback suggests using std::to_string for more idiomatic and portable integer-to-string conversion and simplifying the email string construction logic.
| char time_string[22]; | ||
| snprintf(time_string, sizeof(time_string), "%lld", | ||
| app_framework::GetCurrentTimeInMicroseconds()); |
There was a problem hiding this comment.
Using snprintf with %lld for an int64_t value can lead to portability issues or compiler warnings if int64_t is not exactly long long on all target platforms. Since this is C++, using std::to_string is a safer and more idiomatic way to convert the timestamp to a string.
| char time_string[22]; | |
| snprintf(time_string, sizeof(time_string), "%lld", | |
| app_framework::GetCurrentTimeInMicroseconds()); | |
| std::string time_string = std::to_string(app_framework::GetCurrentTimeInMicroseconds()); |
| std::string email = "user_"; | ||
| email.append(INTEGRATION_TEST_PLATFORM_NAME); | ||
| email.append("_"); | ||
| email.append(sanitized_test_name); | ||
| email.append("_"); | ||
| email.append(time_string); | ||
| email.append("@gmail.com"); |
There was a problem hiding this comment.
The email construction logic can be simplified by using string concatenation or a single append call, which improves readability. Additionally, since time_string is now a std::string (per the previous suggestion), the append calls are straightforward.
| std::string email = "user_"; | |
| email.append(INTEGRATION_TEST_PLATFORM_NAME); | |
| email.append("_"); | |
| email.append(sanitized_test_name); | |
| email.append("_"); | |
| email.append(time_string); | |
| email.append("@gmail.com"); | |
| std::string email = "user_" + std::string(INTEGRATION_TEST_PLATFORM_NAME) + "_" + | |
| sanitized_test_name + "_" + time_string + "@gmail.com"; |
Description
There are two noticeable issues in the nightly tests:
SignInWithBadEmail would regularly fail because the backend thought it was suspicious, which resulted in the wrong error. Just deleting that test, since that behavior doesn't really need to be tested anyway.
LinkAnonymousUserWithEmailCredential was not properly cleaning up the users it created, resulting in leftover users on the backend that needed to be cleaned up. Refactored the test to address it.
Also adjusted the generated emails, so that they can be more easily tracked back if they are not cleaned up properly.
Testing
https://github.com/firebase/firebase-cpp-sdk/actions/runs/25352154658
Type of Change
Place an
xthe applicable box:Notes
Release Notessection ofrelease_build_files/readme.md.