public void TestTriggerList()
        {
            var infoTypes = new InfoType[] { new InfoType {
                                                 Name = "PERSON_NAME"
                                             } };
            var triggerId     = $"my-csharp-test-trigger-{Guid.NewGuid()}";
            var fullTriggerId = $"projects/{Fixture.ProjectId}/jobTriggers/{triggerId}";
            var displayName   = $"My trigger display name {Guid.NewGuid()}";
            var description   = $"My trigger description {Guid.NewGuid()}";

            using var randomBucketFixture = new RandomBucketFixture();
            using var bucketCollector     = new BucketCollector(randomBucketFixture.BucketName);
            var bucketName = randomBucketFixture.BucketName;
            var fileName   = Guid.NewGuid().ToString();
            var objectName = $"gs://{bucketName}/{fileName}";

            bucketCollector.CopyToBucket(Path.Combine(Fixture.ResourcePath, "dates-input.csv"), fileName);
            var trigger = TriggersCreate.Create(Fixture.ProjectId, bucketName, Likelihood.Unlikely, 1, true, 1, infoTypes, triggerId, displayName, description);

            try
            {
                var triggers = TriggersList.List(Fixture.ProjectId);
                Assert.Contains(triggers, t => t.Name == trigger.Name);
            }
            finally
            {
                TriggersDelete.Delete(trigger.Name);
            }
        }
        public void TestDeleteJob()
        {
            using var randomBucketFixture = new RandomBucketFixture();
            using var bucketCollector     = new BucketCollector(randomBucketFixture.BucketName);
            var bucketName = randomBucketFixture.BucketName;
            var fileName   = Guid.NewGuid().ToString();
            var objectName = $"gs://{bucketName}/{fileName}";

            bucketCollector.CopyToBucket(Path.Combine(Fixture.ResourcePath, "dates-input.csv"), fileName);
            var job = JobsCreate.CreateJob(Fixture.ProjectId, objectName);

            JobsDelete.DeleteJob(job.Name);
            var activeJobs = JobsList.ListDlpJobs(Fixture.ProjectId, "state = RUNNING", DlpJobType.InspectJob);

            Assert.DoesNotContain(activeJobs, j => j.Name == job.Name);
        }
Пример #3
0
        public void TestCreateDlpJob()
        {
            using var randomBucketFixture = new RandomBucketFixture();
            using var bucketCollector     = new BucketCollector(randomBucketFixture.BucketName);
            var bucketName = randomBucketFixture.BucketName;
            var fileName   = Guid.NewGuid().ToString();
            var objectName = $"gs://{bucketName}/{fileName}";

            bucketCollector.CopyToBucket(Path.Combine(Fixture.ResourcePath, "dates-input.csv"), fileName);
            var job = JobsCreate.CreateJob(Fixture.ProjectId, objectName);

            TestRetryRobot.ShouldRetry = ex => true;
            TestRetryRobot.Eventually(() =>
            {
                var response = JobsList.ListDlpJobs(Fixture.ProjectId, "state=DONE", "InspectJob");

                Assert.True(response.Any());
            });
        }