use of com.google.cloud.solutions.autotokenize.encryptors.FixedClearTextKeySetExtractor in project auto-data-tokenize by GoogleCloudPlatform.
the class EncryptionPipelineErrorTest method test.
public void test(ImmutableList<String> extraArgs, Class<? extends Exception> expectedException, Consumer<ThrowableSubject> checks) {
var args = makeArgsWithExtraOptions(extraArgs);
var options = PipelineOptionsFactory.fromArgs(args).as(EncryptionPipelineOptions.class);
var pipeline = new EncryptionPipeline(options, TestPipeline.create(), null, makeSecretsClient(), KeyManagementServiceClient.create(new Base64DecodingKmsStub("")), new FixedClearTextKeySetExtractor(options.getTinkEncryptionKeySetJson()));
var exception = assertThrows(expectedException, pipeline::run);
checks.accept(assertThat(exception));
}
use of com.google.cloud.solutions.autotokenize.encryptors.FixedClearTextKeySetExtractor in project auto-data-tokenize by GoogleCloudPlatform.
the class EncryptionPipelineTest method buildPipeline_valid.
@Test
public void buildPipeline_valid() throws Exception {
makeDlpStub();
Truth.assertThat(Sets.difference(Set.copyOf(expectedSchema.getFields()), Set.copyOf(inputSchema.getFields())).size()).isAtLeast(1);
// Perform the Encryption pipeline
new EncryptionPipeline(pipelineOptions, testPipeline, dlpClientFactory, secretsClient, KeyManagementServiceClient.create(new Base64DecodingKmsStub(pipelineOptions.getMainKmsKeyUri())), new FixedClearTextKeySetExtractor(pipelineOptions.getTinkEncryptionKeySetJson())).run().waitUntilFinish();
// Verify the output Avro file
PCollection<GenericRecord> encryptedRecords = readPipeline.apply(AvroIO.readGenericRecords(expectedSchema).from(pipelineOptions.getOutputDirectory() + "/*"));
PAssert.that(encryptedRecords).satisfies(new RecordsCountMatcher<>(expectedRecordsCount));
if (configParameters.containsKey("expectedRecordsAvro")) {
var expectedRecords = TestResourceLoader.classPath().forAvro().readFile(configParameters.get("expectedRecordsAvro")).loadAllRecords();
PAssert.that(encryptedRecords).containsInAnyOrder(expectedRecords);
}
readPipeline.run();
}
Aggregations