Server GDPR timeline and questions

Hey @fmunhoz,

You can refer to com.atlassian.jira.dev.backdoor.UserAnonymizeBackdoor in the jira-func-test-plugin to see how we set up our integration tests for this area. It was added in Jira 8.2.

As a step by step breakdown, you will need to use AnonymizeUserService that’s available through @ComponentImport.

First, you will have to create an anonymization request and validate it, e.g.:

        final AnonymizeUserService.AnonymizeValidationResult validateResult = anonymizeUserService.validateAnonymize(AnonymizeUserService.AnonymizeUserRequest.builder()
                .targetUser(userKey)
                .rerunPluginPoints(rerunPluginPoints)
                .oldUserName(oldUserName)
                .oldUserKey(oldUserKey)
                .newOwnerKey(newOwnerKey)
                .executor(authenticationContext.getLoggedInUser())
                .asyncTaskContext(Contexts.nullContext())
                .build()
        );
        if (!validateResult.isValid()) {
            return Response.status(Response.Status.BAD_REQUEST).entity(
                    validateResult.getErrorCollection().toString()).build();
        }

Then, you can actually perform the operation using the validation result from the last step:

        final AnonymizeUserService.AnonymizePerformResult performResult = anonymizeUserService.perform(validateResult);
        if (!performResult.getReport().isValid()) {
            return Response.status(Response.Status.BAD_REQUEST).entity(
                    performResult.getReport().toString()
            ).build();
        }

Finally, we return a custom object that holds some outputs from the operation, just to perform asserts in the integration tests:

        return Response.ok(
                new AnonymizePerformResult(...)
        ).cacheControl(never()).build();

Hope this helps. :slight_smile:

4 Likes