The Simplest Way to Make Cloud SQL and Testcomplete Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair cloud sql and testcomplete to check database state during automated UI and API tests. TestComplete runs test scripts that query Cloud SQL to confirm app actions saved the right data. This workflow catches data bugs early in the release cycle. An automated test submits a web form or calls an endpoint. Next, the test runner queries the database to check the new row. If the database record matches the input, the test passes. Still, connecting test runners to cloud databases often introd

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams pair cloud sql and testcomplete to check database state during automated UI and API tests. TestComplete runs test scripts that query Cloud SQL to confirm app actions saved the right data.

This workflow catches data bugs early in the release cycle. An automated test submits a web form or calls an endpoint. Next, the test runner queries the database to check the new row. If the database record matches the input, the test passes. Still, connecting test runners to cloud databases often introduces security risks.

How cloud sql and testcomplete share data and roles

TestComplete scripts use standard database drivers to log in to Cloud SQL instances. The test runner sends a user name, a password, and a query over the network. Cloud SQL checks those credentials and returns the matching rows to the test script.

Understanding how Cloud SQL handles admin roles helps you set up safe test users. Cloud SQL for PostgreSQL is a managed service. Because of this, customers cannot create or use accounts with true superuser attributes. Google manages a system account named cloudsqladmin that holds actual superuser privileges. Customers cannot modify or delete these system roles.

When you set up an instance, you get a default admin user named postgres. This user is created without a password, so you must set one before logging in. The postgres account belongs to the cloudsqlsuperuser role. It can create roles, create databases, and log in, but it lacks superuser or replication attributes. The cloudsqlsuperuser role does allow creating event triggers, replication users, and extensions that need high privileges.

Your automated tests do not need the default postgres account or the cloudsqlsuperuser role. Giving a test runner those privileges creates a major risk if a test script goes wrong.

Common failure modes with test database connections

Many teams take shortcuts when they wire up test suites to cloud databases. The most common mistake is putting the default admin password into shared test project files. Every engineer and continuous integration worker then uses the same powerful account. If a password leaks from a build log, an attacker gains broad control over the database.

End-to-End Encryption + SQL Query Filtering: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Overly broad permissions cause another common failure mode. A test script that only checks order totals does not need permission to drop tables. Yet teams often give test accounts full write access across every schema. One bad cleanup script in TestComplete can wipe out reference data for the whole team.

Unlogged queries and sensitive test data create a third risk. When five test runners share one database login, database logs cannot show who ran which query. Worse, staging databases often hold real customer emails, phone numbers, card numbers, or national IDs. Test scripts pull these fields into test logs and local machines.

Scoping database roles and network paths for test runners

Start by creating a dedicated database role just for TestComplete. Grant this role read-only access to the specific tables that tests must check. If a test must clean up its own rows, limit write access to those exact tables. Never add the test account to the cloudsqlsuperuser role.

Next, lock down the network path between your test runners and Cloud SQL. Do not open your database instance to public IP addresses for remote testers. Run your automated test agents inside a private network that has a direct route to the database. Rotate the test database password often and store it in a secret manager, not in test code.

Finally, protect sensitive columns before test runners query the database. Data masking rewrites matched fields like emails and card numbers in query results. This lets TestComplete check row counts and status codes while keeping real personal data out of build logs.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Should TestComplete use the default postgres user in Cloud SQL?

No, TestComplete should never use the default postgres user or the cloudsqlsuperuser role. Create a separate database user with read-only permissions on the exact tables your tests check.

How can we stop test scripts from exposing real customer data?

Use synthetic data in staging or apply data masking to your database queries. Masking rewrites sensitive fields like phone numbers, emails, and card numbers in the query results.

Why is a shared database account bad for automated testing?

Shared accounts hide which test runner or engineer ran a bad query. Using individual identities and scoped roles makes every database query easy to trace in your logs.

The query runs. The emails stay hidden.