In brief
Personal data copied from production into a test environment is still subject to GDPR, and test environments are usually less protected than production. It is safer to test on anonymized or synthetic data. Masking that leaves the possibility of reconstructing identity is only pseudonymization: it lowers the risk, but the data is still personal. Good practice is a process that, before every environment refresh, turns data into something that cannot be linked to a person while keeping it consistent for tests.
What GDPR says about data in testing
Regulation (EU) 2016/679, the GDPR, has no separate provision on test environments. The same rules apply to them as to any other processing. The most important ones for IT teams:
- purpose limitation (Art. 5(1)(b)): data collected to serve a customer does not automatically become data for testing. Further processing for another purpose must be compatible with the original one, and Art. 6(4) lists the factors for that assessment, including safeguards such as encryption and pseudonymization;
- data minimization (Art. 5(1)(c)): data must be limited to what is necessary. Testing a loan form does not need real surnames;
- data protection by design and by default (Art. 25): the controller implements measures such as pseudonymization at the design stage. More on this principle in the article Privacy by design: GDPR in IT projects;
- security of processing (Art. 32): technical measures appropriate to the risk, including pseudonymization and encryption;
- processor (Art. 28): if an external company runs the tests on personal data, a data processing agreement is required.
A test environment with a production copy usually has more users, weaker permissions, logs with full data and exports to spreadsheets. Each of these elements is a potential breach.
Anonymization vs. pseudonymization
This distinction decides whether GDPR applies at all.
Pseudonymization is defined in Art. 4(5) GDPR: data is processed so that it can no longer be attributed to a specific person without additional information, kept separately and protected. Example: replacing a PESEL (Polish national ID number) with a random identifier, with the mapping table kept in a vault. Recital 26 of GDPR says explicitly that pseudonymized data which could be attributed to a person by the use of additional information should be considered information on an identifiable person. Such data is still personal.
Anonymization means a person cannot be identified, taking into account all the means that could reasonably be used. According to recital 26, data protection principles do not apply to anonymous information.
| Aspect | Pseudonymization | Anonymization |
|---|---|---|
| Can you get back to the person | Yes, with additional information | No, by reasonably available means |
| Is it personal data | Yes | No |
| Usefulness in testing | High, preserves relationships | Depends on the technique, consistency is easily lost |
| Typical use | Analytics, integration tests reconciled against production | Test and development environments, data for vendors |
The most common mistake is when a team replaces the first and last name but leaves the date of birth, postal code and a rare occupation. A combination of several such fields can point to one person even when none of them does so alone.
Data masking techniques
Masking is a set of techniques from which pseudonymization or anonymization is built:
- substitution: a real surname replaced with a random one from a list, an address with one from another city. It preserves the format and look of the data;
- shuffling: column values mixed across records. The distribution stays, the link to the person disappears, but only if all identifying fields are shuffled;
- generalization: an exact date of birth replaced with the year, a postal code shortened to its first digits. It reduces the risk of combining fields;
- noise addition: amounts and dates shifted by a random value within a set range. Totals and trends stay approximate;
- format-preserving generation: identifiers replaced with new ones that pass validation. A PESEL has a check digit and encodes the date of birth, so a random eleven digits will stop at the first form validation;
- tokenization: a value replaced with a token, with the mapping kept in a separate, protected system. This is pseudonymization, not anonymization.
What is key is referential integrity. A customer with ID 1001 must have the same masked ID in the accounts system, the card system and the data warehouse, otherwise integration and migration tests stop making sense. That is why masking is done deterministically, with the same key for all systems in one refresh, and the key is destroyed after the process if the goal is anonymization.
Synthetic data
Synthetic data is generated from scratch, without copying records from production. Its main advantage: there are no real people in it, so the problem of protecting personal data in testing largely disappears.
Synthetic data works especially well when:
- the system is new and production does not exist yet;
- tests need rare cases or ones impossible to find in production, for example a customer with a dozen accounts in different currencies and a bailiff's seizure;
- the data goes to an external team or a cloud environment;
- automated tests must prepare data themselves before every run.
There is one limitation, but a serious one: synthetic data shows only what someone anticipated. Production contains records from many years back, with fields filled according to old rules, with duplicates and errors. Data migration tests need this variety, which is why such projects combine synthetic data with an anonymized slice of production. The rules from the article on data quality help assess data variety.
How to build a test data process
A process that works at banks and insurers usually looks like this:
- Inventory. A list of tables and fields with personal data, including free-text fields, attachments and logs. Descriptive fields such as “notes” are the most common place for leaks.
- Masking rules for each field. Technique, format, consistency requirements across systems. The rules are consulted with the data protection officer if the organization has appointed one.
- Masking before data leaves the production zone. The copy does not reach the test environment in raw form, not even for a moment.
- Verifying the result. An automated check that the masked database has no real identifiers, and a re-identification test on field joins.
- Supplementing with synthetic data. Edge and rare cases generated by script.
- Documentation. A description of the process and a risk assessment, ready for audit.
Such a process is part of environment preparation, not a one-off project. With every database schema change, the rules need review. Similar tasks appear in migration and testing projects, which we describe in the case study on data migration testing in a merger of two banks.
Questions and answers
Is it allowed to test on a copy of the production database?
GDPR does not prohibit it outright, but such processing requires a legal basis, compatibility with the original purpose, data minimization and safeguards appropriate to the risk. In practice it is hard to show that testing needs real personal data when masked or synthetic data serves the same purpose. That is why many organizations adopt the rule: no unmasked personal data outside production. It is worth making the decision with the data protection officer.
Is masked data still personal data?
It depends on the technique. If a key, a mapping table or other information exists that allows getting back to the person, it is pseudonymization and the data is still personal. If the link cannot be reconstructed by reasonably available means, including by combining fields, it is anonymization and GDPR does not apply. The line is assessed for a specific data set, not for a tool.
Is synthetic data enough for data migration testing?
Rarely on its own. A migration is meant to move the data that is actually in the system, with historical formats, gaps and duplicates. Synthetic data will not reproduce that unless the generator was built on a detailed analysis of the production profile. A typical combination is an anonymized production copy for migration dress rehearsals and synthetic data for edge cases and automated tests.
What about personal data in test environment logs?
Logs are a common, overlooked source of personal data, because applications record full requests and responses. If the test environment runs on masked data, the logs contain masked data. If not, logs must be covered by the same rules as the database: restricted access, short retention, field masking in the logging library configuration. The simplest approach is to remove the problem at the source and not log personal data in any environment.