The Simplest Way to Make Pytest and Rubrik Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair pytest and rubrik to test data backups and recovery rules in code. The test runner calls the backup API to check snapshots, policies, and restore states. Manual backup checks take too much time and often miss broken rules. Automated tests run after every system change and verify that data stays safe. When a backup rule fails, the test suite alerts the team right away. How pytest and rubrik share keys and data The test runner needs a safe way to log in to the backup system. Teams s

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 pytest and rubrik to test data backups and recovery rules in code. The test runner calls the backup API to check snapshots, policies, and restore states.

Manual backup checks take too much time and often miss broken rules. Automated tests run after every system change and verify that data stays safe. When a backup rule fails, the test suite alerts the team right away.

How pytest and rubrik share keys and data

The test runner needs a safe way to log in to the backup system. Teams set up a service account with a scoped API token for the tests. Test fixtures read this token from a secret store before the test run starts.

Each fixture sets up a client session with the backup cluster. Tests then send web requests to read policy states, job logs, and snapshot counts. The backup cluster replies with structured data that the test suite checks against rules.

Read-only tests check if critical apps have valid protection plans and recent snapshots. Write tests trigger a test restore into a sandbox to check if recovery works. After the restore test ends, a teardown step cleans up the temporary sandbox resources.

Fixing common risks with keys and broad roles

Many teams make the mistake of using full admin keys for their test suites. If a build server leaks that key, an attacker can delete real production backups. Shared accounts also make it hard to see which test job changed a setting.

To fix this, give the test account a custom role with minimal rights. Most tests only need permission to read policy rules and view recent job results. If a test must trigger a restore, limit that role to one isolated sandbox.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged API calls create another risk when many build jobs run at once. Teams should tag each test session with a build number and a branch name. Network rules should also restrict backup API calls to known test runner hosts.

When test logs capture response payloads, they might include sensitive user fields. Masking rules can rewrite emails, phone numbers, card numbers, and national IDs in results. This keeps sensitive data out of build logs while proving the backup works.

Running backup tests in a build pipeline

Fast feedback matters when engineers update system templates or storage rules. Keep the main pipeline fast by running only read-only policy checks on every commit. These quick checks confirm that new apps belong to the right backup tier.

Full restore tests take longer because moving data takes time. Run these heavier tests on a nightly schedule rather than on every code push. Nightly runs prove that snapshots can boot and serve data when an outage hits.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Should backup tests run against production clusters?

Read-only checks can safely inspect production backup rules and recent snapshot ages. Tests that create snapshots or run restores should use a separate test cluster instead.

How should test fixtures handle slow backup jobs?

Backup and restore tasks run in the background and take several minutes to finish. Fixtures should poll the job status endpoint with a short wait and clear timeout.

What is the safest way to store backup API tokens for tests?

Never store API tokens in code files or plain text settings. Load short-lived tokens from a central secret manager into memory when the test starts.

The query runs. The emails stay hidden.